Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 28 Nov 2014, 16:32
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
StemseeS-Remastering-Suite-V4.9 .sfs & .pet 25/11/14
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [24 Posts]   Goto page: 1, 2 Next
Author Message
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Tue 04 Nov 2014, 08:16    Post subject:  StemseeS-Remastering-Suite-V4.9 .sfs & .pet 25/11/14
Subject description: remaster from the prompt or commandline - X graphical server need not be running!
 

StemseeS-Remastering-Suite consists of two main scripts: sfs-direct-remaster and sfs-unattended-remaster. There are two main scripts and several config files and boot files included in the pet/sfs/deb packages @1.14mb

SFS-direct-remaster is unique in that it creates an sfs directly from the running system without an intermediary folder, such as puppylivecdbuild, to work on the directories and their folders. Usually the system is copied into an intermediary work directory which has the system tree directory, then files and folders are 'cleaned' deleted and/or copied 'pristine' from an iso or cd. RemasterX by shinobar and remasterPuppy live-cd by BK work this way. This means that you have to locate an iso or cd/dvd of the system you want to remaster as well as be running that system. sfs-direct-remaster and sfs-unattended-remaster DO NOT require an iso or cd/dvd to copy files from. SFS-Direct-Remaster also does not require a working_directory to clean the new system. Cleaning is performed on the fly by a mechanism that uses an exclude list of files and dirs which can be found in ~/my-applications/.exclude. This file is copied to /tmp and is compared to the running system and such files and directories that are found on the list and in the running system are added to another file in /tmp called 'excluded.txt'. Which is then read by the mksquashfs command.

SFS-Direct-Remaster begins with a display of available ram memory and an estimation of needed working space. The user then decides whether to remaster in ram 'r' or on drive 'd'. If ram is selected, along with compression type 'gz' 'xz' or 'xzm' maximum compression, then mksquashfs immediately begins to build a named (taken from DISTRO_SPECS) .sfs file in /tmp/. A normal sized pup of about 180mb will take about 3 minutes to remaster. If the option to work on a device (partition) is chosen 'd' then a display of available partitions and their available space and usage is displayed. type in 'sda3' or 'Home' or 'home' which are linked to dev_ro2 and dev_save, for example. The script then asks for confirmation, 'y' continue or 'n' select again. The script will add code to rc.local after backing it up to ~/my-applications/.rc.local. This will auto mount partitions and link Home and home to dev_ro2 and dev_save respectively. The script will then build the module on the specified partitoin. When the sfs has been built the option to save to some directory is given. If the directory that has been specified has an existing .sfs module with the same name then that module will be backed up by renaming it with the added suffix '-old'. Upto three modules can exist '-old-old' before the oldest one gets deleted, so no need to worry about a failed remaster (which hasn't happened yet). When copying has completed the script calls sfs-unattended-remaster which opens at its Menu - the hub of the utilities.

SFS-Unattended-Remaster provides a remastering session in which at least one question must be answered, but not more than three questions need be answered, to remaster from scratch all the way to bootable iso creation without any input from the user. This scenario is possible under the assumption that 'sda2' will be used for the remaster! In fact every step of the remaster provides an opportunity to specify other paths and directories aswell as other choices including alternaitve names and compressions, but as it is designed to be 'unattended' it assumes a night time scenario (at least in my case with an 8gb folder to squash!) in which the computer is truly unattended. SFS-unattended-remaster also has the ability to remaster without an iso or cd and also the target system need not be the same one running, it will build the system sfs reading DISTRO_SPECS from 'apupsys'; (options 1, 2, 3 and 4 on the Menu).
CD boot files are included in the pet and sfs packages for Fatdog64, DebianDog xfce and puppy boot method and pups with huge kernels and pups with builtin kernels (tested with fatdog700, LightHouse64, slacko-5.7+, Dpup Wheezy, DebianDog puppy boot, Studio1337, LASSIE, and the latest Tahr pups). SFS-Unattended-Remaster does use an intermediary folder for cleaning up, this allows an option later for other updates and post remaster utilities. Also using this remaster gives more freedom to use your computer normally while the remaster is in progress .... whereas doing so with sfs-direct-remaster could affect progress, but not the outcome! The intermediary folder is 'apupsys' a puppy system (dir). The iso folder to which the main sfs gets auto copied (without backing up any previous .sfs) is called 'bpupiso'. folders a and b, puppy, sys (-tem) and iso ... you see my logic. I meant to change the latter's name to apupiso so that the two folders would be near each other in a rox window. Anyway. After the unattended remaster the script returns to its main 'Menu'. At the moment there are 12 entries to choose from. Including '10' sfs-direct-remaster. and '7' Make a savefile or swapfile. '11' for disclaimer and briefest intro. '5' burn iso to cd. '6' write to usb (not reliable for me). '8' sfs-unattended-remaster. '9' exit script. As I think of them Embarassed

Anyway that is just a brief intro feel free to ask any questions regarding their operation and etc. Please do try them and I will be greatful for feedback and suggestions!

stemsee
capture21882.jpg
 Description   
 Filesize   33.51 KB
 Viewed   95 Time(s)

capture21882.jpg

capture9197.jpg
 Description   
 Filesize   26.54 KB
 Viewed   96 Time(s)

capture9197.jpg

capture7843.jpg
 Description   
 Filesize   27.23 KB
 Viewed   95 Time(s)

capture7843.jpg


Last edited by stemsee on Tue 25 Nov 2014, 07:39; edited 23 times in total
Back to top
View user's profile Send private message MSN Messenger 
CatDude


Joined: 03 Jan 2007
Posts: 1497
Location: UK

PostPosted: Wed 05 Nov 2014, 15:25    Post subject: Re: StemseeS-Remastering-Suite-V3.sfs .pet
Subject description: remaster from the prompt or commandline - X graphical server need not be running!
 

stemsee wrote:
StemseeS-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.
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/0B4GhZVmB2RkwSThiOWRsTE83NTA/view?usp=sharing

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

https://drive.google.com/file/d/0B4GhZVmB2Rkwb1ZMU2V5Ym5Qenc/view?usp=sharing

sfs-direct-remaster: I have fixed a lot of bugs and added some features; notably memory and mounts/disk space/usage ; which provide easier usage, but slow the script down a little. To compensate for this I will add a fast-track option so that users who are familiar with the script and their hardware can jump straight to the
remaster!

_________________

Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Mon 10 Nov 2014, 12:22    Post subject: UPDATED 15/11/14 remastering suite .... kernel 3.17.2-pae
Subject description: stemsees-remastering-suite-v4.7.pet .sfs
 

For puppy linux distros I have squashed two bugs and improved the script with the addition of some code which modifies /etc/rc.d/rc.local by adding code that auto-mounts usable partitions but not dev_ro2 or dev_save which are already mounted and linked to /mnt/Home and /mnt/home respectively. Also replaces resizepf.sh which needs to umount everything before it works.

sfs-direct-remaster tested a gazillian & 1 times Wink

EDIT updated to V4.8 17/11/14

sfs
https://drive.google.com/file/d/0B4GhZVmB2RkwT3YtMjJRcF9ZeU0/view?usp=sharing

pet
https://drive.google.com/file/d/0B4GhZVmB2RkweXpVbTNRTHF1S00/view?usp=sharing

Kernel 3.17.2-pae
https://drive.google.com/file/d/0B4GhZVmB2RkwZkJWa0t2XzRDQ0k/view?usp=sharing

kernel-3.17.2-pae-modules.sfs
https://drive.google.com/file/d/0B4GhZVmB2RkwTWVEV2VibjZnaFk/view?usp=sharing

Last edited by stemsee on Mon 17 Nov 2014, 19:17; edited 16 times in total
Back to top
View user's profile Send private message MSN Messenger 
mavrothal


Joined: 24 Aug 2009
Posts: 1810

PostPosted: Mon 10 Nov 2014, 12:55    Post subject: Re: updated remastering suite .... plus kernel 3.17.2-pae
Subject description: stemsees-remastering-suite-v3.3.pet
 

You may want to add a step where the $DISTRO_IDSTRING from DISTRO_SPECS will be added to the sfs after remastering.
The puppy init is using this string to properly identify the puppy files.
Although it can manage without it, is very useful in complex setups.

_________________
Kids all over the world go around with an XO laptop. They deserve one puppy (or many) too Very Happy
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Mon 10 Nov 2014, 14:10    Post subject:  

Excellent stuff. If you detail the code, save me ploughing through BK's or Shinobar's script!

but I remember it is something like cat "$idstring" >> *.sfs ... or ?

Code:
addidstring () {
   #for file in $name vmlinuz vmlin64 vmlin32 kernel-modules.sfs zdrv_*.sfs ydrv_*.sfs adrv_*.sfs
   #do
   if [ -e /tmp/$name ]; then
   echo -n $DISTRO_IDSTRING >> /tmp/$name
   else
   echo -n $DISTRO_IDSTRING >> /$path/$drive/$name
   #done
   fi
}

need to test $DISTRO_IDSTRING isn't empty [ ! -z $DISTRO_IDSTRING ]

Code:
addidstring () {
   #for file in $name vmlinuz vmlin64 mlin32 kernel-modules.sfs zdrv_*.sfs ydrv_*.sfs adrv_*.sfs
   #do
   if [ -e /tmp/$name ]; then
      if [[ ! -z $DISTRO_IDSTRING ]]; then
      echo -n $DISTRO_IDSTRING >> /tmp/$name
      elif [[ ! -z $DISTRO_IDSTRING ]]; then
      echo -n $DISTRO_IDSTRING >> /$path/$drive/$name
      fi
   #done
   fi
}
Back to top
View user's profile Send private message MSN Messenger 
mavrothal


Joined: 24 Aug 2009
Posts: 1810

PostPosted: Tue 11 Nov 2014, 01:37    Post subject:  

stemsee wrote:

need to test $DISTRO_IDSTRING isn't empty


If is empty you do not add anything
Code:
 [ $DISTRO_IDSTRING ] && echo -n "$DISTRO_IDSTRING" >> /path/to/puppy_sfs
should do.
_________________
Kids all over the world go around with an XO laptop. They deserve one puppy (or many) too Very Happy
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Tue 11 Nov 2014, 17:40    Post subject:  

Updated. See thirdt post for links. Now at V4.8
Last edited by stemsee on Mon 17 Nov 2014, 20:07; edited 3 times in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Thu 13 Nov 2014, 14:13    Post subject:  

EDIT : sfs-unattended-remaster script Menu option 7 save/swapfile creation showed 5000 as 500 MB but was actually 5GB.

Now at V4.8
Fixed rc.local backup and code appending.
IDstring appended function.
V4 had some code missing from .apprc file.

See third post for download links

Road map.Yet to do
1) Add persistent ramdisk creation for audio video work.
2) Multi-sesssion management
3) Add chroot apupsys updating feature from parent distro.
4) Remaster any linux.
5) Manage multiple savefiles.
6) Simultaneous independent savefiles (because it's possible!) one for each seat.
7) Alternative install mechanism.
Cool On the fly savefile resize!

By the way it is possible to use sfs-direct-remaster and sfs-unattended-remaster at the same time! Remastering with different compression.

Last edited by stemsee on Mon 17 Nov 2014, 20:07; edited 5 times in total
Back to top
View user's profile Send private message MSN Messenger 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 659
Location: nyc

PostPosted: Thu 13 Nov 2014, 17:44    Post subject:  

links are messed up, stemsee. first one (sfs) is pet for 4.3, second (pet) is pet for 4.2.
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Thu 13 Nov 2014, 18:12    Post subject:  

Ok Puppus Dogfellow

Sorted now ... V4.8.pet and .sfs

Last edited by stemsee on Mon 17 Nov 2014, 20:07; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Thu 13 Nov 2014, 19:20    Post subject:  

StemseeS-Remastering-Suite consists of two main scripts: sfs-direct-remaster and sfs-unattended-remaster. There are two main scripts and several config files and boot files included in the pet/sfs/deb packages @1.14mb

SFS-direct-remaster is unique in that it creates an sfs directly from the running system without an intermediary folder to work on the directories and their folders, such as puppylivecdbuild,. Usually the system is copied into an intermediary work directory which has the system tree directory, then files and folders are 'cleaned' deleted and/or copied 'pristine' from an iso or cd. RemasterX by shinobar and remasterPuppy live-cd by BK and Moo by Iguleder and iso-remaster by RSH, all work this way. This means that you have to locate an iso or cd/dvd of the system you want to remaster as well as be running that system. sfs-direct-remaster and sfs-unattended-remaster DO NOT require an iso or cd/dvd to copy files from. SFS-Direct-Remaster also does not require a working_directory to clean the new system. Cleaning is performed on the fly by a mechanism that uses an exclude list of files and dirs which can be found in ~/my-applications/.exclude. This file is copied to /tmp and is compared to the running system and such files and directories that are found on the list and in the running system are added to another file in /tmp called 'excluded.txt'. Which is then read by the mksquashfs command.

SFS-Direct-Remaster begins with a display of available ram memory and an estimation of needed working space. The user then decides whether to remaster in ram 'r' or on drive 'd'. If ram is selected, along with compression type 'gz' 'xz' or 'xzm' maximum compression, then mksquashfs immediately begins to build a named (taken from DISTRO_SPECS) .sfs file in /tmp/. A normal sized pup of about 180mb will take about 3 minutes to remaster. If the option to work on a device (partition) is chosen 'd' then a display of available partitions and their available space and usage is presented. Type in 'sda3' or 'Home' or 'home' which are linked to dev_ro2 and dev_save, for example. The script then asks for confirmation, 'y' continue or 'n' select again. The script will add code to rc.local after backing it up to ~/my-applications/.rc.local. This will auto mount partitions and link Home and home to dev_ro2 and dev_save respectively. The script will then build the modules on the specified partitoin. When the sfs has been built the option to save to some directory is given. If the directory that has been specified has an existing .sfs module with the same name then that module will be backed up by renaming it with the added suffix '-old'. Upto three modules can exist '-old-old' before the oldest one gets deleted, so no need to worry about a failed remaster (which hasn't happened yet). When copying has completed the script calls sfs-unattended-remaster which opens at its Menu - the hub of the utilities.

SFS-Unattended-Remaster provides a remastering session in which at least one question must be answered, but not more than three questions need be answered, to remaster from scratch all the way to bootable iso creation without any input from the user. This scenario is possible under the assumption that 'sda2' will be used for the remaster! In fact every step of the remaster provides an opportunity to specify other paths and directories aswell as other choices including alternaitve names and compressions, but as it is designed to be 'unattended' it assumes a night time scenario (at least in my case with an 8gb folder to squash!) in which the computer is truly unattended. SFS-unattended-remaster also has the ability to remaster without an iso or cd and also the system need not be running (options 1, 2, 3 and 4 on the Menu).
CD boot files are included in the pet and sfs packages for Fatdog64, DebianDog xfce and puppy boot method and pups with huge kernels and pups with builtin kernels (tested with fatdog700, slacko-5.7+, Dpup Wheezy, DebianDog puppy boot, Studio1337, and the latest Tahr pup by 666philb). SFS-Unattended-Remaster does use an intermediary folder for cleaning up, this allows an option later for other updates and post remaster utilities. Also using this remaster gives more freedom to use your computer normally while the remaster is in progress .... whereas doing so with sfs-direct-remaster could affect progress, but not the outcome! The intermediary folder is 'apupsys' a puppy system (dir). The iso folder to which the main sfs gets auto copied (without backing up any previous .sfs) is called 'bpupiso'. folders a and b, puppy, sys (-tem) and iso ... you see my logic. I meant to change the latter's name to apupiso so that the two folders would be near each other in a rox window. Anyway. After the unattended remaster the script returns to its main 'Menu'. At the moment there are 12 entries to choose from. Including '10' sfs-direct-remaster. and '7' Make a savefile or swapfile. '11' for disclaimer and briefest intro. '5' burn iso to cd. '6' write to usb (not reliable for me). '8' sfs-unattended-remaster. '9' exit script. As I think of them Embarassed

Anyway that is just a brief intro feel free to ask any questions regarding their operation and etc. Please do try them and I will be greatful for feedback and suggestions!

stemsee

Last edited by stemsee on Sat 15 Nov 2014, 20:53; edited 5 times in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Fri 14 Nov 2014, 07:25    Post subject:  

Chapter 2. Preparations

For a happy and successful journey through the remaster processes there are some preparations that can greatly affect the outcome, especially if a 'pristine' remaster is desired. These are the steps I take when about to remaster:

1) Disconnect internet and delete profile using relevant client: sns, frisbee, network Wizard, PeasyWiFi. Although these config files can be added to the excluded.txt list by one of several methods for sfs-direct-remaster =. a) Append the path to ~/my-applications/.exclude file. b) edit script and add 'echo "/path/to/file or dir" >> /tmp/excluded.txt' just before mksquashfs command in the relevant distro's section. c) Append to mksquashfs command '--exclude "/path/to/file-or-dir" d) delete/move/rename "/path/to/file-or-dir in running system. For sfs-unattended-remaster additionally d) add line to rm -rf section of script. e) add to rsync --exclude argument.

The reason I left this out is that it works for some distros without a problem (DD) but on EmSee cause connection problems.

2) Run Bleachbit as root which will do a lot of cleaning. (but make sure the save file if used has plenty of free space!

3) Select and remove hd icons from the desktop so that there won't be phantoms on other hardware at first run. (not a big problem - just restart X). Because I don't know which script controls them, so I cannot reset it. (Help needed!)

4) Remove any personal files from root/my-documents/ etc.

5) Exit to prompt and call the script from the commandline 'sfs-unattended-remaster' or 'sfs-direct-remaster'. Not having X-graphical-server running will give more cpu and ram resources to the remaster processes. And prevent you from tinkering too much!!

If you choose not to take these steps then the remaster will be personalised for your system. Some of these steps should be included in the script/exclude file and I hope that everyone who uses these scripts will post any additions deemed useful to the exclude file. Here is the content of the exclude file right now.

Code:
/etc/.XLOADED
/etc/rc.d/PUPSTATE
/etc/rc.d/PUPSAVE.conf
/etc/rc.d/pupsave.conf
/etc/rc.d/WOOFMERGEVARS
/etc/rc.d/rc.local-bak
/etc/udev/rules.d/70-persistent
/etc/resolv.conf
/etc/network_wizard/wireless/wpa_profiles/
/lib/keymaps
/lib/consolefonts
/live-rw-backing/
/root/my-applications/.rc.local
/root/.config/geany/geany.conf
/root/.history
/root/Downloads/
/root/.minecraft/
/root/.steam/
/root/.wine/drive_c/users/root/Cookies/
/root/.wine/drive_c/users/root/AppData/XBMC/userdata/addon_data/
/root/.wine/drive_c/users/root/AppData/Tencent/Users/
/root/.wine/drive_c/users/root/AppData/Tencent/QQ/
/root/.wine/drive_c/windows/temp/
/root/.wine/drive_c/users/root/Temp/
/root/.Skype/
/root/.thumbnails
/root/.XLOADED
/root/spot/Downloads/
/root/.bash_history
/root/.cache/mozilla/
/root/.cache/google/
/root/.cache/moonchild productions/
/root/.cache/wine/
/root/.config/chrome
/root/.Trash
/root/.xsession-errors
/root/.pup_event
/root/.mozilla/
/var/tmp/
/var/run/
/var/log/
/var/slapt-get/
/var/lib/dhcp/dhclient.eth0.leases
/var/lib/dhcpcd/.lease
/var/cache/apt/
/cdrom
/proc/
/mnt/
/initrd/
/aufs/
/sys/
/run/
/lib/live/mount
/tmp/
/audit/
/lost+found/
/live/
/archive/
/media/


Another file whose contents are appended to a copy of rc.local is ~/my-applications/.apprc here are the contents.

Code:
if [ -d live-rw-backing ]; then
path=media
else
path=mnt
fi
mkdir -p /root/.pup_event
mkdir -p /root/Downloads
mkdir -p /var/run/dbus
mkdir -p /var/log
if [ -e /tmp/rclc ]; then
rm /tmp/rclc
fi

probepart -m  | grep --invert-match 'none' | cut -f1 -d '|' | cut -f3 -d '/' | grep --invert-match 'sr0' > /tmp/rclc
durr=`mount | grep dev_ro2 | cut -f1 -d ' ' | cut -f3 -d '/'`
dorr=`mount | grep dev_save | cut -f1 -d ' ' | cut -f3 -d '/'`
while read line
do
mkdir -p /$path/$line
mount /dev/$line /$path/$line
if [[ ! -z "$durr" ]]; then
umount /$path/$durr 2>/dev/null
rm -r /$path/$durr 2>/dev/null
fi
if [[ ! -z "$dorr" ]]; then
umount /$path/$dorr 2>/dev/null
rm -r /$path/$dorr 2>/dev/null
fi
done < /tmp/rclc

ln -fnsv /initrd/mnt/dev_ro2 /mnt/Home
ln -fnsv /initrd/mnt/dev_save /mnt/home


Next chapter will be for devs/tinklers who probably understand my script already, and know how to improve it.
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Sat 15 Nov 2014, 10:39    Post subject:  

updated to V4.8 ... this is an important bug fix. Reconfigured as functions and streamlined with more interactions.

Edit V4.8 stable. No bugs remaining!

Last edited by stemsee on Mon 17 Nov 2014, 20:08; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Sat 15 Nov 2014, 21:11    Post subject:  

Here is the sfs-direct-remaster script taken from StemseeS-Remastering-Suite-V4.7 . The script needs supporting files to work properly.

Code:
#!/bin/bash
#sfs-direct-remaster suite by stemsee copyright (c) 2014 Marcos Contant
addidstring () {
   echo -e "Do you want to append the idstring to the sfs? 'y' or 'n'? $timelimit seconds\n: \c"
   string=""
   read -t $timelimit answer
if [ ! -z "$string" ]; then
   echo -e "
   \n You entered '$string'"
else
   echo -e "
   \n TIME OUT\n Assume no"
   string=n
fi
   case $string in
                                        y) [ $DISTRO_IDSTRING ] && echo -n "$DISTRO_IDSTRING" >>/$path/$drive/$name;;
               n) echo "not added.";;
               *) addidstring;;
   esac
}
add2rclocal () {
rm  /etc/rc.d/rc.local-bak
cat ~/my-applications/.rc.local > /etc/rc.d/rc.local-bak
sleep 1
cat /etc/rc.d/rc.local-bak > /root/my-applications/.rc.local
cat  /root/my-applications/.apprc >> /etc/rc.d/rc.local-bak
rm /etc/rc.d/rc.local
cat  /etc/rc.d/rc.local-bak >  /etc/rc.d/rc.local
}
add2rclocal
namefn () {
   if [ -d /aufs ]; then
   . /etc/DISTRO_SPECS
   name=$DISTRO_FILE_PREFIX.sfs
elif [ -d /live-rw-backing ]; then
   name='01-filesystem.squashfs'
elif [[ -d /media &&  -d /mnt ]]; then
   . /etc/DISTRO_SPECS
   name=${DISTRO_FILE_PREFIX}-${DISTRO_VERSION}.sfs
else
   . /etc/DISTRO_SPECS
   name=$DISTRO_PUPPYSFS
fi
}
namefn
   svprt () {
   echo "'$name has been created in /tmp. Where do you want to save it to?
   Enter the path e.g. /mnt/sda2/'directory'/  (mount it first!)
   
       (the old '$name' gets backed-up to '$name'-old)"
   read savepart

   if [ -f $savepart$name-old ]; then
   rm -f $savepart$name-old-old
   mv -f $savepart$name-old $savepart$name-old-old
   mv -f $savepart$name $savepart$name-old
   mv -f /tmp/$name $savepart
   elif [ -e $savepart$name ]; then
   mv -f $savepart$name $savepart$name-old
   mv -f /tmp/$name $savepart
   elif [ ! -e $savepart$name ]; then
   mv -f /tmp/$name $savepart
   elif [ ! -d $savepart ]; then
   clear
   echo "Problem.  Try again!"
   sleep 2
   svprt
   fi
}

sdf () {
if [ -e /tmp/*.*fs ]; then
echo "A previous '$name' is in /tmp.  Do you want to save it or delete it?
                       Enter 's' or d'"
read sd
case $sd in
   s) svprt;;
   d) rm -f /tmp/$name;;
   *) sdf;;
esac
fi
}

cleantmp () {
rm -r /tmp/quaddirs
rm -f /tmp/excluded.txt
rm -f /tmp/exclude
rm -f ~/Startup/star
rm -f /tmp/mem
rm -f /tmp/mem1
rm -f /tmp/fdi
touch /tmp/excluded.txt
cp ~/my-applications/.exclude /tmp/exclude
cp ~/my-applications/bin/star ~/Startup
z=3
clear
}
cleantmp

sdf
introfn () {
echo "                          \ SfS-Direct-Remaster /
  Is a live remaster system which works either in ram or on a storage device.
     Make sure that your system has enough ram for the remaster. If not
         specify drive. e.g. 'sda2' after entering 'dg' or 'dx' or 'dxm'"
echo

echo "free memory is.. `free -m | sed '3 ! d' | awk '{print $4}'` MB"

cp -a ~/my-applications/bin/star ~/Startup/
du -smc --exclude=/sys --exclude=/run --exclude=/proc --exclude=/tmp --exclude=/initrd --exclude=/aufs --exclude=/mnt --exclude=/media --exclude=/live --exclude=/live-rw-backing / | sed -n '$p' |  sed 's/total//g' | sed 's/G//g' > /tmp/mem
sed -i 's/^/p=/' /tmp/mem
. /tmp/mem
echo $((p / z)) > /tmp/mem
sed -i 's/^/  /' /tmp/mem
sed -i 's/$/ MB/g' /tmp/mem
echo
echo "you need about..`cat /tmp/mem`"
echo
}
introfn
rdfn () {
echo "  Do you want to work in ram 'r' or on drive 'd'?
           Enter: rg  ...for in ram, gz compressor or 'dg' on drive
                  rx  ...for in ram, xz compressor or 'dx'
                  rxm ...in RAM MAX, xz compressor or 'dxm'   
              or  mu  ...for Menu"
read input
ram="`echo ${input:0:1}`"
gz="`echo ${input:1:3}`"
ef='-ef /tmp/excluded.txt'
case $gz in
   g) comp="-comp gzip";;
   x) comp="-comp xz";;
   xm) comp="-comp xz -b 1024k -Xbcj x86";;
esac
clear
echo "'$comp' compression selected"
echo "-------------------------"
}
rdfn
pathdef () {
if [ -d /live-rw-backing ]; then
path=media
else
path=mnt
fi
}
pathdef
excludefiles () {
   while read line; do
    if [[ -e $line ]]; then
    echo $line >> /tmp/excluded.txt
    fi
   done < /tmp/exclude
}

excludefiles
case $ram in
    r) mkdir -p /tmp/quaddirs/{mnt,tmp,sys,proc}
    if [ -e /tmp/$name ]; then
    rm /tmp/$name
    else
    echo "Proceeding with '$name' remaster in RAM with '$comp'"
    fi
   if [ -d /aufs ]; then                      #FatDog64
      echo "/lib/modules" >> /tmp/excluded.txt
      echo "/lib/firmware" >> /tmp/excluded.txt
      mksquashfs /* /tmp/quaddirs/* /tmp/$name $comp $ef -keep-as-directory -noappend -no-recovery #/proc /tmp /mnt /proc /sys /aufs /archive /etc/rc.d/PUPSTATE /etc/rc.d/PUPSAVE.conf /etc/rc.d/WOOFMERGEVARS /root/.cache/mozilla /root/.cache/google /root/.thumbnails/* /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.xsession-errors /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED  /var/tmp/* /var/run/* /var/slapt-get/* /var/lib/apt/lists/* /var/lib/slapt/lists/*
      addidstring
      mkdir /tmp/fdi; cd /tmp/fdi
      echo "Enter path to your fatdog initrd eg mnt sda1 fatdog700"
      read path drive dir
      cpio -i < /$path/$drive/$dir/initrd
      mv -f /tmp/$name /tmp/fdi
      cd /tmp/fdi
      find . | cpio -o -H newc > /tmp/initrd
      rm -r /tmp/fdi
      cp /$path/$drive/$dir/initrd /$path/$drive/$dir/initrd-old
      echo "original initrd backed-up to initrd-old"
      mv /tmp/initrd /$path/$drive/$dir/
         if [[  -e /tmp/initrd ]]; then
            name=initrd
         else
            echo "Finished."
         fi && sfs-unattended-remaster && exit
   
   elif [ -d /live-rw-backing ]; then                   #DebianDog
      if [ -f /etc/blkid.conf ]; then
      echo "/etc/blkid.conf" >> /tmp/excluded.txt
      fi
      if [ -d /initrd/lib/modules ]; then
      #echo "/lib/modules" >> /tmp/excluded.txt
      #echo "/lib/firmware" >> /tmp/excluded.txt
      echo "/etc/resolv.conf" >> /tmp/excluded.txt
      fi   
      chmod a=rwx,o+t /tmp/quaddirs/tmp
      mkdir -p /tmp/quaddirs/dev
      #cp -a /dev/console /tmp/quaddirs/dev/
      zerosize() {
      find $* | while read file; do
       echo -n "."
       rm -f $file
       touch $file
      done
      }
       zerosize /usr/share/doc -type f -size +1c
       zerosize /usr/share/doc -type l
       zerosize /usr/share/man -type f -size +1c
       zerosize /usr/share/man -type l
       zerosize /usr/share/info -type f -size +1c
       zerosize /usr/share/info -type l
       zerosize /usr/share/gnome/help -type f -size +1c
       zerosize /usr/share/gnome/help -type l
       zerosize /usr/share/gtk-doc -type f -size +1c
       zerosize /usr/share/gtk-doc -type l
       chown -R man:root usr/share/man
      mksquashfs /* /tmp/quaddirs/* /tmp/$name $comp $ef -keep-as-directory -noappend -no-recovery# /media/* /etc/udev/rules.d/70-persistent* /root/.xsession-errors /live-rw-backing/* /live/* /proc /tmp /mnt /initrd /sys /archive /etc/resolv.conf /etc/blkid.conf /etc/rc.d /etc/DISTRO_SPECS /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /lib/keymaps /lib/consolefonts /root/.pup_event /root/.history /root/.xsession-errors /root/.bash_history /root/.Skype /cdrom /root/.XLOADED /etc/.XLOADED /var/lib/dhcp/dhclient.eth0.leases /var/run/* /var/lib/dhcpcd/*.lease /var/tmp/* /var/lib/alsa/asound.state /var/cache/apt /var/lib/apt/lists/*
      echo "Finished.."
   
   elif [ -d /initrd/pup_z/lib/modules ]; then           #Huge kernels (EmSeeV2.2,Woof-next pups)
      echo "Modules in or out?"
      read mods
      case $mods in
      out) echo "/lib/modules" >> /tmp/excluded.txt
      echo "/lib/firmware" >> /tmp/excluded.txt
      mksquashfs /* /tmp/quaddirs/* /tmp/$name $comp $ef -keep-as-directory -noappend
      addidstring;;
      in) mksquashfs /* /tmp/quaddirs/* /tmp/$name $comp $ef -keep-as-directory -noappend -no-recovery # /proc /dev/* /mnt/* /initrd/* /tmp /proc /sys /archive/* /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /etc/rc.d/PUPSTATE /etc/rc.d/PUPSAVE.conf /etc/rc.d/WOOFMERGEVARS /root/Downloads/* /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /var/tmp/* /var/run/* /var/slapt-get/* /var/lib/apt/lists/*
      addidstring
      echo "Finished...";;
      *) sfs-direct-remaster && exit;;
      esac
   
   else                                         #pups with builtin modules.
      mksquashfs /* /tmp/quaddirs/* /tmp/$name $comp $ef -keep-as-directory -noappend -no-recovery
      addidstring
      echo "Finished...."
   fi
   rm -f /tmp/excluded.txt
   rm -f /tmp/exclude
    rm -r /tmp/quaddirs
   rm -f ~/Startup/star
   rm -f /tmp/mem
   rm -f /tmp/mem1
   rm -f /tmp/fdi
   svprt
   clear
   echo "All done! Do you want to modify /etc/rc.d/rc.local by adding some code
   which is needed to assist sfs-direct-remastering? y or n?"
   read modify
   case $modify in
   y) add2rclocal;;
   n) sleep 1
   exec sfs-unattended-remaster
   exit;;
   esac;;

   d) excludefiles
umnt (){
for dir in $prt
do
   if [[ "$dir"="`cat /proc/mounts | grep sd[a-e][1-9]`" ]]; then
   umount /mnt/$dir 2> /dev/null
   #rm /$path/$dir
   clear
   fi
done
}

prtf () {
if [ -e /tmp/rclc ]; then
rm /tmp/rclc
fi
touch /tmp/rclc
durr=$(mount | grep dev_ro2 | cut -f1 -d ' ' | cut -f3 -d '/')
dorr=$(mount | grep dev_save | cut -f1 -d ' ' | cut -f3 -d '/')
prt=`probepart -m  | grep --invert-match 'none' | cut -f1 -d '|' | cut -f3 -d '/' | grep --invert-match 'sr0'`
echo $prt | tr "\ " "\n" >> /tmp/rclc
while read line
do
mkdir -p /$path/$line 2> /dev/null
mount /dev/$line /$path/$line 2> /dev/null
if [[ ! -z "$durr" ]]; then
umount /$path/$durr 2> /dev/null
rm -r /$path/$durr 2> /dev/null
fi
if [[ ! -z "$dorr" ]]; then
umount /$path/$dorr 2> /dev/null
rm -r /$path/$dorr 2> /dev/null
fi
mount /dev/$line /$path/$line 2> /dev/null
done < /tmp/rclc

}
prtf1 () {
for dir in $prt
do
   if [[ ! $dir == $drive ]]; then
   umount /$path/$dir 2> /dev/null
   fi
done
}

work () {
prtf
echo "This pc has these partitions."
echo "-------------------------"
sda=`probepart -m | grep --invert-match 'none' | grep --invert-match sr* | cut -f1 -d '|' | df -h --exclude-type=aufs --exclude-type=tmpfs`
echo "$sda" | grep --invert-match loop | sed 's|/initrd/mnt/dev_ro2|/'$path'/Home|g' | sed 's|/initrd/mnt/dev_save|/'$path'/home|g' | grep --invert-match 'initrd' | grep --invert-match sr0 | sort -ru

echo "-------------------------"
echo "Input partition e.g. 'sda3'"
read drive

if [[ ! -d /$path/$drive ]]; then
mkdir -p /$path/$drive 2> /dev/null
mount /dev/$drive /$path/$drive 2> /dev/null
elif [[  -d /$path/$drive ]]; then
mount /dev/$drive /$path/$drive 2> /dev/null
fi
clear
echo "'$drive' are you sure? y or n"
   read dummy
   case $dummy in
   n) clear
   work;;
   y) echo "ok";;
   esac
}
   work
   prtf1
   mkdir -p /tmp/quaddirs/{mnt,tmp,sys,proc}
   if [ -e /$path/$drive/$name ]; then
   mv -f /$path/$drive/$name /$path/$drive/$name-old
   echo "Previous '$name' gets backed-up to '$name-old"
   sleep 1
   else
   echo "Proceeding with '$name' remaster on '/$path/$drive' with '$comp'"
   fi
   if  [ -d /aufs ]; then                        #FatDog64
      echo "/lib/modules/" >> /tmp/excluded.txt
   echo "/lib/firmware/" >> /tmp/excluded.txt
   mksquashfs /* /tmp/quaddirs/* /$path/$drive/$name $comp $ef -keep-as-directory -noappend # /proc /tmp /mnt /proc /sys /aufs /archive /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /etc/rc.d/PUPSTATE /etc/rc.d/PUPSAVE.conf /etc/rc.d/WOOFMERGEVARS /root/spot/Downloads/* /root/Downloads/* /root/.xsession-errors /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /var/tmp/* /var/run/* /var/slapt-get/* /var/lib/slapt/lists  -keep-as-directory -noappend
      addidstring
      mkdir /$path/$drive/fdi; cd /$path/$drive/fdi
   echo "Enter path to your fatdog initrd. eg mnt home Fatdog700"
   read path drive dir
   cpio -i < /$path/$drive/$dir/initrd
   mv -f /$path/$drive/$name /$path/$drive/fdi
   cd /$path/$drive/fdi
   find . | cpio -o -H newc > /$path/$drive/initrd
   rm -r /$path/$drive/fdi
   mv /$path/$drive/$dir/initrd /$path/$drive/$dir/initrd-old
   mv /$path/$drive/initrd /$path/$drive/$dir/
      if [[  -e /$path/$drive/initrd ]]; then
      echo "Finished."
      else
      echo "Finished!"
      fi

   elif [ -d /live-rw-backing ]; then               #DebianDog
   echo "/etc/blkid.conf" >> /tmp/excluded.txt
      chmod a=rwx,o+t /$path/$drive/quaddirs/tmp
       zerosize /$path/$drive/$dir/usr/share/doc -type f -size +1c
       zerosize /$path/$drive/$dir/usr/share/doc -type l
       zerosize /$path/$drive/$dir/usr/share/man -type f -size +1c
       zerosize /$path/$drive/$dir/usr/share/man -type l
       zerosize /$path/$drive/$dir/usr/share/info -type f -size +1c
       zerosize /$path/$drive/$dir/usr/share/info -type l
       zerosize /$path/$drive/$dir/usr/share/gnome/help -type f -size +1c
       zerosize /$path/$drive/$dir/usr/share/gnome/help -type l
       zerosize /$path/$drive/$dir/usr/share/gtk-doc -type f -size +1c
       zerosize /$path/$drive/$dir/usr/share/gtk-doc -type l
       chown -R man:root /$path/$drive/$dir/usr/share/man
      mksquashfs /* /tmp/quaddirs/* /$path/$drive/$dir/$name $comp $ef -keep-as-directory -noappend # /media/* /etc/udev/rules.d/70-persistent* /root/.xsession-errors /live-rw-backing/* /live/* /proc /tmp /mnt /initrd /sys /archive /etc/resolv.conf /etc/blkid.conf /etc/rc.d /etc/DISTRO_SPECS /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /lib/keymaps /lib/consolefonts /root/.pup_event /root/.history /root/.xsession-errors /root/.bash_history /root/.Skype /cdrom /root/.XLOADED /etc/.XLOADED /var/lib/dhcp/dhclient.eth0.leases /var/run/* /var/lib/dhcpcd/*.lease /var/tmp/* /var/lib/alsa/asound.state /var/cache/apt /var/lib/apt/lists/*-keep-as-directory -noappend
   echo "All done!"
   elif [ -d /initrd/pup_z/lib/modules ]; then         #Huge kernels
      echo "Modules in or out?"
      read mods
      case $mods in
      out) echo "/lib/modules/" >> /tmp/excluded.txt
   echo "/lib/firmware/" >> /tmp/excluded.txt
   mksquashfs /* /tmp/quaddirs/* /$path/$drive/$name $comp $ef -keep-as-directory -noappend # /proc /tmp /mnt /etc/rc.d/PUPSTATE /etc/rc.d/PUPSAVE.conf /etc/rc.d/WOOFMERGEVARS /initrd /proc /sys /archive /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /lib/live/mount /root/.xsession-errors /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /var/tmp/* /var/run/* /var/cache/apt /var/slapt-get/* /var/lib/apt/lists -keep-as-directory -noappend
   addidstring
   echo "All done!" ;;
   in)    mksquashfs /* /tmp/quaddirs/* /$path/$drive/$name $comp $ef -keep-as-directory -noappend # /proc /tmp /mnt /etc/rc.d/PUPSTATE /etc/rc.d/PUPSAVE.conf /etc/rc.d/WOOFMERGEVARS /initrd /proc /sys /archive /root/.cache/mozilla /root/.cache/google /root/.thumbnails /root/.Trash /root/spot/Downloads/* /root/Downloads/* /lib/live/mount /root/.xsession-errors /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /var/tmp/* /var/run/* /var/cache/apt /var/slapt-get/* /var/lib/apt/lists -keep-as-directory -noappend
   addidstring
   echo "All done!" ;;
   *) sfs-direct-remaster && exit;;
   esac   
   else                                       #pups with built-in modules
   mksquashfs /* /tmp/quaddirs/* /$path/$drive/$name $comp $ef -keep-as-directory -noappend # /proc /etc/rc.d/PUPSTATE /etc/rc.d/PUPSAVE.conf /etc/rc.d/WOOFMERGEVARS /aufs/* /tmp /mnt /media/* /initrd /proc /sys /archive/* /root/.cache/mozilla /root/.cache/google /root/.thumbnails /dev_save/* /root/.Trash /root/spot/Downloads/* /root/Downloads/* /root/.history /root/.bash_history /root/.Skype /root/.XLOADED /etc/.XLOADED /var/tmp/* /var/run/*-keep-as-directory -noappend
   addidstring
   fi
   rm -f ~/Startup/star
  svprt2  () {
   echo "'$name' has been created in '/$path/$drive'. Where do you want to save it?
   Enter the path e.g. /mnt/sda2/'directory'/
   
     (the old '$name' gets backed-up to '$name'-old)"
   read savepart
   if [[ -f $savepart$name-old ]]; then
   mv -f $savepart$name-old $savepart$name-old-old
   mv -f $savepart$name $savepart$name-old
   mv -f /$path/$drive/$name $savepart
   elif [ -f $savepart$name ]; then
   mv -f $savepart$name $savepart$name-old
   mv -f /$path/$drive/$name $savepart
   elif [ ! -f $savepart$name ]; then
   mv -f /$path/$drive/$name $savepart
   else
   clear
   echo "Try again!"
   sleep 1
   svprt2
   fi
}
   svprt2
   cleantmp
   clear
   umnt
   echo "All done! Do you want to modify /etc/rc.d/rc.local? y or n?"
   read modify
   case $modify in
   y) add2rclocal;;
   n) sleep 1
   exec sfs-unattended-remaster
   exit;;
   esac;;
   m) exec sfs-unattended-remaster
   exit;;
   *) clear
   echo "You didn't enter anything relevant try again!"
   sleep 1
   clear
   exec sfs-direct-remaster
   exit;;
esac

Last edited by stemsee on Mon 17 Nov 2014, 03:46; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 541
Location: London

PostPosted: Sat 15 Nov 2014, 21:14    Post subject:  

Here is the script of sfs-unattended-remaster . It needs supporting files to work properly. Taken from StemseeS-Remastering-Suite.

Code:
#!/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.
   
  Enter a number now and press 'Enter'."
read sf
clear
}
menu

timelimit=8

dir1=apupsys
dir2=bpupiso
durr=`mount | grep dev_ro2 | cut -f1 -d ' ' | cut -f3 -d '/'`
dorr=`mount | grep dev_save | cut -f1 -d ' ' | cut -f3 -d '/'`

pathdef () {
if [ -d /live-rw-backing ]; then
path=/media/
else
path=/mnt/
fi
}
pathdef
excludefiles () {
   while read line; do
    if [[ -e $line ]]; then
    echo $line >> /tmp/excluded.txt
    fi
   done < /tmp/exclude
}
rtn2menu="sfs-unattended-remaster && exit"
start () {
echo "Enter the drive with the '$dir1' you wish to sync with running system.
For example 'sda2'"
read drive
if [[ "$drive" == home ]]; then
echo "home is already mounted"
elif [[ "$drive" == Home ]]; then
echo "Home is already mounted"
else
mount /dev/$drive /$path/$drive 2> /dev/null
fi
if [ -d $path$drive/$dir1 ]; then
echo "Press ok to rsync running system with /mnt/'$drive'/'$dir1'."
read dummy2
. $path$drive/$dir1/etc/DISTRO_SPECS
touch /tmp/excluded.txt
cp ~/my-applications/.exclude /tmp/exclude
excludefiles
rsync -av --delete /* $path$drive/$dir1 -F --exclude-from=/tmp/excluded.txt
sync
echo
else
echo
echo "'$dir1' on '$drive' wasn't found. Please check spelling and path. 'Enter' to try again."
read dummy3
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
   if [[ $durr = $drive ]]; then
   drive="Home"
   elif [[ $dorr = $drive ]]; then
   drive="home"
   fi

   echo
   if [ $drive = home ]; then
   echo "home is already mounted."
   elif [ $drive = Home ]; then
   echo "Home is already mounted."
   elif [ ! -d $path$drive ]; then
   mkdir -p $path$drive
   mount /dev/$drive $path$drive 2> /dev/null
   else
   mount /dev/$drive $path$drive 2> /dev/null
   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
   if [[ $durr = "`echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' | cut -f1 -d '/'`" ]]; then
   echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' | sed -e 's|'$durr'|Home|' > /tmp/sfs
   elif [[ $dorr = "`echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' | cut -f1 -d '/'`" ]]; then
   echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/'  | sed -e 's|'$dorr'|home|' > /tmp/sfs
   else
   echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' > /tmp/sfs
   fi
   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
   if [[ $durr = "`echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' | cut -f1 -d '/'`" ]]; then
   echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' | sed -e 's|'$durr'|Home|' > /tmp/sfs
   elif [[ $dorr = "`echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' | cut -f1 -d '/'`" ]]; then
   echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/'  | sed -e 's|'$dorr'|home|' > /tmp/sfs
   else
   echo $PUPSFS | cut -c 1-4,11-40 | cut -f1,2 -d '/' > /tmp/sfs
   fi
   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
}
addidstring () {
   echo -e "Do you want to append the idstring to the sfs? 'y' or 'n'? $timelimit seconds\n: \c"
   string=""
   read -t $timelimit answer
if [ ! -z "$string" ]; then
   echo -e "
   \n You entered '$string'"
else
   echo -e "
   \n TIME OUT\n Assume no"
   string=n
fi
   case $string in y) [ $DISTRO_IDSTRING ] && echo -n "$DISTRO_IDSTRING" >>/$path/$drive/$name;;
               n) echo "not added.";;
               *) addidstring;;
   esac
}
   

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/
      addidstring
      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/
      addidstring
      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/
      addidstring
      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
      . /etc/DISTRO_SPECS
      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/`echo $DISTRO_SAVESFS` ext`echo $DISTRO_SAVESFS | cut -f2  -d '.' | cut -c1` 500
                                           ( ^ 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 "'y' or 'n'?"
         read savemnt
         case $savemnt in
         y) mount -o loop $savefile /initrd/pup_rw;;
         n) echo "Not mounted. If a non-standard name was given you will need to edit DISTRO_SPECS in initrd.gz.";;
         esac
         sleep 2
         $rtn2menu && exit;;
         
      b) echo "Create a pupswap.swp swapfile. 
   Enter path and size;
      eg /mnt/home 500  (MB)"   
         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 copy and paste this line to the bottom of fstab
      
'/mnt/home/pupswap.swp    none   swp      sw                  0 0 '"
      echo
         sleep 8
         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
surfn () {
echo "Here begins the unattended remaster section.  Option 8 in the Menu."
fndboot
workdrive
echo
echo "Proceeding with remaster on '$drive'."
sleep 1
echo
}
surfn
checkfn () {
echo "Checking if previous remaster directories exist."
clear
sleep 1
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 10
   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
}
checkfn
rsyncfn () {
clear
mkdir -p $path$drive/{$dir1,$dir2}
echo "Start copying from your running system.
Press Ctrl+c anytime to stop!"
sleep 1
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/*}
}
rsyncfn
addirsfn () {
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
}
addirsfn
cleanfn () {
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 .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/*
rm -rf .pup_event/*
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
echo "Cleaning finished"
}
cleanfn
compfn () {
clear
echo -e "
Enter your preferred compression e.g. -comp xz
                                   or -comp xz -b 1024k -Xbcj x86
                                   or -comp gzip
     
      Enter mksquashfs 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 -b 1024k -Xbcj x86'."
comp="-comp xz -b 1024k -Xbcj x86"
fi
}
compfn
scompfn () {
if [ -d /aufs ]; then
   cp -a ~/my-applications/bin/star $path$drive/$dir1/root/Startup/
   scomp=fd
elif [ $path == /media/ ]; then
   scomp=dd
elif [ $path == /mnt/ ]; then
   cp -a ~/my-applications/bin/star $path$drive/$dir1/root/Startup/
   scomp=pp
else
   cp -a ~/my-applications/bin/star $path$drive/$dir1/root/Startup/
   echo "Enter custom name for sfs. '00-filesystem.squashfs' 'puppy2.sfs' etc"
   read name
   scomp=pp
fi
}
pathdef
scompfn
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 $scomp in
   pp) modules
   mksquashfs  $path$drive/$dir1 $path$drive/$name $comp -noappend
   mv $path$drive/$name $path$drive/$dir2/;;
   
   fd) modules
   mksquashfs  $path$drive/$dir1 $path$drive/$name $comp -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 -noappend
   mv $path$drive/$name $path$drive/$dir2/;;
   
   *) modules
   mksquashfs  $path$drive/$dir1 $path$drive/$name $comp -noappend
   mv $path$drive/$name $path$drive/$dir2/;;
esac
addidstring
isofn () {
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 vmlin64 vmlinux1 initrd initrd.gz initrd1.img initrd.xz initrd1.xz initrd.img vmlin32
      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 vmlinuz vmlin64 vmlinux1 initrd.gz initrd initrd1.img initrd.xz initrd1.xz initrd.img vmlin32 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 vmlin64 vmlinux1 initrd initrd.gz initrd1.img initrd.xz initrd1.xz initrd.img vmlin32
      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 vmlin64 vmlinux1 initrd.gz initrd initrd1.img initrd.xz initrd1.xz initrd.img vmlin32 wheezy-i486.sgn
      do
      cp -a $path$boot/$file $path$drive/$dir2/
      done
   elif [[ -d /live-rw-backing ]]; then
      for file in vmlinuz vmlin64 vmlinux1 initrd.gz initrd initrd1.img initrd.xz initrd1.xz initrd.img vmlin32 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
}
isofn
tidyupfn () {
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
}
tidyupfn
deldir2fn () {
clear
if [ ! -f $path$drive/$niso ]; then
   echo "'$drive'/'$dir2' directory left in existence."
   sleep 1
else
   echo "'$niso' has been created on '$drive' so deleting '$dir2' directory."
   sleep 1
   rm -rf $path$drive/$dir2
fi
}
 endfn () {
   clear
   echo "
                                  All done!
                         Press enter to return to Menu."
read dummy
$rtn2menu
##THE END##
}
endfn
Back to top
View user's profile Send private message MSN Messenger 
Display posts from previous:   Sort by:   
Page 1 of 2 [24 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

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
[ Time: 0.3746s ][ Queries: 12 (0.0105s) ][ GZIP on ]