The modification consists of only five lines of code. In the section of initrd that chooses the pup_save file, the lines between the comments are added:
Code: Select all
...
PUPMODE=0
#choose which pup_save.2fs to use...
if [ -f /tmp/MULTIFOLDERS ];then #multisession cd/dvd.
if [ "$PRAMONLY" = "yes" ];then #v3.97 fix 'pfix=ram' for multisession dvd.
PUPSAVE=""
else
PUPMODE=72 #77 v3.01 64+8, will become 77.
PUPSAVE="`cat /tmp/MULTIFOLDERS | cut -f 1-3 -d ' ' | tr ' ' ','`" #only record 1st folder.
fi
else
#Added PUPSAVE code
[ $psave ] && PSAVE=$psave #Explicit pup save file. ex: pup_save.2fs pup_save2.2fs
if [ $PSAVE ]; then
grep "$PSAVE" /tmp/PUPSAVE2FSS > /tmp/PUPSAVTMP
mv -f /tmp/PUPSAVTMP /tmp/PUPSAVE2FSS
fi
# End added code
NUMPUPSAVES=`wc -l /tmp/PUPSAVE2FSS | tr -s ' ' | cut -f 2 -d ' '`
[ "$PRAMONLY" = "yes" ] && NUMPUPSAVES=0 #pfix=ram is a boot param.
case $NUMPUPSAVES in
...
boot code:
Code: Select all
LINLD.COM image=D:\linux\puppy\p412\vmlinuz initrd=D:\linux\puppy\p412\initrd.gz cl=@D:\PUPPY.LIN
Code: Select all
root=/dev/ram0
pmedia=idehd
acpi=on
psubok=TRUE
psubdir=linux/puppy/p412
psave=pup_save2.2fs
Typical pupsave parameter:
hda3,ext2,/pup220/pup_save.2fs
The psave parameter actually can contain the same type of format as pupsave, or can contain abbreviated forms:
psave=sda2,vfat,/linux/puppy/p412/pup_save2.2fs
psave=pup_save2.2fs
psave=2.2fs
psave=2.2
They all have the same effect, since all available save files have been identified by this time in the init code; then grep does all the work.
If you have save files of the same name but in different partitions, you can simply specify the partition:
psave=sda2
There are all sorts of combinations that can work for your specific situation.
The code is not elegant (hey, I've only been doing shell scripts for a month, give me a break), but is very robust. If there is a match, the appropriate save file is loaded. If there are still multiple matches, the original menu comes up to give your choices. If there is no match, Puppy still boots, just with no save file.
All this description for five lines of code. Actually, its all the other neat code in init that these five lines take advantage of that makes this feature really cool.
Note: This version of init is from Puppy V4.12 initrd.zg, and also contains the modifications discussed in a previous post
http://www.murga-linux.com/puppy/viewtopic.php?t=36703
Contents of the init file: