From 1d7bf3cf4cb1fe00d496cf5b457332b5cc3255f2 Mon Sep 17 00:00:00 2001 From: Holger Paradies Date: Thu, 28 Apr 2016 23:15:48 +0200 Subject: add new package kanotix-enable-persistent-live move files from kanotix-build-tree to package --- backend/modules/install_configure | 1 + debian/control | 5 ++ debian/kanotix-enable-persistent-live.install | 2 + kanotix/9000-enable-persistent | 56 ++++++++++++ kanotix/enable_persistent_live | 123 ++++++++++++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100644 debian/kanotix-enable-persistent-live.install create mode 100755 kanotix/9000-enable-persistent create mode 100755 kanotix/enable_persistent_live diff --git a/backend/modules/install_configure b/backend/modules/install_configure index f6a75ea..719a9c8 100644 --- a/backend/modules/install_configure +++ b/backend/modules/install_configure @@ -114,6 +114,7 @@ function configure_target_purge_live_only_stuff() busybox \ acritoxinstaller \ acritoxinstaller-kanotix \ + kanotix-enable-persistent-live \ live-boot-initramfs-tools \ live-boot \ live-initramfs \ diff --git a/debian/control b/debian/control index fb384ed..0b77cfc 100644 --- a/debian/control +++ b/debian/control @@ -17,3 +17,8 @@ Architecture: all Depends: acritoxinstaller (= ${source:Version}) Description: AcritoxInstaller for KANOTIX +Package: kanotix-enable-persistent-live +Architecture: all +Depends: acritoxinstaller (>= ${source:Version}), zenity | kde-baseapps-bin +Description: create persistent kanotix usb stick + Only useful on live-iso diff --git a/debian/kanotix-enable-persistent-live.install b/debian/kanotix-enable-persistent-live.install new file mode 100644 index 0000000..78c1759 --- /dev/null +++ b/debian/kanotix-enable-persistent-live.install @@ -0,0 +1,2 @@ +kanotix/enable_persistent_live /usr/bin +kanotix/9000-enable-persistent /lib/live/config diff --git a/kanotix/9000-enable-persistent b/kanotix/9000-enable-persistent new file mode 100755 index 0000000..734af95 --- /dev/null +++ b/kanotix/9000-enable-persistent @@ -0,0 +1,56 @@ +#!/bin/sh + +# "enable persistent" desktop-icon + +Persistent () +{ +if [ -e /var/lib/live/config/enable-persistent ] +then + return +fi +echo -n " enable-persistent" +Configure_Persistent +} + +Configure_Persistent () +{ +if ! [ -x /usr/bin/enable_persistent_live ] +then + touch /var/lib/live/config/enable-persistent + return +fi + +case "$(awk '{if($2=="/live/image"||$2=="/lib/live/mount/medium"){print $1;}}' /proc/mounts)" in +/dev/sd*) + case "$( ls /grub.cmdline 2>/dev/null)" in + /grub.cmdline) + rm -f /home/${LIVE_USERNAME}/Desktop/enable_persistent.desktop + ;; + *) + sudo -u "${LIVE_USERNAME}" sh -c "mkdir -p /home/${LIVE_USERNAME}/Desktop; cat > /home/${LIVE_USERNAME}/Desktop/enable_persistent.desktop" <<"EOF" +[Desktop Entry] +Comment[de]=Diesen Live-USB-Stick persistent machen, d.h. alle Änderungen werden auf dem Stick gespeichert. +Comment=Make this Live-USB-Stick persistent, i.e. all changes will be saved to the stick. +Exec=/usr/bin/enable_persistent_live +Icon=acritoxinstaller +MimeType= +Name[de]=»persistent« aktivieren +Name=enable »persistent« +StartupNotify=true +Terminal=false +TerminalOptions= +Type=Application +EOF + chmod +x /home/${LIVE_USERNAME}/Desktop/enable_persistent.desktop + ;; + esac + ;; +*) + rm -f /home/${LIVE_USERNAME}/Desktop/enable_persistent.desktop + ;; +esac + +touch /var/lib/live/config/enable-persistent +} + +Persistent diff --git a/kanotix/enable_persistent_live b/kanotix/enable_persistent_live new file mode 100755 index 0000000..a28bdc0 --- /dev/null +++ b/kanotix/enable_persistent_live @@ -0,0 +1,123 @@ +#!/bin/bash +# This script automatically configures your Live-USB-Stick to be persistent +# +# Written by Andreas Loibl +KDIALOG="$(which kdialog)" || KDIALOG="/usr/bin/kdialog" +ZENITY="$(which zenity)" || ZENITY="/usr/bin/zenity" + +partition=3 +filesystem=ext4 + +. /etc/default/distro +isodev="$(awk '{if($2=="/live/image"||$2=="/lib/live/mount/medium"){print $1;}}' /proc/mounts)" +case $isodev in +/dev/sd*) ;; +*) isodev= ;; +esac +case "$( ls /grub.cmdline 2>/dev/null)" in +/grub.cmdline) +if [ -x "$KDIALOG" ]; then + $KDIALOG --error "Persistent mode seems to be enabled already!" --title "Persistent Live-USB-Stick" +elif [ -x "$ZENITY" ]; then + $ZENITY --error --text "Persistent mode seems to be enabled already!" --title "Persistent Live-USB-Stick" +fi +exit 1 +;; +esac + +if [ "$FLL_DISTRO_MODE" != "live" -o -z "$isodev" ]; then +if [ -x "$KDIALOG" ]; then + $KDIALOG --error "This script can only be used from a Live USB-Stick!" --title "Persistent Live-USB-Stick" +elif [ -x "$ZENITY" ]; then + $ZENITY --error --text "This script can only be used from a Live USB-Stick!" --title "Persistent Live-USB-Stick" +fi +exit 1 +fi + +if ((UID)); then +if [ -x "$KDIALOG" ]; then +$KDIALOG --warningcontinuecancel "This script automatically configures your Live-USB-Stick to be persistent: + +* it adds a new partition into the unused space of your stick +* formats the partition with $filesystem filesystem +* writes config files to the new partition + +=============================================================== +CURRENT CHANGES ARE NOT STORED, YOU HAVE TO REBOOT TO ENABLE PERSISTENCE! +=============================================================== + +Press \"Continue\" when you are ready to start. + +" --title "Persistent Live-USB-Stick" || exit 0 +elif [ -x "$ZENITY" ]; then + +$ZENITY --question --text "This script automatically configures your Live-USB-Stick to be persistent: + +* it adds a new partition into the unused space of your stick +* formats the partition with $filesystem filesystem +* writes config files to the new partition + +=============================================================== +CURRENT CHANGES ARE NOT STORED, YOU HAVE TO REBOOT TO ENABLE PERSISTENCE! +=============================================================== + +Press \"Continue\" when you are ready to start. + +" --title "Persistent Live-USB-Stick" || exit 0 +fi +cp "$0" "/tmp/$(basename "$0")" +chmod +x "/tmp/$(basename "$0")" +if [ -x "$KDIALOG" ]; then +$KDIALOG --progressbar "Please wait..." --title "Persistent Live-USB-Stick" 0 +sudo "/tmp/$(basename "$0")" "$@" +elif [ -x "$ZENITY" ]; then +sudo "/tmp/$(basename "$0")" "$@" | $ZENITY --progress --pulsate --text "Please wait..." --title "Persistent Live-USB-Stick" 0 +fi + +exit $? +fi + +exec >/tmp/persistent.log 2>&1 +set -x + +. /usr/share/acritoxinstaller/modules/partitions +isodisk="$(get_disk $isodev)" +is_removeable "$isodisk" || exit 1 + +nop() { return 0; } +trap nop TERM KILL HUP + +# Debug output +set -x + +if [ ! -e "$isodisk"$partition ]; then + # Add partition + echo "n|p|$partition|||w" | tr '|' '\n' | fdisk "$isodisk" + partprobe "$isodisk" + while [ ! -e "$isodisk"$partition ]; do sleep 1; done + mkfs.$filesystem -L "persistence" "$isodisk"$partition +fi + +if [ -d /lib/live/mount ]; then + mkdir -p /lib/live/mount/persistence + mount "$isodisk"$partition /lib/live/mount/persistence + set -- $(cat /proc/cmdline) + shift + echo "set persistence_cmdline='$@ persistence'" > /lib/live/mount/persistence/grub.cmdline + echo "/ union" > /lib/live/mount/persistence/persistence.conf + umount /lib/live/mount/persistence + rmdir /lib/live/mount/persistence +elif [ -d /live ]; then + mkdir -p /live/persistence + mount "$isodisk"$partition /live/persistence + set -- $(cat /proc/cmdline) + shift + echo "set persistence_cmdline='$@ persistence'" > /live/persistence/grub.cmdline + echo "/ union" > /live/persistence/persistence.conf + umount /live/persistence + rmdir /live/persistence +fi + +#killall -9 kdialog +kill $(ps ax | grep kdialog | grep Live-USB | cut -c2-5) +exit 0 -- cgit v1.0