The time now is Mon 23 Apr 2018, 19:25
All times are UTC - 4 |
Page 1 of 6 [78 Posts] |
Goto page: 1, 2, 3, 4, 5, 6 Next |
Author |
Message |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Thu 21 Aug 2014, 04:47 Post subject:
New Remaster script Working!! Subject description: sfsdirect - 3 minute remaster in ram! |
|
SOLVED
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: | #!/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##
|
Last edited by stemsee on Sun 12 Oct 2014, 18:18; edited 22 times in total
|
Back to top
|
|
 |
mavrothal

Joined: 24 Aug 2009 Posts: 2964
|
Posted: Thu 21 Aug 2014, 05:17 Post subject:
|
|
/proc and /sys get 555 permissions *after* the kernel is done writing in them. 555 makes the dirs not writable hence the kernel panic (I think)
Change them to 755 and see if this solves it.
PS: you may also need the /run directory that depending on your booting process may cause panic as udev needs it to make devices.
BTW, how the directories on the remastered sfs compare to the original sfs?
_________________ == Here is how to solve your Linux problems fast ==
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Thu 21 Aug 2014, 10:30 Post subject:
|
|
How do they compare? In terms of permissions? I started listing all permissions in running system to compare with remastered directory, but rightclick->properties-> shows a graphic status of permissions I do not know how they are translated numerically! Except by experimenting on a NewDir in Downloads, which I was doing until I got distracted somehow and stopped. Is there a table showing puppy dir permissions in number format?
Also I thought that /run was not a used dir in puppy linux! DebianDog yes, fatdog 700 has a symlink /run linked to /tmp . But i wont hurt to have it there!
|
Back to top
|
|
 |
saintless

Joined: 11 Jun 2011 Posts: 3882 Location: Bulgaria
|
Posted: Thu 21 Aug 2014, 10:56 Post subject:
|
|
stemsee wrote: | Is there a table showing puppy dir permissions in number format? |
Try this one:
Code: | ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \
*2^(8-i));if(k)printf("%0o ",k);print}'
|
Or this:
Code: | stat -c '%a %n' /tmp /root |
_________________ Farewell, Nooby, you will be missed...
|
Back to top
|
|
 |
mavrothal

Joined: 24 Aug 2009 Posts: 2964
|
Posted: Thu 21 Aug 2014, 11:02 Post subject:
|
|
There plenty of articles for linux permissions like this one or this one
Running
Code: | ls -l /initrd/pup_ro2 |
in a running puppy, will show the default directories and permissions in a puppy sfs.
_________________ == Here is how to solve your Linux problems fast ==
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Thu 21 Aug 2014, 11:24 Post subject:
|
|
ok....thanks guys! Another lesson to learn and apply ...
Saintless's code lists with numerically represented permissions ie tmp=777 etc!
Perfect.
|
Back to top
|
|
 |
Flash
Official Dog Handler

Joined: 04 May 2005 Posts: 12822 Location: Arizona USA
|
Posted: Thu 21 Aug 2014, 16:24 Post subject:
|
|
Stemsee, is your problem solved? Does the remastered iso work now?
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Fri 22 Aug 2014, 03:28 Post subject:
|
|
@Flash
It didn't solve the issue! But i have to look at mksquashfs -e (exclude) option to make sure tmp mnt sys proc are excluded from the running system, and only those from /tmp/quaddirs/* are added to the sfs.
But try it ... maybe it will work on your distro!
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Fri 22 Aug 2014, 06:09 Post subject:
|
|
I have an idea what might be the error. Namely, when creating new mnt in /tmp/quaddirs/ must also create subdirs for mount points - sda1-8 sr0-3 home and ram1, just remastering now. Also experimenting with -read-queue and -write-queue to speed things up.
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Fri 22 Aug 2014, 13:20 Post subject:
|
|
Nah - that didn't make any difference either. I wonder if it has to do with uuid or guid?
So i was trying to void using an inermeiary directory that you copy into first but now I will use one in ram --- see if that works.
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 2641
|
Posted: Fri 22 Aug 2014, 13:38 Post subject:
|
|
I think you need to investigate the 'standard' perms/ownerships used by other distros in order to get a clear idea of what is needed. And, the same to find out what should not be included in a clone of a system. There should be nothing copied from kernel-gernerated content, that is, /proc /sys and /run should never be copied over. And, /mnt should also not be copied if it contains non-system mounts.
Trying to clone a puppy system is quite difficult to figure out because best-practices are completely ignored or contravened.
Normally, you should be able to just cd into / and:
Code: | cp -a list-of-dirs destination |
where list-of-dirs excludes the above mentioned dirs. This is the list I always use -I often clone a running system:
bin lib opt root var etc home sbin srv usr
These:
dev media mnt tmp boot proc run sys
should be handled with care. dev should only be copied if static device files are being used. boot is often mounted on another filesysetm so your clone may or may not need that content. mnt and media should be empty dirs or empty dir structures. proc sys tmp and run should be empty dirs on the cloned system
Normal best-practices usage of the filesystem hierarchy *would* make this possible also under puppy.
I have written two tools which convert perms from octal to human and human to octal which I can provide here if needed in the end. But, the problems booting are owning to improper perms and content, I'm afraid.
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Fri 22 Aug 2014, 14:07 Post subject:
|
|
Thanks amigo
That makes sense! I believe I have figured out the right way to do it! Avoiding the pitfalls you mention. As i am sure it is kernel-generated content. So I will use the mksquashfs command specifying several more folders for source, namely /initrd/pup_ro2 /initrd/pup_rw /initrd/pup_* (any mounted sfs greater than zero) It must work I think!! And no intermediary directory just more careful excludes
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 2641
|
Posted: Sat 23 Aug 2014, 03:17 Post subject:
|
|
The contents of /initrd should also not be copied as they are setup during boot.
|
Back to top
|
|
 |
stemsee
Joined: 27 Jun 2013 Posts: 2139 Location: In The Way
|
Posted: Fri 19 Sep 2014, 17:54 Post subject:
sfs direct remaster in ram or on device. Subject description: the fastest possible remaster. |
|
This script is now working as it should!
Code: | #!/bin/bash
#sfsdirect remastering suite by stemsee copyright Marcos Contant 2014
if [ -f /etc/DISTRO_SPECS ]; then
. /etc/DISTRO_SPECS
fi
if [ -d /aufs ]; then
name=$DISTRO_FILE_PREFIX.sfs
elif [ -d /live-rw-backing ]; then
name='01-filesystem.squashfs'
else
name=$DISTRO_PUPPYSFS
fi
echo "SfS direct is a live remaster system which works in either ram or device.
Make sure that your system has enough ram or uses a swap for the remaster, or
specify path and drive. e.g. mnt sda2.
Do you want to work in ram? y or n"
read ram
case $ram in
y) mkdir -p /tmp/quaddirs/{mnt,tmp,sys,proc}
if [ -d /live-rw-backing ]; then
mksquashfs /* /tmp/quaddirs/* /tmp/$name -e /media/* /root/.xsession-errors /live-rw-backing/* /live/* /proc /tmp /mnt /initrd /sys /aufs /archive /etc/rc.d/PUPSTATE /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.pup_event /root/.history /root/.bash_history /root/.Skype /cdrom /root/.XLOADED /etc/.XLOADED /lib/modules /lib/firmware /var/cache/apt /var/cache/slapt /var/lib/apt/lists /var/lib/slapt/lists -comp xz -keep-as-directory -noappend
elif [ -d /aufs ]; then
mksquashfs /* /tmp/quaddirs/* /tmp/$name -e /proc /tmp /mnt /initrd /proc /sys /aufs /archive /etc/rc.d/PUPSTATE /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.pup_event /root/.xsession-errors /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /lib/modules /lib/firmware /var/cache/apt /var/cache/slapt /var/lib/apt/lists /var/lib/slapt/lists -comp xz -keep-as-directory -noappend
elif [ -d /initrd/pup_z/lib/modules ]; then
mksquashfs /* /tmp/quaddirs/* /tmp/$name -e /proc /media/* /tmp /mnt /initrd /proc /sys /aufs /archive /etc/rc.d/PUPSTATE /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /lib/live/mount /root/.pup_event /root/.xsession-errors /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /lib/modules /lib/firmware /var/cache/apt /var/cache/slapt /var/lib/apt/lists -comp xz -keep-as-directory -noappend
else
mksquashfs /* /tmp/quaddirs/* /tmp/$name -e /proc /tmp /mnt /initrd /proc /sys /aufs /archive /etc/rc.d/PUPSTATE /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.pup_event /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED -comp xz -keep-as-directory -noappend
fi
echo "'$name has been created in /tmp. Where do you want to save it to?
Enter the path e.g. /mnt/sda2/"
read savepart
mv -f /tmp/$name $savepart
echo "All done!"
exit;;
n) echo "Input path and drive e.g. 'mnt sda2' or 'mnt home'"
read path drive
mount /dev/$drive /$path/$drive
mkdir -p /$path/$drive/quaddirs/{mnt,tmp,sys,proc}
if [ -d /initrd/pup_z/lib/modules ]; then
mksquashfs /* /$path/$drive/quaddirs/* /$path/$drive/$name -e /proc /tmp /mnt /initrd /proc /sys /aufs /archive /etc/rc.d/PUPSTATE /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.pup_event /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /lib/modules /lib/firmware -comp xz -keep-as-directory -noappend
elif [ -d /live-rw-backing ]; then
mksquashfs /* /$path/$drive/quaddirs/* /$path/$drive/$name -e /media/* /root/.xsession-errors /live-rw-backing/* /live/* /proc /tmp /mnt /initrd /sys /aufs /archive /etc/rc.d/PUPSTATE /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.pup_event /root/.history /root/.bash_history /root/.Skype /cdrom /root/.XLOADED /etc/.XLOADED /lib/modules /lib/firmware /var/cache/apt /var/cache/slapt /var/lib/apt/lists /var/lib/slapt/lists -comp xz -keep-as-directory -noappend
else
mksquashfs /* /$path/$drive/quaddirs/* /$path/$drive/$name -e /proc /tmp /mnt /initrd /proc /sys /aufs /archive /etc/rc.d/PUPSTATE /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.pup_event /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED -comp xz -keep-as-directory -noappend
echo "All done!"
fi
exit;;
*) echo "You didn't enter anything relevant!"
exec -e sfsdirect-remaster
exit;;
esac
|
Last edited by stemsee on Wed 24 Sep 2014, 16:18; edited 3 times in total
|
Back to top
|
|
 |
Jasper
Joined: 25 Apr 2010 Posts: 1350 Location: England
|
Posted: Fri 19 Sep 2014, 19:00 Post subject:
|
|
Hi stemsee,
Your code works perfectly for me (as does that of Ted Dog).
I can automatically remaster my main sfs in less than 5 minutes.
I can make an updated iso in about 1 second.
I can burn an updated DVD in less than 1 minute (or a CD in <200")
My regards
PS I don't see much sense in remastering a full installation so I presume your hitch related to a frugal installation.
PPS I'm finishing my weekly bottle of red wine (chiante - though more tired than plastered) and I cluelessly and carelessly read your "now" as "not", but I have left my comments in case they may be of some minor general interest.
_________________ Desktop (1998 with 2002 Motherboard replacement) @ 2.0 GHz with 640 MB (SDRAM) - no swap facility needed.
Precise 5.6 with Multi-session-CD + Quirky unicorn on USB2-stick + W98SE on HD for rare printing needs.
|
Back to top
|
|
 |
|
Page 1 of 6 [78 Posts] |
Goto page: 1, 2, 3, 4, 5, 6 Next |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|