#!/bin/bash # # kusbsave # # Save changes of the running Slax 6 system (booted off USB drive) onto USB drive or create a lzm of # different existing lzms with the option to delete the old ones # # Written by flux (pilleus.pulcher at arcor.de) # Copyright by flux # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Version 0.1a 20070806 # Version 0.1b 20070807 # Changes in 0.1b # -added the stop commands if a user chooses "cancel" # choice=$(kdialog --geometry 400x50 --title "kusbsave" --radiolist "Please choose your action:" 1 "Save the changes of the running system to USB drive" on 2 "Create a new lzm of different existing lzms" off) if [ "$choice" = "" ]; then exit fi if [ "$choice" = "1" ]; then savelzm=$(kdialog --title "kusbsave" --getsavefilename "`echo /mnt/live/mnt/*/slax/modules/`"$(date +'%y.%m.%d.%H.%M').lzm"" ".lzm") if [ "$savelzm" = "" ]; then exit fi sync konsole -T "Creating $savelzm ..." --geometry 750x15 -e dir2lzm /mnt/live/memory/changes/ $savelzm sync kdialog --geometry 400x50 --title "kusbsave" --msgbox "The changes of the running system have been stored in\n\n $savelzm.\n\n The script will finish now." else ls /mnt/live/memory/images/ > /tmp/includelist ls /mnt/live/memory/images/ >> /tmp/includelist ls /mnt/live/memory/images/ >> /tmp/includelist include=$(kdialog --title "kusbsave" --checklist "Now you can choose one or more module(s) out of your running system:" `cat /tmp/includelist | sort | sed 's/\///g'`) if [ "$include" = "" ]; then exit fi echo $include | sed 's/"//g' > /tmp/include mkdir /tmp/work for modinc in $include do { echo $modinc | sed 's/"//g' > /tmp/modinc2 modinc1=$(cat /tmp/modinc2) cp -R /mnt/live/memory/images/$modinc1/* /tmp/work/ } | kdialog --title "kusbsave" --passivepopup "The choosen module will be copied to a temporary directory. Please wait a moment ..." modinc1=$(cat /tmp/modinc2) kdialog --title "kusbsave" --msgbox "The module $modinc1 was copied to /tmp/work/. We go on now ...!" done kdialog --title "kusbsave" --msgbox "Now you can choose the storage medium and the name of your new module ...!" newlzm=$(kdialog --title "kusbsave" --getsavefilename "`echo /mnt/live/mnt/*/slax/modules/`"$(date +'%y.%m.%d.%H.%M').lzm"" ".lzm") if [ "$newlzm" = "" ]; then exit fi konsole -T "Creating $newlzm ..." --geometry 750x15 -e dir2lzm /tmp/work $newlzm kdialog --title "kusbsave" --msgbox "The choosen module was compressed and stored in `echo $newlzm`!" choice2=$(kdialog --title "kusbsave" --radiolist "Do you want to remove the choosen modules, which were put together into $newlzm:" 1 "Yes, the modules shall be deleted." on 2 "No, the modules shall be untouched." off) if [ "$choice2" = "" ]; then exit fi if [ "$choice2" = "1" ]; then for i in `cat /tmp/include`; do rm /mnt/live/mnt/*/slax/modules/$i done else exit fi fi rm -R /tmp/work 2>/dev/null rm /tmp/{mo*,include*} 2>/dev/null