I have arrived at a new remaster script which simply squashes the running system (frugal or full), working in ram or on device, including extra sfs and savefile.
Here it is! Updated 12/10/14 and smoothed out
Code: Select all
#!/bin/bash
#SFS-Unattended-Remaster script by StemSee copyright Marcos Contant 2014
intro () {
clear
echo "
User assumes all responsibility, use at your own risk!
INTRODUCTION
This script provides an unattended remastering session.
Answer two or three questions, then, no need to answer more.
There are also other useful utilities.
Please note: on a full installation copy initrd* to /boot/ directory
Press enter to continue ...
"
read dummy
clear
}
menu () {
clear
echo " REMASTER FUNCTIONS
For processing an existing remaster directory apupsys or bpupiso
or for any of the utilities; enter the code number;
MKSQUASHFS
'1' for a xz compressed sfs/squashfs system file from apupsys.
'2' for a gz compressed sfs/squashfs
'3' for a max '-comp xz -b 1024k -Xbcj x86' sfs/squashfs
ISO
'4' for bootable iso remake from bpupiso.
'5' for burning iso to cd/dvd.
'6' for writing iso to usb storage device with option to isohybrid.
SAVEFILE
'7' for savefile/swapfile creation.
NEW REMASTER
'8' for New SFS-Unattended-Remaster.
'9' for EXIT from this script.
'10' for SFS-Direct-Remaster.
'11' for Intro.
CD RW / DVD RW TOOLS
'12' for multisession/formatting/data-iso.
Enter a number now and press 'Enter'."
read sf
clear
}
menu
timelimit=10
dir1=apupsys
dir2=bpupiso
if [ -d /live-rw-backing ]; then
path=/media/
else
path=/mnt/
fi
rtn2menu="sfs-unattended-remaster && exit"
echo ""
workdrive () {
echo -e "Enter partition name of ext 2/3/4 partition for work directory
or for existing remaster directories/iso, for use with special functions.
eg 'sda3' or 'home'
or wait for default 'sda2' $timelimit seconds\n: \c"
drive=""
read -t $timelimit drive
if [ ! -z "$drive" ]; then
echo -e "\n You entered '$drive'"
else
echo -e "\n TIME OUT\n Assume default."
drive=sda2
fi
echo
if [ ! -d $path$drive ]; then
mkdir $path$drive
mount /dev/$drive $path$drive
else
mount /dev/$drive $path$drive
fi
echo
}
fndboot () {
if [ -d /aufs ]; then #fatdog
. /etc/DISTRO_SPECS
name=$DISTRO_FILE_PREFIX.sfs
niso=new-$DISTRO_NAME.iso
subd=fd
echo "Please type the current boot partition and directory
eg /home/fatdog700/ or /sda2/fd700/"
read boot
if [[ -d $path$boot ]]; then
echo "OK"
else
clear
echo "error! try again" && fndboot
fi
elif [ -d /live-rw-backing ]; then #DebianDog-OpenBox version & puppy boot
name="01-filesystem.squashfs"
niso=new-DebianDog.iso
subd=dd
echo "Please type the current boot partition and directory
eg /sda1/live/"
read boot
if [[ -d $path$boot ]]; then
echo "OK"
else
clear
echo "error!" && fndboot
fi
elif [[ ! -d /aufs && ! -d /live-rw-backing ]]; then #normal pups
. /etc/DISTRO_SPECS
name=$DISTRO_PUPPYSFS
niso=new-$DISTRO_NAME.iso
subd=pp
. /etc/rc.d/PUPSTATE
echo $PUPSFS | cut -c 1-4,11-40 > /tmp/sfs
sed -i "s/$DISTRO_PUPPYSFS//g" /tmp/sfs
sed -i 's/^/boot=/' /tmp/sfs
. /tmp/sfs
elif [[ -d /media && -d /mnt ]]; then #lighthouse
. /etc/DISTRO_SPECS
name=${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}.sfs
niso=new-$DISTRO_NAME.iso
subd=pp
. /etc/rc.d/PUPSTATE
echo $PUPSFS | cut -c 1-4,11-40 > /tmp/sfs
sed -i "s/$DISTRO_PUPPYSFS//g" /tmp/sfs
sed -i 's/^/boot=/' /tmp/sfs
. /tmp/sfs
fi
clear
}
cdburn () {
# borrowed from 'burniso2cd' by BK
#(c) Copyright 2006, 2007 Barry Kauler.
#Lesser GPL licence v2 (/usr/share/doc/legal). 2007 www.puppylinux.com
export TEXTDOMAIN=burniso2cd
export TEXTDOMAINDIR=/usr/share/locale
export OUTPUT_CHARSET=UTF-8
eval_gettext () {
local myMESSAGE=$(gettext "$1")
eval echo \"$myMESSAGE\"
}
export LANGORG=$LANG
Yes_lbl="$(gettext 'Yes')"
No_lbl="$(gettext 'No')"
CDRECORD='cdrecord'
if [ "`which xorriso`" != "" ];then
CDRECORD='xorrecord'
export MKISOFS='xorrisofs' #growisofs reads this variable.
fi
MEDIATYPE="`Xdialog --wmclass "mini-cd" --title "Burniso2cd" --stdout --menubox "$(gettext "Welcome to our little CD/DVD burner program!\nPlease choose whether you want to burn to a CD or DVD media.\nNote that DVDs are always burnt 'open' so can be used by Puppy\nas normal or multisession, whereas for CD you will be given\nthe choice further on whether to burn as closed or open.")" 0 0 5 CD "$(gettext 'CD-R or CD-RW (must be blank)')" DVD "$(gettext 'DVD-R or DVD-RW (must be blank)')"`"
[ ! $? -eq 0 ] && sfs-unattended-remaster && exit
SELECTIONS="`probedisk | grep '|optical|' | grep '/dev/' | cut -f 1,3 -d '|' | tr " " '_' | tr -s '_'`" #110205
SELECTIONX="`echo "$SELECTIONS" | tr '|' " " | tr "\n" " "`"
if [ "$SELECTIONX" = "" ];then
pupmessage -bg '#FF8080' "$(gettext 'Sorry, no CD/DVD drive detected')"
sfs-unattended-remaster && exit
fi
BURNERDRIVE="`Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Choose burner drive')" --stdout --menubox "$(gettext 'Choose the CD/DVD drive to burn to')" 400x200 5 $SELECTIONX 2> /dev/null`"
[ ! $? -eq 0 ] && sfs-unattended-remaster && exit
[ ! -f /etc/cdburnerdevice ] && echo -n "$BURNERDRIVE" | sed -e 's/\/dev\///g' > /etc/cdburnerdevice
ISOFILE="`Xdialog --wmclass "mini-cd" --backtitle "$(gettext 'Please choose the iso file...')" --title "$(gettext 'Burniso2cd: Choose iso file')" --stdout --no-buttons --fselect "*.iso" 0 0`"
if [ ! $? -eq 0 ];then
sfs-unattended-remaster && exit
fi
CDR="$BURNERDRIVE"
CDDESCR="`echo "$SELECTIONS" | grep "$CDR" | cut -f 2 -d '|'`"
while [ ! "`mount | grep "$CDR"`" = "" ];do
pupmessage -bg "#ff8080" -center -name "burniso2cd" -title "Burniso2cd: ERROR" "The $CDR CD/DVD drive, described as:
$CDDESCR
is currently mounted.
Use MUT or Pmount to unmount it.
Please unmount CD drive, then click OK button..."
done
if [ "$MEDIATYPE" = "CD" ];then
Xdialog --wmclass "mini-cd" --title "Burniso2cd" --stdout --ok-label "$(gettext 'NORMAL')" --cancel-label "$(gettext 'MULTI')" --yesno "$(gettext 'You have selected iso file:')
$ISOFILE
$(gettext 'Do you want to burn a multi-session CD?
A multi-session CD is one that is left "open" so that further
tracks may be burnt later. The iso file that you have selected
will be burnt now as the first track.
Note, this is an experimental option for the Puppy live-CD, to
allow burning of sessions back to CD, thus personal data is saved
to CD and a hard drive or usb stick is not required.')
$(gettext "Please choose 'NORMAL' unless you have some special reason to burn
the CD multi-session (such as the iso is specifically for multisession).
Click 'NORMAL' button for normal burn...
Click 'MULTI' button for multi-session...")" 0 0
RETVAL=$?
else
RETVAL=12
fi
case $RETVAL in
0) #normal cd
BURNMULTI="-dao" #v2.02 added -dao
BURNMSG=""
;;
1) #multi cd
#BURNMULTI="-multi -tao -pad" #v2.02 added -tao -pad
BURNMULTI="-multi -tao padsize=300k" #w482
BURNMSG=""
;;
12) #multi dvd
BURNMULTI="yes"
BURNMSG="$(gettext '(blank DVD-R. A DVD+/-RW will be fast-wiped if it has data)')"
;;
*)
$rtn2menu
;;
esac
RECHECK="yes"
BURNSPEED="10"
while [ 1 ];do #burn-again-loop
BURNSPEED="`Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Burn') $MEDIATYPE" --stdout --spinbox "$(eval_gettext "Please insert blank \\\$MEDIATYPE into \\\$CDR")
$BURNMSG
$(gettext '(which is described as:') ${CDDESCR})
$(gettext 'Then click 'OK' button...')" 0 0 4 32 $BURNSPEED "$(gettext 'Set burn speed')"`"
[ ! $? -eq 0 ] && sfs-unattended-remaster && exit
sync
if [ "$MEDIATYPE" = "CD" ];then
DEVDEV="$CDR" #w482
echo "$(gettext 'Now executing:')"
echo " $CDRECORD $BURNMULTI -data -eject -v speed=$BURNSPEED dev=$DEVDEV $ISOFILE"
rxvt -name burniso2cd -bg blue -geometry 80x10 -e $CDRECORD $BURNMULTI -data -eject -v speed=$BURNSPEED dev=$DEVDEV "$ISOFILE"
else #dvd
echo "$(gettext 'Now executing:')"
echo " growisofs -speed=$BURNSPEED -Z $CDR=$ISOFILE"
rxvt -name burniso2cd -bg blue -geometry 80x10 -e growisofs -speed=$BURNSPEED -Z $CDR="$ISOFILE"
fi
sync
echo "$(gettext '...done')"
#v2.10 kirk contributed this...
# ******Verify burn******
DEVNAME="`echo -n "$CDR" | grep '/dev' | cut -f 3 -d '/'`"
if [ ! "$DEVNAME" = "" -a "$RECHECK" = "yes" ];then
Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Finished')" --stdout --ok-label "$Yes_lbl" --cancel-label "$No_lbl" --yesno "$(gettext 'Would you like to verify that the burn was successful?
This may take a while depending on the size of the iso file.')" 0 0
if [ "$?" = "0" ] ;then
pupmessage -bg "#3CA8EE" -center -name "burniso2cd" -title "$(gettext 'Burniso2cd: Burn Verify')" "$(gettext 'Make sure the CD/DVD drive is closed,
then click OK')"
echo "Waiting 15 seconds to allow drive lights to finish blinking" > /tmp/burniso2cd.log #v431
sleep 15 #v431
if [ "$( md5sum $ISOFILE | cut -f 1 -d " " )" = "$(dd if=$CDR 2>> /tmp/burniso2cd.log | head -c `stat --format=%s $ISOFILE` | md5sum | cut -f 1 -d " " )" ] ;then #v431
pupmessage -bg "#3CA8EE" -center -name "burniso2cd" -title "$(gettext 'Burniso2cd: Burn Verify')" "$(gettext 'The burn has been verified as good!')"
else
pupmessage -bg "#1E90FF" -center -name "burniso2cd" -title "$(gettext 'Burniso2cd: Burn Verify')" "$(gettext 'The burn was not verified. See details in /tmp/burniso2cd.log. You should start over.')"
fi
else
RECHECK="no" #do not check if doing repeat burns.
fi
fi
eject $CDR
Xdialog --wmclass "mini-cd" --title "$(gettext 'Burniso2cd: Finished')" --stdout --ok-label "$(gettext 'FINISHED')" --cancel-label "$(gettext 'REPEAT')" --yesno "$(gettext 'If all went well, you have now burnt iso file')
$ISOFILE
$(gettext 'to a') $MEDIATYPE!
$(gettext 'If you want to burn the iso file to another') $MEDIATYPE,
$(gettext "click 'REPEAT' button...")
$(gettext "Otherwise, click 'FINISHED' to quit...")" 0 0
[ $? -ne 1 ] && break
done #burn-again-loop
$rtn2menu
}
case $sf in
10) sfs-direct-remaster
$rtn2menu;;
1) workdrive
if [ -d $path$drive/$dir1/aufs ]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_FILE_PREFIX.sfs
elif [ -d $path$drive/$dir1/live-rw-backing ]; then
name="01-filesystem.squashfs"
elif [[ ! -d $path$drive/$dir1/aufs && ! -d $path$drive/$dir1/live-rw-backing ]]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_PUPPYSFS
fi
mksquashfs $path$drive/$dir1 $path$drive/$name -comp xz -noappend
mv -f $path$drive/$DISTRO_PUPPYSFS $path$drive/$dir2/
echo "squashed using xz compression and is in '$path''$drive'/'dir2'"
sleep 2
$rtn2menu;;
2) workdrive
if [[ -d $path$drive/$dir1/aufs ]]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_FILE_PREFIX.sfs
elif [[ -d $path$drive/$dir1/live-rw-backing ]]; then
name="01-filesystem.squashfs"
elif [[ ! -d $path$drive/$dir1/aufs && ! -d $path$drive/$dir1/live-rw-backing ]]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_PUPPYSFS
fi
mksquashfs $path$drive/$dir1 $path$drive/$name -noappend
mv -f $path$drive/$name $path$drive/$dir2/
echo "squashed using gz compression and is in '$path''$drive'/'dir2'"
sleep 2
$rtn2menu;;
3) workdrive
if [ -d $path$drive/$dir1/aufs ]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_FILE_PREFIX.sfs
elif [ -d $path$drive/$dir1/live-rw-backing ]; then
name="01-filesystem.squashfs"
elif [[ ! -d $path$drive/$dir1/aufs && ! -d $path$drive/$dir1/live-rw-backing ]]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_PUPPYSFS
fi
mksquashfs $path$drive/$dir1 $path$drive/$name -comp xz -b 1024k -Xbcj x86 -noappend
mv -f $path$drive/$DISTRO_PUPPYSFS $path$drive/$dir2/
echo "squashed using max xz compression and is in '$path''$drive'/'dir2'"
sleep 2
$rtn2menu;;
4) workdrive
if [[ -d $path$drive/$dir1/live-rw-backing ]]; then
name="01-filesystem.squashfs"
niso=new-DebianDog.iso
subd1=dd
elif [[ -d $path$drive/$dir1/aufs ]]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_FILE_PREFIX.sfs
niso=new-$DISTRO_NAME.iso
subd1=fd
elif [[ ! -d $path$drive/$dir1/aufs && ! -d $path$drive/$dir1/live-rw-backing ]]; then
. $path$drive/$dir1/etc/DISTRO_SPECS
name=$DISTRO_PUPPYSFS
niso=new-$DISTRO_NAME.iso
subd1=pp
fi
cd $path$drive
if [ $subd1=dd ]; then
genisoimage -b isolinux/isolinux.bin -c isolinux/boot.cat -D -l -R -v -no-emul-boot -boot-load-size 4 -boot-info-table -o "$niso" $path$drive/$dir2
elif [ $subd1=pp ]; then
mkisofs -b isolinux.bin -c boot.catalog -D -l -R -v -no-emul-boot -boot-load-size 4 -boot-info-table -o "$niso" $path$drive/$dir2
elif [ $subd1=fd ]; then
mkisofs -b isolinux.bin -c boot.cat -D -l -R -v -no-emul-boot -boot-load-size 4 -boot-info-table -o "$niso" $path$drive/$dir2
fi
clear
echo "ISO has been made. It is suitable for cd/dvd.
Do you want to
a) burn to cd/dvd now
b) write to usb storage
c) exit to the Menu
enter a or b or c"
read write
case $write in
a) echo "Enter the cd/dvd writer eg sr0 or sr1.
Make sure a writeable disc is in it!"
read writer
if [[ -e /dev/'$writer' ]]; then
growisofs -dvd-compat -Z /dev/$writer=$path$drive/$niso
echo "Finished!"
else
echo "No Go!"
fi
$rtn2menu;;
b) echo "Enter the usb device; eg sdb1"
read usb
umount /dev/$usb
isohybrid $niso
dd if=$path$drive/$niso of=/dev/$usb bs=4M
echo "Finished!"
sleep 2
$rtn2menu;;
c)$rtn2menu;;
esac
;;
5) echo "Do you want to use puppy native burn app with gui?
Or simple in-built command?
Or dd?
Enter p or s or dd"
read in
case $in in
p) cdburn
$rtn2menu;;
s) echo "Enter the cd/dvd writer and the path to the iso
eg 'sr0 /mnt/sda2/new-FatDog64.iso'
Make sure a writeable disc is in it!"
read writer iso
if [[ -e /dev/'$writer' ]]; then
growisofs -dvd-compat -Z /dev/$writer=$iso
echo "Finished!"
else
echo "No Go!"
fi
$rtn2menu;;
dd) echo "Enter the cd/dvd writer and the path to the iso
eg 'sr0 /mnt/sda2/new-FatDog64.iso'
Make sure a writeable disc is in it!"
read writer iso
if [[ -e /dev/'$writer' ]]; then
dd if=$iso of=/dev/'$writer' seek=0 bs=32k
echo "Finished!"
else
echo "No Go!"
fi
$rtn2menu;;
esac;;
6) echo "Enter 'usb partition iso' eg 'sdb1 sda5 /my-folder/new-Slacko-8.8.iso'
NB: If you choose to make the iso a hybrid back it up first."
read usb part iso
umount /dev/$usb
mount /dev/$part $path$part
echo "Gparted will open for you to prepare your usb device. When ready close gparted."
gparted /dev/$usb
echo "Make the iso a hybrid? y or n?"
read hybrid
if [ $hybrid=y ]; then
isohybrid $path$part$iso
else
dd if=$path$part$iso of=/dev/$usb bs=4M
fi
parted /dev/$usb set 1 boot on
echo "Finished!"
$rtn2menu;;
7)
menu2 () {
echo " a) Create savefile
b) Create swapfile
c) Exit to Menu.
choose one"
read create
}
menu2
case $create in
a) echo "Create savefile; casper-rw, parsistence, pupsave.2fs etc
Enter 'path/name' and 'fs' (ext2/3/4) and 'size'.
eg /mnt/sda2/EmSee/EmSeeV2.2save.3fs ext3 5000
( ^ about 512mb)
make sure the partition is mounted. "
read savefile fs size
dd if=/dev/zero of=$savefile bs=1024k count=$size
mkfs -t $fs -q -m 0 -F $savefile
echo "Savefile Created!"
sleep 2
$rtn2menu;;
b) echo "Create a pupswap.swp swapfile.
Enter path and size;
eg /mnt/home 5000"
read swap size
dd if=/dev/zero of=$swap/pupswap.swp bs=1024k count=$size
mkswap $swap/pupswap.swp
swapon $swap/pupswap.swp
echo "Swapfile Created and in use!
To make it permanent add this line to the bottom of fstab
"$swap/pupswap.swp none swp sw 0 0""
echo
sleep 4
geany /etc/fstab
echo "Press Enter when ready"
read dummy
$rtn2menu;;
c) $rtn2menu;;
esac;;
12) menu3 () {
echo "CD/DVD image burning and multisession functions
'1' BURNING A MULTISESSION DVD
'2' CREATE A DISC IMAGE (not bootable)
'3' BURN AN ISO IMAGE TO DVD
'4' FORMATTING A DVD RW DISC
'5' FORMATTING A CD RW DISC
'6' Restart Script
Type number and press enter"
read number
clear
}
menu3
case $number in
1) echo "To burn to a disk first time or add to a muti-session disc.
Enter the device and path-to-folder/file and session-type= new or multi;
eg sr0 /mnt/sda5/docs new -or- sr1 /media/sda3/e-books multi"
read writer files session
case $session in
new) if [[ -e /dev/'$writer' ]]; then
growisofs -Z /dev/$writer -r -J $files
echo "Finished!"
else
echo "No Go!"
fi
$rtn2menu;;
multi) if [[ -e /dev/'$writer' ]]; then
echo "writing to a multisession disc."
growisofs -M /dev/$writer -r -J $files
echo "Finished!"
else
echo "No Go!"
fi
$rtn2menu;;
esac;;
2) echo "Create a data image (iso); enter name-for-iso path-to-file
eg data-2014.iso /media/sda4/docs/*"
read nfi files
genisoimage -r -J -o $nfi $files
echo "Finished!" && $rtn2menu;;
3) echo "Write iso image to disc; enter device and path-to-iso;
eg sr0 /media/home/ISO/lina-1.8.iso"
read writer niso
if [[ -e /dev/'$writer' ]]; then
#growisofs -dvd-compat -Z /dev/$writer=$niso
dd if=$niso of=/dev/$writer seek=0 bs=32k
echo "Finished!"
else
echo "NoGo!"
fi
$rtn2menu;;
4) echo "Format DVD-RW disc, enter device to use; eg sr0"
read writer
if [[ -e /dev/'$writer' ]]; then
dvd+rw-format -blank /dev/$writer
echo "Finished!"
else
echo "No Go!"
fi
$rtn2menu;;
5) echo "Format CD-RW disc, enter device to use; eg sr0"
if [[ -e /dev/'$writer' ]]; then
cdrecord blank=fast dev=1,0,0
echo "Finished!"
else
echo "No Go!"
fi
$rtn2menu;;
6) echo "Exiting to Menu."
$rtn2menu;;
esac
;;
8) if [ $sf=8 ]; then
clear
echo "ok"
else
clear
$rtn2menu
fi;;
9) exit;;
11) intro
$rtn2menu;;
*) $rtn2menu;;
esac
fndboot
workdrive
echo ""
echo
echo "Proceeding with remaster on '$drive'."
sleep 2
echo
echo "Checking if previous remaster directories exist."
clear
sleep 4
if [ -d $path$drive/$dir1 ]; then
echo "Previous remaster directories on '$drive' exist.
They will be overwritten unless you press Ctrl + c to stop this script now
and backup the directories '$dir1' '$dir2' which are on '$drive'."
sleep 12
echo "removing"
rm -rf $path$drive/{$dir1,$dir2}
clear
echo "removed!!"
sleep 1
fi
echo
echo "Checking for previous '$niso'."
sleep 1
if [ ! -e $path$drive/$niso ]; then
echo "No previous '$niso' found on '$drive'."
sleep 1
else
clear
echo "About to delete previous '$niso' on '$drive'.
Press 'Ctrl + c' now to stop and manually save it.
Or wait 6 seconds to proceed."
sleep 8
echo
rm -f $path$drive/$niso
echo "Deleted previous '$niso'"
clear
fi
mkdir -p $path$drive/{$dir1,$dir2}
echo "Start copying from your running system.
Press Ctrl+c anytime to stop!"
sleep 2
echo
echo "rsync '/'"
rsync -a --progress /* $path$drive/$dir1/ --exclude=/{/run/*,media,live,/lib/live/mount,cdrom,aufs,dev,proc,mnt,sys,tmp,initrd,archive,audit,/var/cache/apt/*,/var/slapt-get/*,/var/lib/apt/lists/*,/var/lib/slapt/lists/*,/dev_save/*}
for subdir in {media,cdrom,live,/lib/live/mount,aufs,dev,proc,mnt,sys,tmp,archive,audit,live-rw-backing}
do
if [[ -e /"$subdir" ]]; then
mkdir -p $path$drive/$dir1/$subdir
echo "'$subdir' created."
sleep 1
else
echo "'$subdir' directory not needed for this distro."
sleep 1
fi
done
echo ""
echo "Entering remaster directory '$dir1'."
sleep 1
cd $path$drive/$dir1
echo "
Cleaning caches and .bak, .wh files and history."
rm -rf var/run/*
rm -rf var/tmp/*
rm -rf tmp/*
rm -rf audit/*
rm -rf lost+found/*
cd $path$drive/$dir1/root
rm -rf .bash_history
rm -rf .history
rm -rf .Trash/*
rm -rf .cache/mozilla
rm -rf .cache/google
rm -rf Downloads/*
rm -rf .minecraft/*
rm -rf .steam/*
rm -rf .wine/drive_c/users/root/Cookies/*
rm -rf .wine/drive_c/users/root/AppData/XBMC/userdata/addon_data/*
rm -rf .wine/drive_c/users/root/AppData/Tencent/Users/*
rm -rf .wine/drive_c/users/root/AppData/Tencent/QQ/*
rm -rf .wine/drive_c/windows/temp/*
rm -rf .wine/drive_c/users/root/Temp/*
rm -rf .Skype/*
rm -rf .thumbnails/*
echo "
Leaving '$dir1' directory."
cd ../../../../
echo -n "More cleaning..."
rm -f $path$drive/$dir1/root/.XLOADED
rm -f $path$drive/$dir1/etc/.XLOADED
chroot $path$drive/$dir1/ find . -type f -name '.wh.*' -print -exec rm -rf {} \; #remove .wh. files
chroot $path$drive/$dir1/ find . -type f -name '*.bak' -print -exec rm -rf {} \; #remove *.bak files
clear
echo -e "
Making the main.sfs squashfs filesystem choose mksquashfs code.
Key: 'pp' for puppy xz
'fd' for fatdog xz with initrd repack
'dd' for debbiandog xz max and essential tweaks
'Enter' for puppy.sfs gz
Or wait for auto detect
Enter mksquashfs code within $timelimit seconds\n: \c"
comp=""
read -t $timelimit comp
if [ ! -z "$comp" ]; then
echo -e "
\n You entered '$comp'.
Using '$comp' code for mksquashfs."
else
echo -e "
\n TIME OUT\n Assume default -comp xz."
if [[ -d /aufs ]]; then
comp=fd
elif [[ "$path" = /media/ ]]; then
comp=dd
elif [[ "$path" = /mnt/ ]]; then
comp=pp
else
echo "Enter custom name for sfs. '00-filesystem.squashfs' 'puppy2.sfs' etc"
read comp
fi
fi
modules () {
clear
echo "Checking for kernel-modules.sfs!"
if [ -d /initrd/pup_z/lib/modules ]; then
echo "Found so Removing modules."
rm -r $path$drive/$dir1/lib/modules
echo "Removing firmware."
rm -r $path$drive/$dir1/lib/firmware
echo "done."
elif [ -d /aufs/kernel-modules/lib/modules ];then
echo "Found so Removing modules."
rm -r $path$drive/$dir1/lib/modules
echo "Removing firmware."
rm -r $path$drive/$dir1/lib/firmware
echo "done."
else
echo "No Huge detected, modules and firmware left in sfs."
fi
}
case $comp in
pp) modules
mksquashfs $path$drive/$dir1 $path$drive/$name -comp xz -noappend
mv $path$drive/$name $path$drive/$dir2/;;
fd) modules
mksquashfs $path$drive/$dir1 $path$drive/$name -comp xz -noappend
mkdir $path$drive/$dir2/fdi; cd $path$drive/$dir2/fdi
cpio -i < $path$boot/initrd
mv -f $path$drive/$name $path$drive/$dir2/fdi
cd $path$drive/$dir2/fdi
find . | cpio -o -H newc > $path$drive/$dir2/initrd
rm -r $path$drive/$dir2/fdi
echo "done";;
dd) cp -a /dev/console $path$drive/$dir1/dev/
chmod a=rwx,o+t $path$drive/$dir1/tmp
zerosize() {
find $* | while read file; do
echo -n "."
rm -f $file
touch $file
done
}
zerosize $path$drive/$dir1/usr/share/doc -type f -size +1c
zerosize $path$drive/$dir1/usr/share/doc -type l
zerosize $path$drive/$dir1/usr/share/man -type f -size +1c
zerosize $path$drive/$dir1/usr/share/man -type l
zerosize $path$drive/$dir1/usr/share/info -type f -size +1c
zerosize $path$drive/$dir1/usr/share/info -type l
zerosize $path$drive/$dir1/usr/share/gnome/help -type f -size +1c
zerosize $path$drive/$dir1/usr/share/gnome/help -type l
zerosize $path$drive/$dir1/usr/share/gtk-doc -type f -size +1c
zerosize $path$drive/$dir1/usr/share/gtk-doc -type l
chown -R man:root $path$drive/$dir1/usr/share/man
rm -f $path$drive/$dir1/etc/resolv.conf
rm -f $path$drive/$dir1/etc/rc.d/PUPSTATE
rm -f $path$drive/$dir1/etc/.pupevent
rm -f $path$drive/$dir1/var/lib/alsa/asound.state
rm -f $path$drive/$dir1/root/.xsession-errors
rm -rf $path$drive/$dir1/root/.cache
rm -f $path$drive/$dir1/etc/blkid-cache
rm -f $path$drive/$dir1/etc/resolv.conf
rm -rf $path$drive/$dir1/etc/udev/rules.d/70-persistent*
rm -f $path$drive/$dir1/var/lib/dhcp/dhclient.eth0.leases
rm -f $path$drive/$dir1/var/lib/dhcpcd/*.lease
rm -rf $path$drive/$dir1/etc/rc.d
rm -f $path$drive/$dir1/etc/DISTRO_SPECS
rm -rf $path$drive/$dir1/lib/consolefonts
rm -rf $path$drive/$dir1/lib/keymaps
rm $path$drive/$dir1/etc/blkid.conf
mksquashfs $path$drive/$dir1 $path$drive/$name -comp xz -b 1024k -Xbcj x86 -noappend
mv $path$drive/$name $path$drive/$dir2/;;
*) modules
mksquashfs $path$drive/$dir1 $path$drive/$comp -noappend
mv $path$drive/$name $path$drive/$dir2/;;
esac
clear
echo "
If you want to make an iso file then boot files will be supplied.
copied from /boot to '$path''$drive'/'$dir2'."
echo
echo -e "
Type 'y' to create iso or 'n' to NOT create iso then press enter.
Default is 'y'. or 'm' to exit to Menu.
You have $timelimit seconds\n: \c"
answer=""
read -t $timelimit answer
if [ ! -z "$answer" ]; then
echo -e "
\n You entered '$answer'"
else
echo -e "
\n TIME OUT\n Assume yes"
answer=y
fi
case $answer in
y) echo "Copying boot files for iso."
cp -a /boot/$subd/* $path$drive/$dir2/
if [ -d /aufs ]; then
for file in vmlinuz initrd.gz initrd
do
cp -a $path$boot$file $path$drive/$dir2/
done
cd $path$drive
mkisofs -b isolinux.bin -c boot.cat -D -l -R -v -no-emul-boot -boot-load-size 4 -boot-info-table -o "$niso" $path$drive/$dir2
echo "'$niso' is on drive '$path''$drive'."
elif [ -d /live-rw-backing ]; then
for file in vmlinuz1 initrd.gz initrd.img initrd1.* wheezy-i486.sgn
do
cp -a $path$boot$file $path$drive/$dir2/live/
mv $path$drive/$dir2/$name $path$drive/$dir2/live/
done
cd $path$drive
genisoimage -b isolinux/isolinux.bin -c isolinux/boot.cat -D -l -R -v -no-emul-boot -boot-load-size 4 -boot-info-table -o "$niso" $path$drive/$dir2
echo "'$niso' is on drive '$path''$drive'."
else
for file in vmlinuz initrd.gz initrd
do
cp -a $path$boot$file $path$drive/$dir2/
done
cd $path$drive
mkisofs -b isolinux.bin -c boot.catalog -D -l -R -v -no-emul-boot -boot-load-size 4 -boot-info-table -o "$niso" $path$drive/$dir2
echo "'$niso' is on drive '$path''$drive'."
fi;;
n) cp -a /boot/$subd/* $path$drive/$dir2/
if [[ ! -d /live-rw-backing ]]; then
for file in vmlinuz vmlinuz* initrd.gz initrd.* initrd1.* wheezy-i486.sgn
do
cp -a $path$boot$file $path$drive/$dir2/
done
elif [[ -d /live-rw-backing ]]; then
for file in vmlinuz vmlinuz* initrd.gz initrd.img initrd1.* initrd.xz wheezy-i486.sgn
do
cp -a $path$boot$file $path$drive/$dir2/live/
done
mv $path$drive/$dir2/$name $path$drive/$dir2/live/
echo "'$dir2' directory left in existence.
Can be deleted for you if no longer needed."
fi;;
*) clear
echo "Sorry, unexpected input.'$dir1' and '$dir2' directories on '$drive'
left in existence. Exiting to Menu!" && $rtn2menu;;
esac
clear
echo -e "
Enter 'k' to keep or 'd' to delete /'$path/'$drive'/'$dir2'.
You have $timelimit seconds\n: \c"
choice=""
read -t $timelimit choice
if [ ! -z "$choice" ]; then
echo -e "
\n You entered '$choice'."
else
echo -e "
\n TIME OUT\n Assume keep"
choice=k
fi
case $choice in
k) echo "'$dir2' directory left in existence.";;
d) echo "Deleting '$path''$drive'/'$dir2'"
rm $path$drive/$dir2 -r
echo "DELETED!";;
*) echo "Unexpected input. Not deleting!";;
esac
clear
#if [ ! -f $path$drive/$niso ]; then
#echo "'$drive'/'$dir2' directory left in existence."
#sleep 3
#else
#echo "'$niso' has been created on '$drive' so deleting '$dir2' directory."
#sleep 3
#rm -rf $path$drive/$dir2
echo "
All done!
Press enter to return to menu."
read dummy
#fi
$rtn2menu
##THE END##