Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case $COMMAND in
- writefs)
- # Writefs to rootfs.gz
- check_root
- if [ -z $2 ]; then
- COMPRESSION=none
- else
- COMPRESSION=$2
- fi
- # Start info
- newline
- boldify "$(gettext 'Write filesystem')"
- separator
- cat << EOT
- $(gettext "The command writefs will write all the current filesystem into a suitable
- cpio archive (rootfs.gz) usable on a bootable LiveUSB media.")
- $(boldify "Archive compression:") $(colorize 36 "$COMPRESSION")
- EOT
- # Clear out tazpkg cache
- rm /var/cache/tazpkg/* -r -f
- # Optionally remove sound card selection and screen resolution.
- gettext "Do you wish to remove the sound card and screen configs ? "; echo
- gettext "Press ENTER to keep or answer (No|yes|exit): "
- read anser
- case $anser in
- e|E|"exit"|Exit)
- exit 0 ;;
- y|Y|yes|Yes)
- gettext "Removing current sound card and screen configurations..."
- rm -f /var/lib/sound-card-driver
- rm -f /var/lib/alsa/asound.state
- rm -f /etc/X11/xorg.conf ;;
- *)
- gettext "Keeping current sound card and screen configurations..." ;;
- esac
- status && newline
- # Optionally remove i18n settings
- gettext "Do you wish to remove local/keymap settings ? "; echo
- gettext "Press ENTER to keep or answer (No|yes|exit): "
- read anser
- case $anser in
- e|E|"exit"|Exit)
- exit 0 ;;
- y|Y|yes|Yes)
- gettext "Removing current locale/keymap settings..."
- echo "" > /etc/locale.conf
- echo "" > /etc/keymap.conf ;;
- *)
- gettext "Keeping current locale/keymap settings..."
- grep -qs '^INCLUDE i18n.cfg' /home/boot/*linux/*linux.c* &&
- sed -i 's/^INCLUDE i18n.cfg/# &/' /home/boot/*linux/*linux.c* ;;
- esac
- status
- # Clean-up files by default
- echo "" > /etc/udev/rules.d/70-persistent-net.rules
- echo "" > /etc/udev/rules.d/70-persistant-cd.rules
- # Create list of files
- # find / -xdev | sed '/^\/home\//d;/^\/tmp\//d' >/tmp/list
- # for dev in console null tty tty1
- # do
- # echo /dev/$dev >>/tmp/list
- # done
- find /bin /etc /init /sbin /var /dev /lib /root /usr >/tmp/list
- for dir in /home /proc /run /sys /tmp /mnt /media /media/cdrom /media/flash /media/usbdisk
- do
- echo $dir >>/tmp/list
- done
- sed -i '/^\/var\/run\/.*pid$/d' /tmp/list
- # Generate initramfs with specified compression
- if [ "$COMPRESSION" = "lzma" ]; then
- gettext "Creating rootfs.gz with lzma compression... "
- cpio -o -H newc | lzma e -si -so > /rootfs.gz
- elif [ "$COMPRESSION" = "gzip" ]; then
- gettext "Creating rootfs.gz with gzip compression... "
- cpio -o -H newc | gzip -9 > /rootfs.gz
- else
- gettext "Creating rootfs.gz without compression... "
- cpio -o -H newc > /rootfs.gz
- fi < /tmp/list
- # Get initramfs size
- size=`du -sh /rootfs.gz | cut -f 1`
- # If the bootable medium is where it should be, copy across
- if (test -e /home/boot/bzImage); then
- gettext "Moving rootfs.gz to media. Remember to unmount for delayed writes!"; echo ""
- #..................................................................
- # Begin code alterations - 13.10.2014 - Rodrigo Boechat .
- # Reasons: .
- # 1) Recreated an error that involves the physical removal of the .
- # flash drive before the end of full copy of rootfs.gz. This .
- # causes the system to be broken for the next start. .
- # =============================================================== .
- # 2) Currently, writefs tazusb creates a single rootfs.gz file. .
- # And there is no entry for this new single file in boot menu. .
- # Because the slitaz boot scheme works with four files. .
- #..................................................................
- #..................................................................
- # 13.10.2014 - Rodrigo Boechat .
- # To minimize the error occurrence described in item 1. Also .
- # realized that previous.gz is not really necessary. Got rid of. .
- #..................................................................
- ## Move the old filesystem with the unix timestamp for reference
- #if (test -e /home/boot/previous.gz); then
- # mv /home/boot/previous.gz /home/boot/rootfs.gz.$(date +%s)
- #fi
- #mv /home/boot/rootfs.gz /home/boot/previous.gz
- #mv /rootfs.gz /home/boot/.
- mv /rootfs.gz /home/boot/newrootfs.gz
- vDate=$(date +%s)
- [ -f /home/boot/rootfs.gz ] && mv /home/boot/rootfs.gz /home/boot/$vDate.rootfs.gz
- mv /home/boot/newrootfs.gz /home/boot/rootfs.gz
- #..................................................................
- # 13.10.2014 - Rodrigo Boechat .
- # To remedy the lack of entry in the boot menu, writefs has to .
- # insert the menu entry for itself. .
- # The insert was made based on lines 28 and 29 found in the file: .
- # /home/boot/extlinux/extlinux.conf. .
- # 28- # Labels .
- # 29- LABEL slitaz .
- #..................................................................
- #..................................................................
- # Retrieve the home UUID from extlinux.conf. .
- #..................................................................
- vHome=$(cat /home/boot/extlinux/extlinux.conf | grep "home" | tail -n 1 | awk -F ' ' '{print $8}')
- sed -i ':a;N;$!ba;s/\(^\|\n\)\(# Labels\)\n\(LABEL slitaz\)\(\n\|$\)/\1\2\n# Begin of WriteFs Edition #\nLABEL SlitazUSB\n\tMENU LABEL Slitaz Usb\n\tCOM32 c32box.c32\n\tappend linux \/boot\/bzImage initrd=\/boot\/rootfs.gz rw root=\/dev\/null autologin '$vHome'\n# Space Reserved for Recovery #\n# End of WriteFs Edition #\n\3\4/' /home/boot/extlinux/extlinux.conf
- sed -i ':a;N;$!ba;s/\(^\|\n\)\(# Labels\)\n\(LABEL slitaz\)\(\n\|$\)/\1\2\n# Begin of WriteFs Edition #\nLABEL SlitazUSB\n\tMENU LABEL Slitaz Usb\n\tCOM32 c32box.c32\n\tappend linux \/boot\/bzImage initrd=\/boot\/rootfs.gz rw root=\/dev\/null autologin '$vHome'\n# Space Reserved for Recovery #\n# End of WriteFs Edition #\n\3\4/' /home/boot/extlinux/isolinux.cfg
- #..................................................................
- # 13.10.2014 - Rodrigo Boechat .
- # Also a menu entry for recovery. .
- #..................................................................
- if [ -f /home/boot/$vDate.rootfs.gz ]; then
- vQuantity=$(ls /home/boot/*.rootfs.gz | wc -l)
- #..................................................................
- # Regex for the recovery menu entry. .
- #..................................................................
- sed -i 's/^# Space Reserved for Recovery #$/LABEL tazUsbRecovery\n\tMENU LABEL SliTaz Usb Recovery\n\tCOM32 c32box.c32\n\tappend linux \/boot\/bzImage initrd=\/boot\/'$vDate'.rootfs.gz rw root=\/dev\/null autologin '$vHome'/' /home/boot/extlinux/extlinux.conf
- sed -i 's/^# Space Reserved for Recovery #$/LABEL tazUsbRecovery\n\tMENU LABEL SliTaz Usb Recovery\n\tCOM32 c32box.c32\n\tappend linux \/boot\/bzImage initrd=\/boot\/'$vDate'.rootfs.gz rw root=\/dev\/null autologin '$vHome'/' /home/boot/extlinux/isolinux.cfg
- if [ $vQuantity -gt 1 ]; then
- #..................................................................
- # Update the recovery boot menu entry when a new backup is created.
- #..................................................................
- sed -i 's/^\tappend linux \/boot\/bzImage initrd=\/boot\/[0-9]*\.rootfs\.gz/\tappend linux \/boot\/bzImage initrd=\/boot\/'$vDate'.rootfs.gz/' /home/boot/extlinux/extlinux.conf
- sed -i 's/^\tappend linux \/boot\/bzImage initrd=\/boot\/[0-9]*\.rootfs\.gz/\tappend linux \/boot\/bzImage initrd=\/boot\/'$vDate'.rootfs.gz/' /home/boot/extlinux/isolinux.cfg
- fi
- fi
- #..................................................................
- # End code alterations - 13.10.2014 - Rodrigo Boechat .
- #..................................................................
- else
- gettext "rootfs.gz is located in /"; echo ""
- fi
- separator
- gettext "Root filesystem size: $size"; echo ""
- echo ""
- echo "----"
- gettext "ENTER to continue..."; read i
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement