Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #...............................................................................
- # Begin code alterations - 13.10.2014 - Rodrigo Boechat .
- # Reason: .
- # A new clean_usb implementation was necessary to follow the alterations made .
- # on writefs. .
- #...............................................................................
- #...............................................................................
- # Maintained the original code without alterations. .
- # Thus, the original was renamed "clean_usb_orig". .
- #...............................................................................
- # Clean out old backups to save disk space
- clean_usb_orig()
- {
- echo ""
- echo -en "\033[1m`gettext \"Clean\"`\033[0m
- ================================================================================"
- gettext "Remove old rootfs.gz.unixtimestamp backup filesystems to free up disk space."; echo -e "\n\n"
- # Locate and interactively remove old filesystems from /home directory
- for file in `find /home/boot/rootfs.gz.[0-9]*`
- do
- gettext "Do you wish to remove: `basename $file` (Yes/no/exit) ? "
- read answer
- case $answer in
- e|E|"exit"|Exit)
- exit 0 ;;
- y|Y|yes|Yes)
- rm -f $file ;;
- *)
- gettext "No filesystems selected, exiting..." ; echo "" ;;
- esac
- done
- }
- #...............................................................................
- # 13.10.2014 - Rodrigo Boechat .
- # Now is also necessary that the "clean_usb" knows how to handle entries .
- # in boot menu. .
- #...............................................................................
- clean_usb()
- {
- echo ""
- echo -en "\033[1m`gettext \"Clean\"` Usb\033[0m
- ================================================================================"
- gettext "Remove old unixtimestamp.rootfs.gz backup filesystems to free up disk space."; echo -e "\n\n"
- gettext "What do you wish to do?"
- echo -en "
- \033[1mStandard\033[0m Cleaning - Deletes all backups except the latest.
- Complete Cleaning - Deletes all backups.
- \033[1mST\033[0m for Standard
- CO for Complete
- Exit
- (St/co/exit):: "
- read vAnswer
- echo -e "\n"
- case $vAnswer in
- ST|St|sT|st)
- #..................................................................
- # Remove all but the latest backup. .
- # As the latest backup should be in boot menu entry, no change in .
- # extlinux.conf & isolinux.cfg is necessary. .
- #..................................................................
- for file in $(find /home/boot/[0-9]*.rootfs.gz | sort -r | sed '1{/.*/d}')
- do
- echo "Removing $file..."
- rm -f "$file"
- done
- echo "Everything done."
- ;;
- CO|Co|cO|co)
- #..................................................................
- # Remove all backup. .
- #..................................................................
- echo "Erasing all backup. Wait a minute or two..."
- find /home/boot/[0-9]*.rootfs.gz -exec rm -f '{}' \;
- #..................................................................
- # Retrieve the home UUID from extlinux.conf. .
- #..................................................................
- vHome=$(cat /home/boot/extlinux/extlinux.conf | grep "home" | tail -n 1 | awk -F ' ' '{print $8}')
- #..................................................................
- # Clear the Restore menu entry, from extlinux.conf & isolinux.cfg .
- # and switch back to "# Space Reserved for Recovery #" instead. .
- #..................................................................
- echo "Clearing extlinux & isolinux..."
- sed -i ':a;N;$!ba;s/LABEL tazUsbRecovery\n\tMENU LABEL SliTaz Usb Recovery\n\tCOM32 c32box.c32\n\tappend linux \/boot\/bzImage initrd=\/boot\/[0-9]*.rootfs.gz rw root=\/dev\/null autologin '$vHome'/# Space Reserved for Recovery #/' /home/boot/extlinux/extlinux.conf
- sed -i ':a;N;$!ba;s/LABEL tazUsbRecovery\n\tMENU LABEL SliTaz Usb Recovery\n\tCOM32 c32box.c32\n\tappend linux \/boot\/bzImage initrd=\/boot\/[0-9]*.rootfs.gz rw root=\/dev\/null autologin '$vHome'/# Space Reserved for Recovery #/' /home/boot/extlinux/isolinux.cfg
- echo "Everything done."
- ;;
- e|E|"exit"|Exit)
- echo "Exiting..."
- exit 0
- ;;
- *)
- echo "Instruction not recognized. Exiting..."
- exit 0
- ;;
- esac
- }
- #...............................................................................
- # End code alterations - 13.10.2014 - Rodrigo Boechat .
- #...............................................................................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement