New Remaster script Working!!

Under development: PCMCIA, wireless, etc.
Message
Author
stemsee

#46 Post by stemsee »

"unload sfs files" ... that is part of 'the preparation process'. Before beginning remaster load/unload sfs files as required. Also delete internet connection profiles and passwords for screen-lock, websites, etc for a 'pristine' remaster, or leave them for a personalised remaster! BK's built-in remaster is 'best' for producing a pristine remaster, and attendance required. ..." it failed to deal correctly with StartMount from 01micko.." because 01micko's StartMount was not written with SFS-Remastering-Suite's requirements in mind! You could request 01micko to modify his script accordingly!

The other utilities are not needed but provide an all-in-one convenient app that over-reaches my original intention, and probably doesn't achieve the same level of results as the standalone utilities.

However, I can also supply a purely OVPrecise minimal remaster script if appropriately requested!

However, my scripts are just the way I hoped they would be! So I am not too bothered about falling short of an audience's diametrically opposed expectations. Suffice to say, you get what you pay for, satisfaction is neither guaranteed nor required.

stemsee

#47 Post by stemsee »

StemseeS-Remastering-Suite_1.7.pet
see first post
Last edited by stemsee on Sun 12 Oct 2014, 22:21, edited 1 time in total.

tlchost
Posts: 2057
Joined: Sun 05 Aug 2007, 23:26
Location: Baltimore, Maryland USA
Contact:

#48 Post by tlchost »

stemsee wrote: Suffice to say, you get what you pay for, satisfaction is neither guaranteed nor required.
You might want to add the lIne "Welcome to Lowered Expectations",
or, "I really don't care if it works for you or not"

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#49 Post by Puppus Dogfellow »

Jasper wrote: Guys - my first car, a 1937 Morris 8, cost £5, so I may well be well out of touch, but I'd be mildly surprised if £10 wouldn't cover a replacement DVD drive.
been thinking a lot about three wheeled cars since misreading this this morning, having taken "Morris 8" as "Morgan 8." not to derail or get off topic, but what sort of shape was it in when you got it, Jasper?

mirroring this, stemsee--looks interesting.

stemsee

#50 Post by stemsee »

@tlchost

You exaggerate my disposition! Or even misrepresent it. Better to say I wrote the program according to my knowledge, I don't KNOW about 01micko's startmount and I have never used a puppy multi-session cd/dvd, nor do I plan to, except to test a script.

I think that being considerate and patient is important. But self awareness first! "Happy are those aware of their own .... needs."

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#51 Post by jamesbond »

This figure, which I gave in this post is wrong. It is too big by a factor of two.
jamesbond wrote:
stemsee wrote:No problem. But I got the scripts working for fatdog 700, studio1337, EmSeeV2.2 and DebianDog. For fatdog 700 when i remastered and got the sfs to 800mb and packed into the initrd, it wouldn't boot. So I wondered what is the limit of the initrd size and why?
The normal limit of initrd is about 30% to 50% of the RAM size by default, and increased to 80% if you use "rootfstype=ramfs" on the bootloader. I haven't tested an SFS of that size for a long time, but I remember I could get it to boot with 2GB of RAM in a qemu. I may be wrong, though, it was a long time ago.
The correct figure is (for recent kernels):
- without rootfstype=ramfs - max initrd size is 20-25% of RAM.
- with rootfstype=ramfs - max initrd size is 45-50% of RAM.
And this is true for *ALL* LiveCD Linuxes, not only Fatdog or Puppies.

Note: this is only for the size of initrd, not the size of the basesfs. If you put your basesfs outside initrd, then you can use basesfs a whole lot bigger than your RAM size, but of course it won't be loaded in RAM.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

stemsee

#52 Post by stemsee »

From Jamesbond
stemsee wrote:
It doesn't add up. I have 8GB ram and the initrd is only 860MB.

Yes, it doesn't sound right. You should be able to boot even without rootfstype. Try logging with "loglevel=7" and tell me what you see. I also have 8GB RAM, perhaps I should try that myself.

EDIT: I tested it. I didn't remaster, I just "enlarge" the size of fd64.sfs to ~950MB by adding zeros to it ("head -c 700M /dev/zero >> fd64.sfs") and repack initrd. And I can get it to boot. Please try that one first, if you can boot then the issue is elsewhere, it's not about the size anymore.
:
Also if i take the fd64.sfs out to the boot folder

"basesfs=local" or "basesfs=device:sda5" etc (obviously replace sda5 with your correct disk). See boot options for more details.

and modules too
Don't do this. Fatdog won't boot if kernel-modules.sfs is missing. If you really want to take it out, use the fatdog-split-initrd or at least read that script first.
Thanks for that, I will test it.

stemsee

#53 Post by stemsee »

@Jamesbond

I unpacked my remastered fd64.sfs @620mb from the initrd and placed in the frugal folder on sda1 (/mnt/sda1/live/fd64.sfs) and added basesfs=local to kernl arguments .... it didn't find it. I realise that it needed to be in the root partition, meaning search depth is only one deep. It loaded into ram and worked normally. So I again repacked it in the initrd and rebooted, but again error 28 the item is too big to load ... or some such wording!

The init script or the kernel configuration file might hold the answer!

The good thing about this though is that the original fd64.sfs can stay in the initrd while the remastered fd64.sfs need only be created on the root of a partition and with a simple addition to the command line in menu.lst have a dua boot frugal install. Or even a renamed alien distro such as EmSeeV2.2 or DD!! ha ha ...

stemsee

#54 Post by stemsee »

latest version is 1.8 completely rearranged the order of unattended remaster's flow as I implement functions.

Added LightHouse64 Mariner to the list of supported distros!

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#55 Post by jamesbond »

stemsee wrote:I unpacked my remastered fd64.sfs @620mb from the initrd and placed in the frugal folder on sda1 (/mnt/sda1/live/fd64.sfs) and added basesfs=local to kernl arguments .... it didn't find it. I realise that it needed to be in the root partition, meaning search depth is only one deep.
Yes. You can be more specific: "basesfs=local:/live/fd64.sfs" or even "basesfs=device:sda1:/live/fd64.sfs" (or you can tell it to search deeper levels - but I don't recommend it, it is slow).
The good thing about this though is that the original fd64.sfs can stay in the initrd while the remastered fd64.sfs need only be created on the root of a partition and with a simple addition to the command line in menu.lst have a dua boot frugal install. Or even a renamed alien distro such as EmSeeV2.2 or DD!! ha ha ...
That's the whole idea :)
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

stemsee

#56 Post by stemsee »

Up to StemseeS-Remastering-Suite_1.9 corrected mksquashfs command, typos, display messages.

I am thinking about adding xorriso-1.3.8 to the package so that it will work the same with every distro.

stemsee

#57 Post by stemsee »

see first or last post

stemsee

#58 Post by stemsee »

sfs-unattended-remaster
Suitable for all pups including EmSeeV1/2/3,Lighthouse, Fatdog, DebianDog (OpenBox version and puppy intrd boot method). Of course using only the script without the prepared /boot directory with the iso boot files for each distro then there is limited functionality, you can simply mkdir -p /boot/{fd,dd,pp} and copy in the boot files from the relevant iso. If remastering a full install you must copy the relevant initrd* to /boot/pp/ or dd. For DebianDog copy any extra modules into /boot/dd/live/modules/* then it may work for all boot methods (needs testing).

sfs-direct-remaster will reappear soon after a re-write implementing new ideas to eliminate the 'cannot stat' messages and other optimizations using variables and 'for - do'.

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##

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#59 Post by slavvo67 »

First of all, I'm a big fan and thanks!

Second, the .iso thing really bothers me. Can you remaster and create an iso without having to move files in or have a cd in the drive? For example, I boot from USB but wouldn't mind making the remaster into an .iso for later use, as well.

If you addressed #2, please disregard. It would be a nice touch.

Best,

Slavvo67

stemsee

#60 Post by stemsee »

slavvo67 wrote:Can you remaster and create an iso without having to move files in or have a cd in the drive? For example, I boot from USB but wouldn't mind making the remaster into an .iso for later use, as well.
Slavvo67
If you use 'only' this script then you cannot make an iso without additional steps, as indicated above. If you download the StemseeS-Remastering-Suite.sfs or .pet or .deb then yes you can. Because it installs /boot/{fd,dd,pp} which contain all the extra boot files for cd/dvd and finds your original vmlinuz and initrd files aswell, if you want to upgrade your initrd and/or vmlinuz (kernel and modules) just place them in /boot/pp (for most pups and lighthouse; /boot/fd for fatdog, /boot/dd for debiandog).

I have also tidied up sfs-direct-remaster script to not get any 'stat' errors! But I need to test it with several distros before I upload the new version of StemseeS-Remastering-Suite-V2.0.sfs/pet/deb :D

Gobbi
Posts: 255
Joined: Fri 09 Mar 2012, 14:01

#61 Post by Gobbi »

slavvo67 wrote: Can you remaster and create an iso without having to move files in or have a cd in the drive? For example, I boot from USB but wouldn't mind making the remaster into an .iso for later use, as well.
The ISO file is needed for the vmlinuz , etc ... and the other files that makes the remaster to boot from an optical drive .
No matter where I boot from - USB , HDD partition or CD/DVD , I have the exact ISO file corresponding to running puppy - mounted from outside the File System ( or at most in the /tmp ) folder , and I indicate it as the source of those files required - that's all it takes .
This way I don't have to burn ISO's , or use phisical optical media.

stemsee

#62 Post by stemsee »

4U Gobbi

Sometimes things sound like nonsense to me, and other times they don't! My advice to you is write your own script or use one that has already been written by someone who understands your special needs. Do what you think is best! I'm certain that your own efforts will exceed mine. I'm sure you will have the entire support of the entire forum. As for me, I am just a visitor ready to move on. You'll be glad to know.
Remember

"Many is called; but few is chosen! Init?"

User avatar
Smithy
Posts: 1151
Joined: Mon 12 Dec 2011, 11:17

#63 Post by Smithy »

Hi Stemsee, had a go with your script, just a few remarks.

It moves very fast, like mission impossible "you have 10 seconds and your sfs will be overwritten!" Maybe no need for that until one has made their mind up?

The number choices are not entirely clear to a noobish, maybe another sentence saying what the number will do (direct to sfs for example)?

It certainly whizzed off doing stuff pretty quickly, but unfortunately I didn't have enough ram for it to do the remaster job.
Not your fault or the fault of the remaster script I might add.

Maybe most people are 16gb ram these days, but it has to be noted that an attempted quick ram remaster of a puppy sfs of over 250mb is going to fail on 2gb ram, because puppy is really 700mb+.

Nice remaster script!
Last edited by Smithy on Wed 15 Oct 2014, 14:55, edited 1 time in total.

Gobbi
Posts: 255
Joined: Fri 09 Mar 2012, 14:01

#64 Post by Gobbi »

Hi stemsee !

I didn't want to trouble you in any way ...
In my last post on your thread I meant etc as etcetera and not as etc folder from the File System. I was simply using the normal puppy remaster but without having a physical optical disk .
I do appreciate your efforts in this direction as I'm interested in merging a savefile into an ISO or at least the main SFS file . From what I read until now , because of how puppy layer system is built , it was difficult to hope in such thing .
I did try your tool with Lighthouse64 602B with a savefile , but with no luck .
In Lighthouse 602B the only way I could keep the benefit of the installed AMD driver was through a savefile. With this exception , I don't use savefile , I use the remaster as tool to make the taylored puppies I need .

About the last lines of your previous post :
I don't want to bother you , or anybody else . I'm a curious tester , I notice things and sometimes my questions or statements can be wrong . i learn something , also from the errors I do .
You have more knowledge than I have , and also the ability to create new things . You already did more for this community than I did .

stemsee

#65 Post by stemsee »

temseeS-Remastering-Suite works from the command line in X or nox. You
can exit the desktop to the > prompt and gain additional processor speed/memory
for the remaster and/or utilities. Alternatively run it from a terminal.
These scripts require additional files to function properly, which are
in the .pet and .sfs and .deb packages on my google drive.

StemseeS-Remastering-Suite.sfs
sfs-direct-remaster
sfs-unattended-remaster

https://drive.google.com/file/d/0B4GhZV ... sp=sharing

StemseeS-Remastering-Suite.pet
sfs-direct-remaster
sfs-unattended-remaster

https://drive.google.com/file/d/0B4GhZV ... sp=sharing

sfs-unattended-remaster: I have added routines to the utilities to allow
live rsync with running system to update a remaster directory. Also added
option to mksquashfs the remaster directory on some other partition,
in case of low space situations. CD/DVD burning utilities may or may not
be working - I haven't tested them (...I know).

Code: Select all

#!/bin/bash
#SFS-Unattended-Remaster script by StemSee copyright (C) 2014 Marcos Contant

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

pathdef () {
if [ -d /live-rw-backing ]; then
path=/media/
else
path=/mnt/
fi
}
pathdef
rtn2menu="sfs-unattended-remaster && exit"
start () {
echo "Enter the drive and directory you wish to sync with running system.
For example 'sda2 apupsys' which are defaults in SFS-Unattended-Remaster
script."
read drive dir
mount /dev/$drive /$path/$drive
if [ -d "$dir" ]; then
xmessage -e "Press ok to rsync running system with /mnt/'$drive'/'$dir'."
geany /etc/DISTRO_SPECS /
touch /tmp/excluded.txt
cp ~/my-applications/.exclude /tmp/exclude
excludefiles
rsync -a -e --delete /* /$path/$drive/$dir -F --exclude-from=/tmp/excluded.txt
sync
else
echo "."
xmessage "'$dir' on '$drive' wasn't found. Please check spelling and path. Then try againPress 'ok' to try again."
start
fi

}

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 [ "$drive"="home" ]; then
	echo "home is already mounted."
	elif [ ! -d $path$drive ]; then
	mkdir $path$drive
	mount /dev/$drive $path$drive
	else
	mount /dev/$drive $path$drive
	fi
echo
}
pathdef1 () {
	echo "Please enter the path for the new file to be created at, in case present
	partition doesn't have enough space. eg sda6/EmSeeV2.3/"
	read pth1
	if [ -d $path$pth1 ]; then
	echo "ok"
	else
	echo "retry"
	$retn2menu && exit
	fi
}
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 && exit
  ;;
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 && exit
}

case $sf in
	10) sfs-direct-remaster
	$rtn2menu && exit;;
	
	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
		elif [[ -d $path$drive/$dir1/media &&  -d $path$drive/$dir1/mnt ]]; then					#lighthouse
			. $path$drive/$dir1/etc/DISTRO_SPECS
			name=${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}.sfs
		fi
		echo "Do you want to sync/update with running system?
		y or n ?"
		read option
		case $option in
		y) start;;
		n) echo "Not updating.";;
		*) ;;
		esac
		pathdef1
		mksquashfs $path$drive/$dir1 $path$pth1$name -comp xz -noappend
		if [[ "$drive"=`echo "$pth1" | cut -f1 -d '/'` ]]; then
		rm -f $path$drive/$dir2/$name
		mv -f $path$drive/$name $path$drive/$dir2/
		else
		echo "squashed using xz compression and is in '$path''$pth1'" 
		sleep 2
		fi
		$rtn2menu && exit;;
	
	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
		elif [[ -d $path$drive/$dir1/media &&  -d $path$drive/$dir1/mnt ]]; then					#lighthouse
			. $path$drive/$dir1/etc/DISTRO_SPECS
			name=${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}.sfs
		fi
		echo "Do you want to sync/update with running system?
		y or n ?"
		read option
		case $option in
		y) start;;
		n) echo "Not updating.";;
		*) ;;
		esac
		pathdef1
		mksquashfs $path$drive/$dir1 $path$pth1$name -noappend
		if [[ "$drive"=`echo "$pth1" | cut -f1 -d '/'` ]]; then
		rm -f $path$drive/$dir2/$name
		mv -f $path$drive/$name $path$drive/$dir2/
		else
		echo "squashed using gz compression and is in '$path''$pth1'" 
		sleep 2
		fi
		$rtn2menu && exit;;
			
	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
		elif [[ -d $path$drive/$dir1/media &&  -d $path$drive/$dir1/mnt ]]; then					#lighthouse
			. $path$drive/$dir1/etc/DISTRO_SPECS
			name=${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}.sfs
		fi
		echo "Do you want to sync/update with running system?
		y or n ?"
		read option
		case $option in
		y) start;;
		n) echo "Not updating.";;
		*) ;;
		esac
		pathdef1
		mksquashfs $path$drive/$dir1 $path$pth1$name -comp xz -b 1024k -Xbcj x86 -noappend
		if [[ "$drive"=`echo "$pth1" | cut -f1 -d '/'` ]]; then
		rm -f $path$drive/$dir2/$name
		mv -f $path$drive/$name $path$drive/$dir2/
		else
		echo "squashed using max xz compression and is in '$path''$pth1'" 
		sleep 2
		fi
		$rtn2menu && exit;;
		
	
	4) workdrive
	pathdef1
		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
		elif [[ -d $path$drive/$dir1/media &&  -d $path$drive/$dir1/mnt ]]; then					#lighthouse
			. $path$drive/$dir1/etc/DISTRO_SPECS
			name=${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}.sfs
			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 "$pth1$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 "$pth1$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 "$pth1$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$pth1$niso
			echo "Finished!"
			else
			echo "No Go!"
			fi
			$rtn2menu && exit;;
		 
			b) echo "Enter the usb device; eg sdb1"
			read usb
			umount /dev/$usb
			isohybrid $niso
			dd if=$path$pth1$niso of=/dev/$usb bs=4M
			echo "Finished!"
			sleep 2
			$rtn2menu && exit;;
			
			c)$rtn2menu && exit;;
		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 && exit;;
	
	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 && exit;;
	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 && exit;;
	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 && exit;;

	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-3save.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 && exit;;
			
		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 && exit;;
			
		c) $rtn2menu && exit;;
		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'		Return to main Menu

	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 && exit;;
			
				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 && exit;;
			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 && exit;;
	
			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 && exit;;
			
			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 && exit;;
			
			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 && exit;;
			
			6) echo "Exiting to Menu."
			$rtn2menu && exit;;
		esac
		;;
	
	8) if [ $sf==8 ]; then
	clear
	echo "ok"
	fi;;
	
	9) if [ $sf==9 ]; then
	exit
	else
	rtn2menu
	fi && exit;;
	
	11) intro
	$rtn2menu && exit;;
	
	*) $rtn2menu && exit;;
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,proc,mnt,sys,tmp,initrd,archive,audit,/var/cache/apt/*,/var/slapt-get/*,/var/lib/apt/lists/*,/var/lib/slapt/lists/*}
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."
	else
		echo "'$subdir' directory not needed for this distro."
	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 /var/log
rm -rf tmp/*
rm -rf audit/*
rm -rf lost+found/*
rm -rf /root/.config/geany/geany.conf
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
		cp -a ~/my-applications/bin/start $path$drive/$dir1/root/Startup/
		comp=fd
		elif [[ "$path" = /media/ ]]; then
		comp=dd
		elif [[ "$path" = /mnt/ ]]; then
		cp -a ~/my-applications/bin/start $path$drive/$dir1/root/Startup/
		comp=pp
		else 
		cp -a ~/my-applications/bin/start $path$drive/$dir1/root/Startup/
		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 vmlin* initr*
		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 vmlin* initr* 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 vmlin* initr*
		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 vmlin* initr* wheezy-i486.sgn
		do
		cp -a $path$boot$file $path$drive/$dir2/
		done
	elif [[ -d /live-rw-backing ]]; then
		for file in vmlin* initr* 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##

Post Reply