init 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019
  1. #!/bin/sh
  2. #(c) Copyright 2007 Barry Kauler, www.puppylinux.com
  3. #2007 GPL licence v2 (/usr/share/doc/legal/gpl-2.0.txt)
  4. #Aug 2007, init script in initramfs, for puppy v2.20, Sept: v3.00, Oct: v3.01
  5. #Nov 2007, v3.91: bugfix for humongous puppy.
  6. #dec 2007, v3.93: update for 2.6.24 kernel, no /dev/hd*. v3.94: bugfix.
  7. #v3.95 28dec07: load scsi_wait_scan.ko to fix sync problem with usb.
  8. #v3.95 1jan08: fix for renaming of pmedia ide/sata -> ata.
  9. #v3.96 26jan08: 2.6.24 kernel, remove scsi_wait_scan.ko and the delays.
  10. #v3.97 31jan2008: restore support for hd* drives.
  11. #v3.97 25feb2008: removed tmpfs on /tmp.
  12. #v3.97 5mar2008: handle SAVEMARK file (see universal installer and rc.shutdown).
  13. #v3.97 6mar2008: fix 'pfix=ram' for multisession cd/dvd.
  14. #v3.97 6mar2008: multisession, copy saved .sfs files to '/' in ram.
  15. #v3.98 3apr2008: partial fix, encrypted pup_save losetup failing.
  16. #v4.00 21apr2008: ntfs-3g upgraded v1.417 to v1.2412.
  17. #v4.00 26apr2008: slightly lowered threshold for copying pup_xxx.sfs to a tmpfs.
  18. #v4.00 27apr2008: k2.6.25: strange sync problem. try restore scsi_wait_scan. NO, DO NOT.
  19. #v4.01 7may2008: new system with all modules builtin to initrd, if ZDRVINIT='yes'
  20. #v4.02 31may2008: export ZDRVINIT in /etc/rc.d/PUPSTATE
  21. #v403 21jun08: reintroduce basic pcmcia support.
  22. #v403 23jun08: fix for humongous initrd.
  23. #v403 23jun08: fix boot from usb cd drive (classmate laptop).
  24. #v404 13Jul08: pfix=noram removed, now need pfix=copy to copy .sfs to ram.
  25. #v404 15jul08: prevent crash in PUPMODE 6,7. add pfix=fsck, otherwise never do fsck.
  26. #v404 16jul08: fix for classmate with internal usb flash, PUPMODE now 13, not 12.
  27. #v405 18jul08: default is now aufs. maybe won't even have unionfs module.
  28. #v406 2aug08: restore support for old /dev/hd* ide devices.
  29. #v406 9aug08: copy pup_xxx.sfs to same place as pup_save if fast media.
  30. #v407 fix for module name change.
  31. #v410 fix to allow 3 extra sfs files (a bug only allowed 2).
  32. #v411 multisession, load saved /dev entries.
  33. #v412 simplified module loading.
  34. #v412 slight changes for new busybox v1.12.1.
  35. #v412 fix usb-storage probe bug.
  36. #v412 DISTRO_SPECS file. pup_xxx.sfs, zdrv_xxx.sfs renamed.
  37. #v412 bugfix, /tmp/versioncleanup got overwritten by tmpfs mounted on /tmp.
  38. #v412 bugfix, pup_ro6 was not created (for 3rd sfs file).
  39. #w001 DISTRO_FILE_PREFIX, pup files renamed again, to woofsave.2fs, woofr001.sfs.
  40. #w003 fix for loading yenta-socket module.
  41. #w003 changed default to copy woofr001.sfs to ram >256MB ram.
  42. #w003 /usr/sbin/snapmergepuppy now saves whiteout files to save-layer, change 'ro' to 'ro+wh'.
  43. #w004 LANG=C
  44. #w007 load nls_utf8.ko
  45. #w012 bugfix. w014 usb flash can now have iso9660 f.s.
  46. #w014 BootFlash utility can create 2 partitions in usb drive, one for boot, other for save.
  47. #w015 allow 6 extra sfs files, up from 3.
  48. #w019 pmedia=ataflash, PUPMODE=13 to constrain writes to drv.
  49. #w460 bugfixes for zdrv, new name zu500629.sfs, handling 6 extra sfs files (7 incl. zdrv).
  50. #w460 bugfix, boot usb, 1st shutdown was not offering to save session sometimes.
  51. #w464 tidyup, make sure /etc/puppyversion is history.
  52. #w468 load nls_cp850, now default for fat f.s. (2.6.29.2 kernel).
  53. #w476 mntfunc() rewritten, support 'pkeys' boot param (work in progress).
  54. #w478 modify sfs exclusion rules.
  55. #w479 fix finding optical drive for kernel with old ide drivers.
  56. #w481 record fast partitions, used by rc.shutdown.
  57. #w482 lowered limit for copy sfs to ram, so multisession will work in 256mb pc.
  58. #v423 k2.6.29.6 dmesg has warning that ehci-hcd should load before uhci-hcd and ohci-hid.
  59. #v423 problem recent kernels: hid-* extra drivers needed as well as usbhid.
  60. #v423 need to reject wrong squashfs version, 3.x or 4.0.
  61. #v424 BootManager no longer has checkbox to only load _nnn.sfs files.
  62. #v424 try again, fix tmpfs overwrites /tmp/versioncleanup
  63. #v424 whiteout processing for aufs2 fixed.
  64. #v426 pkeys=de caused failure to boot from vfat partition.
  65. #v426 record of layers needs to include zdrv.
  66. #v431 piratesmack: fix boot from ext4.
  67. #091031 support quirky, kernel with initramfs built-in, maybe also <main f.s.>.sfs.
  68. #091122 now have /lib/keymaps, /lib/consolefonts, load map if pkeys boot param.
  69. #091222 first support for recognising mmc/sd cards at bootup.
  70. #091225 copy executables from initrd to main f.s.
  71. #100113 TARGETEXES file needed in main f.s., for universal installer.
  72. #100214 one config of 2.6.33 has base floppy and ps/2 mouse support not builtin.
  73. #100222 fix sync problem writing to BOOTCONFIG. technosaurus: consider very big puppies.
  74. #100318 fix any improper shutdowns. see /etc/rc.d/rc.sysinit, rc.shutdown, /sbin/init.
  75. #100323 hwclock path was wrong.
  76. #100401 fix so pupsave can be ext2, ext3 or ext4.
  77. #100406 latest patched aufs may allow sfs mntd one layer to be resident another layer.
  78. #100423 try yet again, fix tmpfs overwrites /tmp/versioncleanup
  79. #100427 despite the help inside the hwclock applet, it doesn't accept long-options.
  80. #100520 pkeys boot param wasn't working for 'uk', 'dvorak'.
  81. #100710 if pupsave file is in a subdirectory, only look for extra sfs's in that subdirectory.
  82. #100711 modify above, look in top dir and in subdirectory.
  83. #100820 multisession shutdown may now relocate some content of /var to /root/.var_saved.
  84. #100831 fix KERNELSUBVER for olpc people, have 'uname -r' returning version with '_'.
  85. #100911 simplified file names: vmlinuz, initrd.gz, puppy.sfs, zdrv.sfs, devx.sfs.
  86. #100911 fsckme.err filename changed to fsckme.flg. see also initNEW, rc.sysinit, rc.shutdown.
  87. #100911 completely overhauled the code to find puppy files. note, dropped support for /proc/ide.
  88. #100914 fallback, search depth 3 -- sub-sub-folders. improve psubdir search.
  89. #100915 technosaurus suggested 'pupsfs' and 'zdrv' kernel boot params. 100916 remove devxsfs. 100919.
  90. #100920 fix decision copy .sfs to ram.
  91. #100922 frugal install, multiple save-files in install-folder, was not offering choice.
  92. #101005 echo extra info if attempted mount failed.
  93. #101013 puppy.sfs was copied to tmpfs so can unmount partition.
  94. #101020 SAVEMARK file can be in sub-directory that pup is installed in, improve searching for save-file.
  95. #101021 avoid finding vmlinuz on hd when booting from cd.
  96. #101028 ask if upgrading save-file. check if puppy.sfs copied to same place as save-file.
  97. #101101 fix load zdrv if in humongous initrd.
  98. #101102 zdrv.sfs was not getting loaded for PUPMODE=6/7 (save to entire partition).
  99. #101103 ignore any session saved to entire partition if puppy installed in a subdir.
  100. #101103 maybe network boot, no local vmlinuz.
  101. #101103 modified logic to find save-file, tried some restrictions.
  102. #101127: pakt: A precfg area for faster re-mastering, no need to regenerate a .SFS.
  103. #101127 added some debugging into /tmp. Will end up in /initrd/tmp after bootup.
  104. #101127 force update of /proc/partitions (slow to update for usb).
  105. #101218 if boot from cd with 'pfix=ram', do not search other drives (do not want to load puppy.sfs off hd).
  106. #110114 if a drive unplugged in previous boot, but plugged in at bootup, device-nodes will be missing in main f.s...
  107. #110116 jamesbond: for netboot, PDEV1 is empty, tests modified. see: http://murga-linux.com/puppy/viewtopic.php?t=63400&start=180
  108. #110116 shinobar: do not change PUPMODE 6 to 7, 12 to 13, if extern usbhd.
  109. #110122 bypass update code, maybe causes more trouble than worth it. Rely on /etc/rc.d/update for all updating.
  110. #110126 restored support for /proc/ide, device nodes /dev/hd*.
  111. #110204 110205 110206 bug fixes: booting ide kernel, copying .sfs to sub-folder. warning: busybox grep -F different from full grep.
  112. #110212 recent aufs: .wh.__dir_opaque name changed to .wh..wh..opq.
  113. #110217 very bad hack, see /etc/rc.d/rc.update, rc.shutdown.
  114. #110223 reset /tmp/PUPSAVES if loop back to do deeper search.
  115. #110304 fix a test.
  116. #110405 fix 'free' applet output format different in later versions of busybox.
  117. #110422 DISTRO_VERSION variable now has dotted format. note, also now using full dotted version# in puppy filenames.
  118. #110424 do not copy puppy*.sfs into a sub-dir (reverse of 110204). see also rc.shutdown.
  119. #110425 major change, /sbin/wait4usb parallel process while searching ata drives, to speed booting.
  120. #110426 move done/failed 2 places to right (also in rc.sysinit script).
  121. #110509 fix for 'grep -f filename' where filename was empty only one LF char.
  122. #110521 also convert bytes to kb.
  123. #110710 handle kernel with usb driver built-in, and/or without my usb-drive-discovery patch (2.6.34+).
  124. #110722 fix deleting of old boot scripts.
  125. #110810 some builds may have many scsi drivers in initrd, if needed will have already loaded, so delete them.
  126. #110810 problem kernel numbering 2.6.32-40, 2.6.32-44 both in /lib/modules/2.6.32.
  127. #111003 ldolse: pemasu 2.6.39 kernel showing usb at also ata, causing double writes to /tmp/PUPSAVES.
  128. #111120 workarounds for missing support utilities: fusermount (no longer needed), e2fsck, resize2fs
  129. #120130 bring back Underdog Linux. Refer "take 2": http://puppylinux.com/development/howpuppyworks.html
  130. #120215 internationalized (with help from L18L). /PUPPYLANG inserted by quicksetup (in future, Woof too).
  131. #120216 /PUPPYKEYMAP inserted by quicksetup. if PLANG but no PKEYS, try assign matching PKEYS. L18L: new fonts.
  132. #120217 L18L: export LANGUAGE and OUTPUT_CHARSET.
  133. #120222 remove setting LANGUAGE. fix if boot param shortened, ex: plang=de
  134. #120328 could have iso9660 f.s. booting off a usb flash/hard drive (see BootFlash). exclude /dev/sd and /dev/mmc.
  135. #121102 file DISTRO_SPECS has new variable DISTRO_DB_SUBNAME. ex: for 14.0-based slacko, DISTRO_DB_SUBNAME=slacko14
  136. #121227 more f.s. drivers as modules, need to load (see also 3builddistro).
  137. #130128 support udf f.s.
  138. #130211 ntfs-3g needs "silent" option.
  139. #130216 preliminary support for f2fs. note, guess_fstype binary updated for f2fs, not yet busybox.
  140. #130513 if we find a rw f.s., create pupdesk.flg. only needed in PUPMODE=5, see /usr/sbin/quicksetup.
  141. #130514 shinobar: extra sfs in the order of EXTRASFSLIST.
  142. #130514 disable pupdesk.flg mechanism if boot param "pfix=ram".
  143. #130515 woof 3builddistro ask question to disable pupdesk.flg, edit this script.
  144. #130518 fix mounting ntfs for creating pupdesk.flg. fix paths.
  145. #130612 support devtmpfs.
  146. #130618 DEVTMPFSFLG now set by 3builddistro. refer also /etc/rc.d/rc.sysinit.
  147. #130728 always try to copy sfs to ram if >=700MB.
  148. #140102 better font for Russian, font is added to /lib/consolefont (in rootfs-skeleton)
  149. #140102 rodin.s: added utf8-option to VFAT_OUT_PARAM for flash drive to be mounted with utf-8 if boot is done from flash drive
  150. #Unionfs layers setup by this script...
  151. #unionfs layers: RW (top) RO1 RO2 PUPMODE
  152. #full install, flash drive: tmpfs PDEV1 3
  153. #First boot (or pfix=ram): tmpfs pup_xxx.sfs 5
  154. #pup_save is a partition: PDEV1 pup_xxx.sfs 6
  155. #ditto, but flash drive: tmpfs PDEV1 pup_xxx.sfs 7
  156. #Normal running puppy: pup_save.3fs pup_xxx.sfs 12
  157. #ditto, but flash drive: tmpfs pup_save.3fs pup_xxx.sfs 13
  158. #Multisession cd/dvd: tmpfs folders(tmpfs2) pup_xxx.sfs 77 (13+64)
  159. #/bin/hotplug2stdout_notimeout > /tmp/pup_event_uevents_initrd &
  160. #120215 internationalize... (based on work by L18L)
  161. if [ ! $1 ];then
  162. mount -t proc none /proc
  163. mount -t sysfs none /sys
  164. mount -t rootfs -o remount,rw rootfs /
  165. ln -s /proc/mounts /etc/mtab #resize2fs,e2fsck need this.
  166. [ $plang ] && PLANG=$plang #boot parameter
  167. [ "`echo -n "$PLANG" | grep '_'`" = "" ] && PLANG="" #120222 PLANG must be complete, ex: de_DE.UTF-8.
  168. [ ! "$PLANG" ] && [ -f /PUPPYLANG ] && PLANG=`cat /PUPPYLANG` #so Woof can specify a default lang.
  169. #note, a running puppy could also open initrd.gz and stick PUPPYLANG inside (i plan for chooselocale to do that!)
  170. if [ "$PLANG" ];then
  171. if [ -f /locale/${PLANG%.*}/init ];then #chop off .UTF-8 if it is there.
  172. TRANSLATIONFILE="/locale/${PLANG%.*}/init"
  173. else
  174. [ -f /locale/${PLANG%_*}/init ] && TRANSLATIONFILE="/locale/${PLANG%_*}/init" #get first 2 chars of PLANG, ex: en
  175. fi
  176. if [ "$TRANSLATIONFILE" ];then
  177. sed -f $TRANSLATIONFILE /init > /init2
  178. chmod 755 /init2
  179. exec /init2 $PLANG #run translated script.
  180. fi
  181. fi
  182. else #2nd entry, running /init2
  183. PLANG=${1}
  184. fi
  185. export LANG=C #w004
  186. . /DISTRO_SPECS #v412 has DISTRO_VERSION, DISTRO_FILE_PREFIX
  187. [ ! "$DISTRO_DB_SUBNAME" ] && DISTRO_DB_SUBNAME="$DISTRO_COMPAT_VERSION" #121102 fallback if DISTRO_DB_SUBNAME not defined in file DISTRO_SPECS.
  188. PATH="/bin:/sbin"
  189. KERNELVER="`uname -r`"
  190. PUPDESKFLG=1 #130515 this may be changed to 0 by 3builddistro.
  191. # always use DEVTMPFS now.
  192. mount -t devtmpfs devtmpfs /dev
  193. DEVTMPFSFLG=1 #130618 set it from 3builddistro.
  194. #100911 simple filenames specified in DISTRO_SPECS: DISTRO_ZDRVSFS, DISTRO_PUPPYSFS...
  195. ZDRVSFS="$DISTRO_ZDRVSFS"
  196. ADRVSFS="$DISTRO_ADRVSFS"
  197. YDRVSFS="$DISTRO_YDRVSFS"
  198. PUPXXXSFS="$DISTRO_PUPPYSFS"
  199. IDSTRING="$DISTRO_IDSTRING" #from DISTRO_SPECS, string appended to kernel.qky, vmlinuz, puppy.sfs, zdrv.sfs, devx.sfs (see 3builddistro).
  200. [ "`echo "$PUPXXXSFS" | grep '[0-9]\.sfs'`" != "" ] && NAMETYPE='traditional' #110422 has version info.
  201. [ $layerfs ] && LAYERFS=$layerfs
  202. [ ! $LAYERFS ] && LAYERFS=aufs #aufs or unionfs
  203. #[ "`modinfo aufs 2>/dev/null`" = "" ] && LAYERFS=unionfs #precaution. #james no longer needed.
  204. [ $loglevel ] && LOGLEVEL=$loglevel #v2.22
  205. #100318 perform a f.s. check...
  206. fsckme_func() { #passed params: partition filesystem [pupsavefile]
  207. if [ ! -e /bin/e2fsck ];then #111120
  208. echo -e -n "\\033[1;31m SORRY, cannot check filesystem \\033[0;39m" > /dev/console #31=red
  209. return
  210. fi
  211. [ "$DEEPFSCK" = "yes" ] && FCK="-f" || FCK=""
  212. case $2 in
  213. ext2|ext3|ext4)
  214. e2fsck -y ${FCK} /dev/$1 >/tmp/chkret &
  215. echo -e "\\033[1;35m" >/dev/console #35=purple
  216. if [ "${1}" = "loop1" ];then
  217. echo -n " 'save file' filesystem check, please wait..." >/dev/console
  218. else
  219. echo -n " '${1}' filesystem check, please wait..." >/dev/console
  220. fi
  221. usleep 200000 #100604 TazOC gave me idea that delay before pidof is good.
  222. while [ "`pidof e2fsck`" != "" ];do
  223. sleep 1
  224. echo -n "." >/dev/console
  225. done
  226. echo -en "\\033[0;39m" >/dev/console
  227. ;;
  228. esac
  229. if [ $3 ];then
  230. #rc.shutdown has created /fsckme.flg with this 3rd parameter.
  231. #this is a pupsave file, which has a ext2/3/4 f.s (based on .2fs, .3fs, .4fs ext)
  232. #this flag will be set for any prior improper shutdown. if have lots of installations
  233. #of puppy on the pc, the flag may not even be for this install of puppy, however, this is
  234. #the simplest implementation...
  235. PFSCK="yes"
  236. fi
  237. }
  238. mntfunc() {
  239. MNT_T="$1" #ex: vfat
  240. MNT_DEV="$2" #ex: /dev/sda1
  241. MNT_DIR="$3" #ex: /mnt/sda1
  242. MNT_O=""
  243. [ $4 ] && MNT_O="${4}" #ex: noatime
  244. case $MNT_T in
  245. ntfs)
  246. ntfs-3g $MNT_DEV $MNT_DIR -o umask=0,no_def_opts,noatime,rw,silent 2>/dev/null #default is rw. 130211 add silent.
  247. ntfsRETVAL=$?
  248. [ $ntfsRETVAL -eq 0 ] && return 0
  249. if [ $ntfsRETVAL -eq 14 ];then
  250. echo -e "\\033[1;31m" >/dev/console #31=red
  251. echo -n "ERROR: Windows NTFS hibernated partition, cannot mount" > /dev/console
  252. echo -e "\\033[0;39m" >/dev/console
  253. return 14
  254. else
  255. ntfs-3g $MNT_DEV $MNT_DIR -o umask=0,no_def_opts,noatime,rw,force,silent 2>/dev/null #130211 add silent.
  256. fi
  257. ;;
  258. vfat)
  259. mount -t $MNT_T -o $VFAT_OUT_PARAM $MNT_DEV $MNT_DIR
  260. ;;
  261. *)
  262. if [ "$MNT_O" = "" ];then
  263. mount -t $MNT_T $MNT_DEV $MNT_DIR
  264. else
  265. mount -t $MNT_T -o $MNT_O $MNT_DEV $MNT_DIR
  266. fi
  267. ;;
  268. esac
  269. return $?
  270. }
  271. umntfunc() {
  272. #111120 note, this code is not needed anymore for ntfs-3g. normal 'umount' can unmount it.
  273. #warning umntfunc call must have mntpt param, not device name.
  274. LASTPARAM="`echo -n "$*" | tr '\t' ' ' | tr -s ' ' | tr ' ' '\n' | grep '^/mnt/'`"
  275. if [ "`mount | grep "$LASTPARAM" | grep -E 'ntfs|fuse'`" = "" ];then
  276. umount $@
  277. else
  278. fusermount -u $LASTPARAM
  279. fi
  280. return $?
  281. }
  282. check_status()
  283. {
  284. if [ $1 -eq 0 ]
  285. then
  286. /bin/echo -en "\\033[74G" >/dev/console #move to column 72. 110426: 74
  287. /bin/echo -en "\\033[1;32m" >/dev/console
  288. /bin/echo -en "done" >/dev/console
  289. /bin/echo -e "\\033[0;39m" >/dev/console
  290. else
  291. /bin/echo -en "\\033[72G" >/dev/console #110426 move to column 72.
  292. /bin/echo -en "\\033[1;31m" >/dev/console
  293. /bin/echo -en "failed" >/dev/console
  294. /bin/echo -e "\\033[0;39m" >/dev/console
  295. echo -en "\\033[1;35m" >/dev/console #35=purple
  296. echo -n "Dumping last lines of /tmp/bootinit.log..." >/dev/console
  297. /bin/echo -e "\\033[0;39m" >/dev/console
  298. echo -en "\\033[1;31m" >/dev/console #31=red
  299. cat /tmp/bootinit.log | tail -n 4 >/dev/console
  300. /bin/echo -en "\\033[0;39m" >/dev/console
  301. echo -en "\\033[1;35m" >/dev/console #35=purple
  302. echo -n "Dumping last lines of kernel log..." >/dev/console
  303. /bin/echo -e "\\033[0;39m" >/dev/console
  304. echo -en "\\033[1;31m" >/dev/console #31=red
  305. dmesg | tail -n 4 >/dev/console
  306. /bin/echo -en "\\033[0;39m" >/dev/console
  307. #exit to initial ramdisk shell...
  308. [ "$RDSH" != "" ] && exec /bin/sh >/dev/console 2>&1
  309. echo "Pausing for 60 seconds..." >/dev/console
  310. sleep 60
  311. fi
  312. }
  313. search_func() { #110425
  314. case $1 in
  315. ata)
  316. [ "$PMEDIA" = "usbflash" -o "$PMEDIA" = "usbhd" ] && return #only probe usb drives.
  317. LESSPARTS0="`echo "$PCPARTS0" | grep -f /tmp/ALLDRVS0`" #111003 only probe non-usb drives. need for kernels builtin usb drvr.
  318. ;;
  319. *) #usb
  320. LESSPARTS0="`echo "$PCPARTS0" | grep -v -f /tmp/ATADRIVES0`" #only probe usb drives.
  321. ;;
  322. esac
  323. if [ "$PMEDIA" ];then #kernel boot param
  324. case $PMEDIA in
  325. cd)
  326. [ "$PRAMONLY" = "yes" ] && LESSPARTS0="`echo "$LESSPARTS0" | grep -E 'iso9660|udf'`" #do not search other drives. 130128 add udf.
  327. ;;
  328. *)
  329. #note: a mistake if have PDEV1 on usb booting, as it can change.
  330. [ "$PDEV1" ] && LESSPARTS0="`echo "$LESSPARTS0" | grep "${PDEV1}|"`" #kernel boot param.
  331. ;;
  332. esac
  333. fi
  334. [ "$LESSPARTS0" = "" ] && return #nothing to search in.
  335. LESSPARTS="`echo "$LESSPARTS0" | tr '\n' ' '`"
  336. echo "$PCPARTSALL" > /tmp/PCPARTSALL_${1} #for debugging.
  337. echo "$LESSPARTS0" > /tmp/LESSPARTS0_${1} #for debugging.
  338. #130513 want to give preference to write pupdesk.flg to a linux partition...
  339. LINUXFS="$(echo "$LESSPARTS0" | grep -E 'ext2|ext3|ext4|reiserfs|minix|f2fs' | head -n 1)"
  340. #find puppy files in the pc...
  341. #vmlinuz (and optional simplified puppy.sfs (PUPXXXSFS), zdrv.sfs (ZDRVSFS)) have appended id-string (IDSTRING).
  342. IGNORE=''
  343. SEARCHDEPTH=2
  344. [ "$PSUBDIR" ] && SEARCHDEPTH=1
  345. for ONETRY in $LESSPARTS
  346. do
  347. ONEDEV="`echo -n "$ONETRY" | cut -f 1 -d '|'`"
  348. ONEFS="`echo -n "$ONETRY" | cut -f 2 -d '|'`"
  349. ONEDRV="`echo -n "$ONEDEV" | grep -o -f /tmp/ALLDRVS0`" #110205 ex: sda1 becomes sda.
  350. if [ "$IGNORE" = "optical" ];then #110126 ignore optical if boot partition found.
  351. [ "`echo -n "$ONEDRV" | grep -f /tmp/OPTICALDRIVES0`" != "" ] && continue #110205
  352. fi
  353. [ "$PFSCK" = "yes" ] && [ "$pdev1" = "$ONEDEV" ] && \
  354. [ "$(echo $ONEFS| cut -c 1-3)" = "ext" ] && fsckme_func $ONEDEV $ONEFS
  355. #v403 nasty bug: usb optical drive showing as /sys/block/sr0, but won't mount, needs more delay...
  356. mntfunc $ONEFS /dev/$ONEDEV /mnt/data #-t $ONEFS /dev/$ONEDEV /mnt/data
  357. if [ $? -ne 0 ];then
  358. echo "PAUSE 5SEC: tried to mount /dev/${ONEDEV}, ${ONEFS} f.s." #101005 boot param loglevel=7 will show this.
  359. echo -e -n " \\033[1;31mpausing\\033[0;39m" > /dev/console #31=red
  360. sleep 5 #2 wasn't enough.
  361. mntfunc $ONEFS /dev/$ONEDEV /mnt/data
  362. if [ $? -ne 0 ];then
  363. echo "RETRY FAILED: mounting /dev/${ONEDEV}, ${ONEFS} f.s." #101005
  364. continue
  365. fi
  366. fi
  367. echo "ONEDEV=$ONEDEV ONEFS=$ONEFS ONEDRV=$ONEDRV PSUBDIR=$PSUBDIR" >> /tmp/puppy-file-search.log #101127 for debugging.
  368. if [ -d /mnt/data${PSUBDIR} ];then
  369. if [ "$VMLINUZ" = "" ];then #search for kernel.qky and vmlinuz...
  370. if [ "$ONEFS" != "iso9660" -a "$PMEDIA" = "cd" -a "$ONEFS" != "udf" ];then #101021 avoid finding vmlinuz on hd. 110204. 130128 also udf.
  371. echo "Bypass looking for vmlinuz on $ONEDEV"
  372. else
  373. FND_FILES="`find /mnt/data${PSUBDIR} -maxdepth ${SEARCHDEPTH} -xdev -type f -iname kernel.qky -o -iname ${KERNELNAME} | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  374. for ONEPUPFILE in $FND_FILES #kernel.qky: see woof script 4quirkybuild.
  375. do
  376. ONEFULLSIZE=`stat -c %s /mnt/data${ONEPUPFILE}`
  377. ONEORIGSIZE=`expr $ONEFULLSIZE - 32` #110422
  378. ONEIDSTRING="`dd if=/mnt/data${ONEPUPFILE} bs=1 skip=${ONEORIGSIZE} 2>/dev/null | sed -e 's%[^a-zA-Z0-9\.]%%g'`"
  379. if [ "$ONEIDSTRING" = "$IDSTRING" ];then
  380. VMLINUZ="`basename $ONEPUPFILE`"
  381. PDEV1="$ONEDEV"
  382. DEV1FS="$ONEFS"
  383. BOOTDRV="$ONEDRV" #exs: sda sr0
  384. PSUBDIR="`dirname $ONEPUPFILE`" #ex: /puppies/wary071
  385. [ "$PSUBDIR" = "/" ] && PSUBDIR=""
  386. #SAVEMARK: BootFlash utility can create 128MB boot partition, 2nd partition for pupsave...
  387. #101020 if pup installed in a subdir, look there for SAVEMARK...
  388. [ -f /mnt/data${PSUBDIR}/SAVEMARK ] && PSAVEMARK="`cat /mnt/data${PSUBDIR}/SAVEMARK`" #partition no. that has or will-have ${DISTRO_FILE_PREFIX}save.2fs. 101020
  389. [ "$PSAVEMARK" ] && SAVEPART="${BOOTDRV}${PSAVEMARK}" #note, PSAVEMARK could also be a kernel boot param. ex: sda2
  390. [ "$PSUBDIR" = "" ] && [ -f /mnt/data/etc/DISTRO_SPECS ] && DEV1PUP='yes' #flag full installation. 101103 ignore if vmlinuz in a subdir.
  391. if [ "`echo -n "$BOOTDRV" | grep -f /tmp/OPTICALDRIVES0`" = "" ];then #110205 test not optical.
  392. IGNORE='optical' #refinement, if vmlinuz not on optical drive, don't probe it. 110126
  393. else #booting on optical, is it multisession?...
  394. FND_MULTIFOLDER="`find /mnt/data -maxdepth 1 -xdev -type d -name 20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9]-[0-9][0-9] | grep -v ' ' | sed -e 's%^/mnt/data%%' | head -n 1`"
  395. if [ "$FND_MULTIFOLDER" ];then #multisession cd/dvd
  396. if [ "$PRAMONLY" != "yes" ];then
  397. PUPMODE=72 #64+8, will become 77.
  398. PUPSAVE="${ONEDEV},${ONEFS},${FND_MULTIFOLDER}"
  399. fi
  400. fi
  401. fi
  402. fi
  403. done
  404. fi
  405. fi
  406. [ "$PSUBDIR" ] && SEARCHDEPTH=1
  407. if [ "$PUPSFS" = "" ];then
  408. FND_FILES="`find /mnt/data${PSUBDIR} -maxdepth ${SEARCHDEPTH} -xdev -type f -iname ${PUPXXXSFS} | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  409. for ONEPUPFILE in $FND_FILES
  410. do
  411. if [ "$NAMETYPE" = "traditional" ];then
  412. ONEIDSTRING="$IDSTRING" #found file based on it's name only.
  413. else
  414. ONEFULLSIZE=`stat -c %s /mnt/data${ONEPUPFILE}`
  415. ONEORIGSIZE=`expr $ONEFULLSIZE - 32`
  416. ONEIDSTRING="`dd if=/mnt/data${ONEPUPFILE} bs=1 skip=${ONEORIGSIZE} 2>/dev/null | sed -e 's%[^a-zA-Z0-9\.]%%g'`"
  417. fi
  418. if [ "$ONEIDSTRING" = "$IDSTRING" ];then
  419. PUPSFS="${ONEDEV},${ONEFS},${ONEPUPFILE}"
  420. break
  421. fi
  422. done
  423. fi
  424. if [ "$ZDRV" = "" ];then
  425. FND_FILES="`find /mnt/data${PSUBDIR} -maxdepth ${SEARCHDEPTH} -xdev -type f -iname ${ZDRVSFS} | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  426. for ONEPUPFILE in $FND_FILES
  427. do
  428. if [ "$NAMETYPE" = "traditional" ];then
  429. ONEIDSTRING="$IDSTRING" #found file based on it's name only.
  430. else
  431. ONEFULLSIZE=`stat -c %s /mnt/data${ONEPUPFILE}`
  432. ONEORIGSIZE=`expr $ONEFULLSIZE - 32` #110422
  433. ONEIDSTRING="`dd if=/mnt/data${ONEPUPFILE} bs=1 skip=${ONEORIGSIZE} 2>/dev/null | sed -e 's%[^a-zA-Z0-9\.]%%g'`"
  434. fi
  435. if [ "$ONEIDSTRING" = "$IDSTRING" ];then
  436. ZDRV="${ONEDEV},${ONEFS},${ONEPUPFILE}"
  437. break
  438. fi
  439. done
  440. fi
  441. if [ "$ADRV" = "" ];then
  442. FND_FILES="`find /mnt/data${PSUBDIR} -maxdepth ${SEARCHDEPTH} -xdev -type f -iname ${ADRVSFS} | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  443. for ONEPUPFILE in $FND_FILES
  444. do
  445. if [ "$NAMETYPE" = "traditional" ];then
  446. ONEIDSTRING="$IDSTRING" #found file based on it's name only.
  447. else
  448. ONEFULLSIZE=`stat -c %s /mnt/data${ONEPUPFILE}`
  449. ONEORIGSIZE=`expr $ONEFULLSIZE - 32` #110422
  450. ONEIDSTRING="`dd if=/mnt/data${ONEPUPFILE} bs=1 skip=${ONEORIGSIZE} 2>/dev/null | sed -e 's%[^a-zA-Z0-9\.]%%g'`"
  451. fi
  452. if [ "$ONEIDSTRING" = "$IDSTRING" ];then
  453. ADRV="${ONEDEV},${ONEFS},${ONEPUPFILE}"
  454. echo -n " adrive" > /dev/console
  455. break
  456. fi
  457. done
  458. fi
  459. if [ "$YDRV" = "" ];then
  460. FND_FILES="`find /mnt/data${PSUBDIR} -maxdepth ${SEARCHDEPTH} -xdev -type f -iname ${YDRVSFS} | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  461. for ONEPUPFILE in $FND_FILES
  462. do
  463. if [ "$NAMETYPE" = "traditional" ];then
  464. ONEIDSTRING="$IDSTRING" #found file based on it's name only.
  465. else
  466. ONEFULLSIZE=`stat -c %s /mnt/data${ONEPUPFILE}`
  467. ONEORIGSIZE=`expr $ONEFULLSIZE - 32` #110422
  468. ONEIDSTRING="`dd if=/mnt/data${ONEPUPFILE} bs=1 skip=${ONEORIGSIZE} 2>/dev/null | sed -e 's%[^a-zA-Z0-9\.]%%g'`"
  469. fi
  470. if [ "$ONEIDSTRING" = "$IDSTRING" ];then
  471. YDRV="${ONEDEV},${ONEFS},${ONEPUPFILE}"
  472. echo -n " ydrive" > /dev/console
  473. break
  474. fi
  475. done
  476. fi
  477. fi #101103 moved up.
  478. echo " IGNORE=$IGNORE PSUBDIR=$PSUBDIR SAVEPART=$SAVEPART VMLINUZ=$VMLINUZ PDEV1=$PDEV1 PUPSFS=$PUPSFS" >> /tmp/puppy-file-search.log #101127 for debugging.
  479. FND_PUPSAVES=""
  480. ONEFS_IS_LINUX=""
  481. case $ONEFS in
  482. ext2|ext3|ext4|reiserfs|minix|f2fs) ONEFS_IS_LINUX="Y" ;;
  483. esac
  484. if [ "$SAVEPART" ];then #see SAVEMARK above. 101103 modified logic.
  485. if [ "$SAVEPART" = "$ONEDEV" ];then
  486. if [ "$PSUBDIR" ];then
  487. #look in same subdir, then in '/' (maxdepth=1)...
  488. if [ -d /mnt/data${PSUBDIR} ]; then
  489. [ "$ONEFS_IS_LINUX" = "Y" ] && FND_PUPSAVES="`find /mnt/data${PSUBDIR} -maxdepth 1 -xdev -type d -iname ${DISTRO_FILE_PREFIX}save'*' | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  490. FND_PUPSAVES="${FND_PUPSAVES}`find /mnt/data${PSUBDIR} -maxdepth 1 -xdev -type f -iname ${DISTRO_FILE_PREFIX}save*.[234]fs | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  491. fi
  492. else
  493. [ "$ONEFS_IS_LINUX" = "Y" ] && FND_PUPSAVES="`find /mnt/data -maxdepth ${SEARCHDEPTH} -xdev -type d -iname ${DISTRO_FILE_PREFIX}save'*' | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  494. FND_PUPSAVES="${FND_PUPSAVES}`find /mnt/data -maxdepth ${SEARCHDEPTH} -xdev -type f -iname ${DISTRO_FILE_PREFIX}save*.[234]fs | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  495. [ -f /mnt/data/etc/rc.d/PUPSTATE ] && DEV2PUP="${ONEDEV}|${ONEFS}" #full save to different partition than boot. 100919 101103 ignore if installed in a subdir.
  496. fi
  497. fi
  498. else #101020
  499. if [ "$PSUBDIR" ];then
  500. #look in same subdir, then in '/' (maxdepth=1)...
  501. if [ -d /mnt/data${PSUBDIR} ]; then
  502. [ "$ONEFS_IS_LINUX" = "Y" ] && FND_PUPSAVES="`find /mnt/data${PSUBDIR} -maxdepth 1 -xdev -type d -iname ${DISTRO_FILE_PREFIX}save'*' | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  503. FND_PUPSAVES="${FND_PUPSAVES}`find /mnt/data${PSUBDIR} -maxdepth 1 -xdev -type f -iname ${DISTRO_FILE_PREFIX}save*.[234]fs | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  504. fi
  505. else
  506. [ "$ONEFS_IS_LINUX" = "Y" ] && FND_PUPSAVES="`find /mnt/data -maxdepth ${SEARCHDEPTH} -xdev -type d -iname ${DISTRO_FILE_PREFIX}save'*' | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  507. FND_PUPSAVES="${FND_PUPSAVES}`find /mnt/data -maxdepth ${SEARCHDEPTH} -xdev -type f -iname ${DISTRO_FILE_PREFIX}save*.[234]fs | grep -v ' ' | sed -e 's%^/mnt/data%%' | tr '\n' ' '`"
  508. fi
  509. fi
  510. [ "$FND_PUPSAVES" ] && echo "$ONEDEV $ONEFS $FND_PUPSAVES" >> /tmp/PUPSAVES
  511. #130513 if we find a rw f.s., create pupdesk.flg. only needed in PUPMODE=5, see /usr/sbin/quicksetup.
  512. if [ "$PRAMONLY" != "yes" -a $PUPDESKFLG -eq 1 ];then #130514 exclude. 130515
  513. if [ ! -f /tmp/RWPART ];then
  514. if [ "$LINUXFS" ];then
  515. RWPARTFLG=''
  516. case $ONEFS in
  517. ext2|ext3|ext4|reiserfs|minix|f2fs) RWPARTFLG="$(cat /proc/mounts | grep "/dev/${ONEDEV} " | grep ' rw,')" ;;
  518. esac
  519. else
  520. RWPARTFLG="$(cat /proc/mounts | grep "/dev/${ONEDEV} " | grep ' rw,')"
  521. fi
  522. [ "$RWPARTFLG" ] && echo -n "${ONEDEV}|${ONEFS}" > /tmp/RWPART #where we intend to create pupdesk.flg, see further down.
  523. fi
  524. fi
  525. #fix any improper shutdowns... fsckme.flg format: sda7,ext3,[/pupsave.2fs] (see rc.shutdown)
  526. FSCKME=""
  527. [ -f /mnt/data/fsckme.flg ] && FSCKME="`cat /mnt/data/fsckme.flg | tr ',' ' ' | tr '\n' ' '`" \
  528. && DEEPFSCK="yes"
  529. rm -f /mnt/data/fsckme.flg
  530. umntfunc /mnt/data
  531. [ "$FSCKME" ] && fsckme_func $FSCKME
  532. done
  533. } #search_func
  534. resize_pupsave_func() { #131225
  535. rm -f /mnt/dev_save/pupsaveresizenew.txt
  536. echo > /dev/console
  537. echo -n "Increasing $PUPSAVEFILE by $KILOBIG Kbytes, please wait..." >/dev/console
  538. dd if=/dev/zero bs=1024 count=$KILOBIG >> /mnt/dev_save$PUPSAVEFILEX #131225
  539. sync
  540. }
  541. fsck_pupsave_func() {
  542. e2fsck -y -f $1
  543. resize2fs -pf $1 #no size, will fill all of file.
  544. sync
  545. check_status 0 #note, e2fsck gives an error even though it works. v2.21 maybe okay now.
  546. echo -n "...continuing with loading $PUPSAVEFILE..." > /dev/console
  547. }
  548. mnt_enc_pupsave_func() {
  549. echo >/dev/console
  550. echo "NOTICE: As you type your password nothing will be displayed on the screen." >/dev/console
  551. echo "This is a security measure. Just type it in then press ENTER key..." >/dev/console
  552. echo -e "\\033[1;36m" >/dev/console #aqua-blue
  553. echo -n "Password: " >/dev/console
  554. echo -en "\\033[0;39m" >/dev/console
  555. read -s MYPASS
  556. if [ "$CRYPTO" = "-e aes" ];then #v3.98
  557. echo "$MYPASS" | losetup -p 0 -e aes /dev/loop1 /mnt/dev_save$PUPSAVEFILE
  558. else
  559. #losetup does not accept -p param for xor encryption... may not work...
  560. echo "$MYPASS" | losetup -p 0 $CRYPTO /dev/loop1 /mnt/dev_save$PUPSAVEFILE
  561. fi
  562. }
  563. #pmedia= usbflash|usbhd|usbcd|ataflash|atahd|atacd|atazip|scsihd|scsicd|cd
  564. [ $pmedia ] && PMEDIA=$pmedia #boot parameter, broad category of boot media. ex: cd.
  565. [ $pdev1 ] && PDEV1=$pdev1 #boot parameter, partition have booted off. ex: hda3
  566. [ $psubdir ] && PSUBDIR=$psubdir #boot parameter, directory for puppy files. ex: puppy220
  567. [ $pkeys ] && PKEYS=$pkeys #boot parameter, keyboard layout w476
  568. [ $psavemark ] && PSAVEMARK=$psavemark #100913 partition number that has/will-have save-file.
  569. [ $PSUBDIR ] && [ "`echo -n "$PSUBDIR" | cut -c 1`" != "/" ] && PSUBDIR="/${PSUBDIR}" #add leading /.
  570. #100915 requested by technosaurus (formats get changed further down)...
  571. [ $pupsfs ] && PUPSFS=$pupsfs #format partition:<path><filename> ex: sda2:/wary071/wary_071.sfs
  572. [ $zdrv ] && ZDRV=$zdrv #ex: sda2:/wary071/zdrv_071.sfs
  573. [ $adrv ] && ADRV=$adrv
  574. [ $ydrv ] && YDRV=$ydrv
  575. [ $underdog ] && UNDERDOG=$underdog #120130 specify partition for Underdog Linux (refer also underdog.lnx).
  576. #now supporting a boot menu...
  577. RDSH=""
  578. if [ "$pfix" ];then
  579. for ONEFIX in `echo -n "$pfix" | tr ',' ' '`
  580. do
  581. case $ONEFIX in
  582. ram) PRAMONLY="yes";; #run in ram only (do not load ${DISTRO_FILE_PREFIX}save).
  583. rdsh) RDSH="yes";; #exit to shell in initial ramdisk.
  584. rdsh0) RDSH="0";; #drop out early, before loading drivers.
  585. rdsh6) RDSH="6";; #w091027 drop out just before mount layerfs.
  586. nox) PNOX="yes";; #do not start X.
  587. clean) PCLEAN="yes";; #force version upgrade and cleanup.
  588. purge) PPURGE="yes";; #radical cleanup for broken system.
  589. copy) PCOPY="yes";; #copy .sfs files into ram.
  590. nocopy) PNOCOPY="yes";; #do not copy .sfs files into ram (default is copy if enough ram).
  591. fsck) PFSCK="yes";; #do a fsck of ${DISTRO_FILE_PREFIX}save file.
  592. [0-9]*) PIGNORELAST=$ONEFIX;; #blacklist last $ONEFIX folders (multisession).
  593. esac
  594. done
  595. fi
  596. #for backwards naming compatibility... ex: idehd becomes atahd 101021: atacd,scsicd,usbcd to become just cd...
  597. PMEDIA="`echo -n "$PMEDIA" | sed -e 's%ide%ata%' -e 's%sata%ata%' -e 's%.*cd$%cd%'`"
  598. clear #clear the screen.
  599. [ ! "$LOGLEVEL" ] && exec 1>/tmp/bootinit.log 2>&1 #remove o/p from console. v2.22 loglevel added.
  600. export TZ='XXX-23' #100318 imaginary place right around the world east of Greenwich.
  601. #...i think that this will give the most delayed time, so any file operations
  602. #will not result in a future date after the correct time is set in the main puppy f.s.
  603. #ref: http://www.gnu.org/s/libc/manual/html_node/TZ-Variable.html
  604. #100427 crap, despite the help inside the hwclock applet, it doesn't accept long-options...
  605. /bin/hwclock -s -l #set system time (based on hw clock set to local time).
  606. #does this initrd have all the zdrv components inside it?...
  607. ZDRVINIT='no'
  608. [ `cat /lib/modules/$KERNELVER/modules.dep | wc -l` -gt 200 ] && ZDRVINIT='yes'
  609. #120216 /PUPPYKEYMAP inserted in initrd by quicksetup (in future, by Woof too)...
  610. FONTMAP=""
  611. [ -f /PUPPYKEYMAP ] && [ ! "$PKEYS" ] && PKEYS="`cat /PUPPYKEYMAP`" #allow kernel boot param to override.
  612. if [ "$PLANG" ];then
  613. if [ ! "$PKEYS" ];then
  614. #try to set PKEYS to match the language. first 2 letters of PLANG...
  615. PKEYS=${PLANG:0:2} #rough as guts, assign first 2 chars of PLANG to PKEYS.
  616. case $PLANG in
  617. en*) PKEYS=us ;;
  618. esac
  619. fi
  620. #120216 L18L suggests load these, instead of what is below...
  621. case $PLANG in
  622. en*) echo ;;
  623. ar*|iw*) #L18L no Greek
  624. setfont /lib/consolefonts/LatArCyrHeb-16.psfu.gz -C /dev/tty1
  625. FONTMAP='LatArCyrHeb-16.psfu'
  626. ;;
  627. ru*) #vkvkvk for ru
  628. zcat /lib/consolefonts/ter-u16n.psf.gz | loadfont
  629. FONTMAP='ter-u16n.psf'
  630. ;;
  631. *) #L18L All European languages; new default ?!
  632. zcat /lib/consolefonts/LatGrkCyr-8x16.psfu.gz | loadfont
  633. FONTMAP='LatGrkCyr-8x16.psfu'
  634. ;;
  635. esac
  636. fi
  637. #091122 load keyboard layout if PKEYS boot param...
  638. STATUS=0
  639. VFAT_OUT_PARAM='shortname=mixed,quiet,utf8' #140102 rodin.s: added utf8 for flash drive to be mounted with utf-8 if boot is done from flash drive
  640. CODEPAGE=""
  641. KMAP=""
  642. if [ "$PKEYS" ];then
  643. if [ ! -f /lib/keymaps/${PKEYS}.gz ];then
  644. PKEYS="`ls -1 /lib/keymaps/${PKEYS}*.gz | head -n 1 | rev | cut -f 1 -d '/' | cut -f 2 -d '.' | rev`"
  645. fi
  646. if [ -f /lib/keymaps/${PKEYS}.gz ];then
  647. echo "Loading '${PKEYS}' keyboard layout..." >/dev/console
  648. KMAP="$PKEYS"
  649. zcat /lib/keymaps/${PKEYS}.gz | loadkmap ; STATUS=$(($STATUS + $?))
  650. case $PKEYS in #note, same code in /etc/rc.d/rc.country, /usr/sbin/input-wizard and init.
  651. de*|be*|br*|dk*|es*|fi*|fr*|it*|no*|se*|pt*)
  652. [ ! "$PLANG" ] && FONTMAP="lat1-12.psfu" #120216
  653. CODEPAGE="850"
  654. VFAT_OUT_PARAM="$OUT_PARAM"',codepage=850'
  655. ;;
  656. cz*|hu*|pl*|ro*|sk*|croat*|slovene*)
  657. [ ! "$PLANG" ] && FONTMAP="lat2-12.psfu" #120216
  658. CODEPAGE="852"
  659. VFAT_OUT_PARAM="$OUT_PARAM"',codepage=852,iocharset=iso8859-2'
  660. ;;
  661. esac
  662. if [ ! "$PLANG" ];then #120216 old behaviour.
  663. if [ "$FONTMAP" ];then #100520 fix syntax error...
  664. zcat /lib/consolefonts/${FONTMAP}.gz | loadfont
  665. STATUS=$(($STATUS + $?))
  666. fi
  667. fi
  668. else
  669. STATUS=1
  670. fi
  671. check_status $STATUS
  672. fi
  673. [ "$RDSH" = "0" ] && exec /bin/sh >/dev/console 2>&1 #w091222
  674. ###################LOAD MODULES TO ACCESS DRIVES#####################
  675. echo -n "Loading drivers needed to access disk drives" > /dev/console #STEP ONE
  676. #110126 define ATADRIVES as all internal ide/pata/sata (and mmc) drives (not usb), except optical...
  677. #110710 rewritten to handle kernel with usb driver built-in...
  678. ALLDRVS0="`find /sys/block -maxdepth 1 -name 'mmc*' -o -name 'sd*' -o -name 'sr*' | xargs -l readlink 2>/dev/null | grep -v '/usb[0-9]' | rev | cut -f 1 -d '/' | rev`" #all *except* usb!
  679. ALLDRVS="`echo "$ALLDRVS0" | tr '\n' ' '`" #all *except* usb!
  680. [ "$ALLDRVS" = " " ] && ALLDRVS=""
  681. ATADRIVES="`echo "$ALLDRVS0" | grep -v '^sr' | tr '\n' ' '`"
  682. [ "$ATADRIVES" = " " ] && ATADRIVES=""
  683. ATAOPTICALDRIVES="`echo "$ALLDRVS0" | grep '^sr' | tr '\n' ' '`"
  684. [ "$ATAOPTICALDRIVES" = " " ] && ATAOPTICALDRIVES=""
  685. if [ -e /proc/ide ];then
  686. for ONEIDE in `ls -1 /proc/ide | grep '^hd' | tr '\n' ' '`
  687. do
  688. ALLDRVS="${ALLDRVS}${ONEIDE} "
  689. if [ "`cat /proc/ide/${ONEIDE}/media`" = "cdrom" ];then
  690. ATAOPTICALDRIVES="${ATAOPTICALDRIVES}${ONEIDE} "
  691. else
  692. ATADRIVES="${ATADRIVES}${ONEIDE} "
  693. fi
  694. done
  695. ALLDRVS0="`echo -n "$ALLDRVS" | tr ' ' '\n'`"
  696. fi
  697. ATADRIVES0="`echo -n "$ATADRIVES" | tr ' ' '\n'`"
  698. touch /tmp/ATADRIVES0 #110509 fix for LF only messes up grep later.
  699. [ "$ATADRIVES" != "" ] && echo "$ATADRIVES0" > /tmp/ATADRIVES0 #110205 broken busybox grep -F. 110509
  700. ATAOPTICALDRIVES0="`echo -n "$ATAOPTICALDRIVES" | tr ' ' '\n'`"
  701. touch /tmp/ALLDRVS0
  702. [ "$ALLDRVS" ] && echo "$ALLDRVS0" > /tmp/ALLDRVS0 #all drives *except* usb.
  703. PCPARTSALL="`probepart_init -k`"
  704. PCPARTS0="`echo "$PCPARTSALL" | grep '^/dev/' | cut -f 1-2 -d '|' | grep -E 'f2fs|udf|iso9660|ext2|ext3|ext4|reiserfs|msdos|vfat|minix|ntfs' | sed -e 's%/dev/%%'`" #ex: sda1|vfat 130128 add udf. 130216 add f2fs.
  705. LESSPARTS0="$PCPARTS0"
  706. #120328 could have iso9660 f.s. booting off a non-optical drive (see BootFlash). exclude /dev/mmc ...
  707. OPTICALDRIVES0="`echo "$PCPARTS0" | grep -E 'iso9660|udf' | grep -v '^mmc' | cut -f 1 -d '|'`" #ex: sr0 130128 add udf.
  708. touch /tmp/OPTICALDRIVES0 #110509 fix for using with grep.
  709. [ "$OPTICALDRIVES0" != "" ] && echo "$OPTICALDRIVES0" > /tmp/OPTICALDRIVES0 #110509 fix
  710. echo "ALLDRVS=$ALLDRVS " >> /tmp/puppy-file-search.log #for debugging.
  711. if [ "`lsmod | grep -E '^uhci|^ohci|^ehci'`" != "" ];then
  712. /sbin/wait4usb_classic & #110425
  713. else
  714. /sbin/wait4usb & #110710 kernel has builtin hid and usb drivers, and without or with my usb-storage patch.
  715. fi
  716. check_status 0 #END STEP ONE
  717. ##############END MODULE LOADING TO ACCESS DRIVES####################
  718. #######################FINDING PUPPY FILES###########################
  719. echo -n "Searching for Puppy files..." > /dev/console #STEP TWO
  720. PUPMODE=0
  721. touch /tmp/PUPSAVES
  722. KERNELNAME='vmlinuz'
  723. #100915 technosaurus recommendation (see above)...
  724. if [ "$PUPSFS" ];then
  725. DEV="`echo "$PUPSFS" | cut -f 1 -d ':'`"
  726. FS="`echo "$PCPARTS0" | grep "${DEV}|" | cut -f 2 -d '|'`"
  727. SPEC="`echo -n "$PUPSFS" | cut -f 2 -d ':'`"
  728. PUPXXXSFS="`basename $SPEC`"
  729. [ "$PSUBDIR" = "" ] && PSUBDIR="`dirname $SPEC`"
  730. [ "$PSUBDIR" = "/" ] && PSUBDIR=""
  731. PUPSFS="${DEV},${FS},${SPEC}"
  732. LESSPARTS0="${DEV}|${FS}" #110425
  733. fi
  734. if [ "$ZDRV" ];then
  735. DEV="`echo "$ZDRV" | cut -f 1 -d ':'`"
  736. FS="`echo "$PCPARTS0" | grep "${DEV}|" | cut -f 2 -d '|'`"
  737. SPEC="`echo -n "$ZDRV" | cut -f 2 -d ':'`"
  738. ZDRVSFS="`basename $SPEC`"
  739. ZDRV="${DEV},${FS},${SPEC}"
  740. fi
  741. if [ "$ADRV" ];then
  742. DEV="`echo "$ADRV" | cut -f 1 -d ':'`"
  743. FS="`echo "$PCPARTS0" | grep "${DEV}|" | cut -f 2 -d '|'`"
  744. SPEC="`echo -n "$ADRV" | cut -f 2 -d ':'`"
  745. ADRVSFS="`basename $SPEC`"
  746. ADRV="${DEV},${FS},${SPEC}"
  747. fi
  748. if [ "$YDRV" ];then
  749. DEV="`echo "$YDRV" | cut -f 1 -d ':'`"
  750. FS="`echo "$PCPARTS0" | grep "${DEV}|" | cut -f 2 -d '|'`"
  751. SPEC="`echo -n "$YDRV" | cut -f 2 -d ':'`"
  752. YDRVSFS="`basename $SPEC`"
  753. YDRV="${DEV},${FS},${SPEC}"
  754. fi
  755. #first look inside initrd...
  756. [ -f /${PUPXXXSFS} ] && PUPSFS="rootfs,rootfs,/${PUPXXXSFS}"
  757. [ -f /${ZDRVSFS} ] && ZDRV="rootfs,rootfs,/${ZDRVSFS}"
  758. [ -f /${ADRVSFS} ] && ADRV="rootfs,rootfs,/${ADRVSFS}"
  759. [ -f /${YDRVSFS} ] && YDRV="rootfs,rootfs,/${YDRVSFS}"
  760. search_func ata #110425
  761. while [ ! -e /tmp/flag-usb-ready ];do #110710 wait for usb process to complete.
  762. usleep 250000 #microseconds
  763. done
  764. if [ -s /tmp/flag-usb-ready ];then #110710 has stuff in it if usb drives exist.
  765. ALLDRVS="`ls -1 /sys/block | grep -E '^scd|^sd|^mmc|^sr' | tr '\n' ' '`" #110204
  766. [ "$ALLDRVS" = " " ] && ALLDRVS=""
  767. [ -e /proc/ide ] && ALLDRVS="${ALLDRVS}`ls -1 /proc/ide | grep '^hd' | tr '\n' ' '`" #110204 ex: sda sdb sr0 hda
  768. ALLDRVS0="`echo -n "$ALLDRVS" | tr -s ' ' | tr ' ' '\n'`" #110205
  769. echo "$ALLDRVS0" > /tmp/ALLDRVS0 #110205
  770. PCPARTSALL="`probepart_init -k`"
  771. PCPARTS0="`echo "$PCPARTSALL" | grep '^/dev/' | cut -f 1-2 -d '|' | grep -E 'f2fs|udf|iso9660|ext2|ext3|ext4|reiserfs|msdos|vfat|minix|ntfs' | sed -e 's%/dev/%%'`" #ex: sda1|vfat 130128 add udf. 130216 add f2fs.
  772. LESSPARTS0="$PCPARTS0"
  773. #120328 could have iso9660 f.s. booting off a usb flash/hard drive (see BootFlash). exclude /dev/sd and /dev/mmc ...
  774. OPTICALDRIVES0="`echo "$PCPARTS0" | grep -E 'iso9660|udf' | grep -v -E '^sd|^mmc' | cut -f 1 -d '|'`" #ex: sr0 130128 add udf.
  775. touch /tmp/OPTICALDRIVES0 #fix
  776. [ "$OPTICALDRIVES0" ] && echo "$OPTICALDRIVES0" > /tmp/OPTICALDRIVES0 #fix
  777. echo "ALLDRVS=$ALLDRVS " >> /tmp/puppy-file-search.log
  778. PUPSFS_OPT=""
  779. if [ "$PUPSFS" ]; then
  780. FS=$(echo $PUPSFS | cut -s -f2 -d',')
  781. echo $FS | grep -q -E 'iso9660|udf' && PUPSFS_OPT=$PUPSFS && PUPSFS=""
  782. fi
  783. if [ "$VMLINUZ" = "" -o "$PUPSFS" = "" -o "$SAVEPART" = "" ];then
  784. search_func usb
  785. fi
  786. [ "$PUPSFS" ] || PUPSFS=$PUPSFS_OPT
  787. fi
  788. cp -f /tmp/PUPSAVES /tmp/PUPSAVES-complete #101127 for debugging.
  789. #110116 jamesbond: for netboot, PDEV1 is empty, so don't want to fail here...
  790. [ "$PUPSFS" = "" ] && DROPOUT="${PUPXXXSFS}"
  791. if [ "$DROPOUT" ];then
  792. echo -en "\\033[1;31m" >/dev/console #31=red
  793. echo -n "${DROPOUT} not found. Dropping out to initial-ramdisk console..." >/dev/console
  794. /bin/echo -e "\\033[0;39m" >/dev/console
  795. exec /bin/sh >/dev/console 2>&1
  796. fi
  797. if [ "$VMLINUZ" = "" ];then #101103 maybe network boot, no local vmlinuz
  798. #well, to get this far, PDEV1 has been supplied.
  799. #110116 jamesbond,shinobar: no, for netboot, PDEV1 is empty, add test for $PDEV1...
  800. [ "$DEV1FS" = "" -a "$PDEV1" != "" ] && DEV1FS="`echo "$LESSPARTS0" | grep "${PDEV1}|" | cut -f 2 -d '|'`"
  801. BOOTDRV="`echo -n "$PDEV1" | grep -o -f /tmp/ALLDRVS0`" #110205 ex: sda1 becomes sda.
  802. VMLINUZ='vmlinuz'
  803. fi
  804. PUPMODE=`expr $PUPMODE + 4` #puppy.sfs (PUPXXXSFS) exists.
  805. #if pupsave file not already found, choose it here...
  806. if [ ! "$PUPSAVE" ];then
  807. if [ "$PRAMONLY" != "yes" ];then
  808. if [ "$IGNORE" = "optical" ];then #narrow it down...
  809. #not booting off optical drive.
  810. grep "${PSUBDIR}/" /tmp/PUPSAVES > /tmp/PUPSAVES2 #note: need this as above probing may have got some invalid hits.
  811. if [ "$SAVEPART" ];then #set by file SAVEMARK, see above.
  812. grep "${SAVEPART} " /tmp/PUPSAVES2 > /tmp/PUPSAVES
  813. else #it must be in the boot partition...
  814. grep "${PDEV1} " /tmp/PUPSAVES2 > /tmp/PUPSAVES
  815. fi
  816. fi
  817. if [ -s /tmp/PUPSAVES ];then #100922
  818. touch /tmp/PUPSAVE2SFSS #so does not spit any erroros if not there
  819. cat /tmp/PUPSAVES |
  820. while read ONELINE
  821. do
  822. ONEDEV="`echo -n "$ONELINE" | cut -f 1 -d ' '`"
  823. ONEFS="`echo -n "$ONELINE" | cut -f 2 -d ' '`"
  824. ONEPUPSAVES="`echo -n "$ONELINE" | cut -f 3-99 -d ' '`"
  825. for ONEPUPSAVE in $ONEPUPSAVES
  826. do
  827. echo "${ONEDEV},${ONEFS},${ONEPUPSAVE}" >> /tmp/PUPSAVE2SFSS
  828. done
  829. done
  830. NUMPUPSAVES=`cat /tmp/PUPSAVE2SFSS | wc -l`
  831. if [ $NUMPUPSAVES -eq 1 ];then
  832. PUPSAVE="`cat /tmp/PUPSAVE2SFSS`"
  833. else
  834. CNTSAVE=1
  835. echo -e "\\033[1;36m" >/dev/console #36=aquablue
  836. echo "Type a number to choose which personal file to use:" > /dev/console
  837. echo "0 none" > /dev/console
  838. for ONECHOICE in `cat /tmp/PUPSAVE2SFSS | tr '\n' ' '`
  839. do
  840. ONEFILE="`echo -n "$ONECHOICE" | cut -f 3 -d ','`"
  841. ONEPART="`echo -n "$ONECHOICE" | cut -f 1 -d ','`"
  842. echo -e "${CNTSAVE} ${ONEPART}\\033[10G${ONEFILE}" > /dev/console #10 means move to that column.
  843. CNTSAVE=`expr $CNTSAVE + 1`
  844. done
  845. echo -en "\\033[0;39m" >/dev/console
  846. read NUMSAVE
  847. [ $NUMSAVE -ne 0 ] && PUPSAVE="`cat /tmp/PUPSAVE2SFSS | tr '\n' ' ' | cut -f $NUMSAVE -d ' '`"
  848. fi
  849. fi
  850. fi
  851. [ "$PUPSAVE" ] && PUPMODE=`expr $PUPMODE + 8`
  852. fi
  853. #refine the PUPMODE...
  854. #if a ${DISTRO_FILE_PREFIX}save.2fs was not found, perhaps boot partition has a full install of puppy...
  855. [ ! "$PUPSAVE" ] && [ "$DEV1PUP" = "yes" -o "$DEV2PUP" != "" ] && PUPMODE=`expr $PUPMODE + 2`
  856. #do we want a tmpfs top layered-fs layer? (set bit-0 of PUPMODE)...
  857. #only if ${DISTRO_FILE_PREFIX}save.2fs (or PDEV1 for DEV1PUP=yes, or first boot) on a flash drive, usb or internal...
  858. case $PUPMODE in
  859. 4) #so far have only got a puppy.sfs. this is first boot or pfix=ram.
  860. PUPMODE=5 #`expr $PUPMODE + 1` #yes, want tmpfs top layer (PUPMODE=5).
  861. ;;
  862. 6) #4=puppy.sfs found, 2=session saved to entire partition. total=6
  863. #note: session saved in boot partition, or other specified by SAVEMARK (DEV2PUP).
  864. DRVSAVE="`echo -n "$PDEV1" | sed -e 's/[0-9]*$//' -e 's/p$//'`" #ex: sda 110126 mmcblk0p1 becomes mmcblk0
  865. REMOVABLEDRVSAVE="`cat /sys/block/$DRVSAVE/removable`"
  866. [ "$REMOVABLEDRVSAVE" = "1" -a "$PMEDIA" != "usbhd" ] && PUPMODE=7 #110116 shinobar.
  867. #v3.96 Classmate laptop has internal usb flash, so really want the tmpfs layer...
  868. # puppyinstaller created 'pmedia=usbflash' for the extlinux full hd install...
  869. [ "$PMEDIA" = "usbflash" ] && PUPMODE=7
  870. ;;
  871. 12) #4=puppy.sfs found, 8=${DISTRO_FILE_PREFIX}save.2fs found. total=12
  872. DRVSAVE="`echo -n "$PUPSAVE" | cut -f 1 -d ',' | sed -e 's/[0-9]*$//' -e 's/p$//'`" #ex: sda 110126 mmcblk0p1 becomes mmcblk0
  873. REMOVABLEDRVSAVE="`cat /sys/block/$DRVSAVE/removable`"
  874. [ "$REMOVABLEDRVSAVE" = "1" -a "$PMEDIA" != "usbhd" ] && PUPMODE=13 #110116 shinobar.
  875. [ "$PMEDIA" = "usbflash" ] && PUPMODE=13 #v404 fix classmate, with internal usb flash.
  876. [ "$PMEDIA" = "ataflash" ] && PUPMODE=13 #w019 constrain writes to internal flash drv.
  877. ;;
  878. 76) #v3.01 64+8+4 multisession cd.
  879. PUPMODE=77 #yes, want tmpfs top layer.
  880. ;;
  881. esac
  882. check_status 0
  883. ########################END FINDING PUPPY FILES############################
  884. ##########################LOADING PUPPY FILES###########################
  885. RAMSIZE=`free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 2 -d ' '` #total physical ram (less shared video). 110405
  886. CRYPTO=""
  887. STATUS=0
  888. #decide the mount-points...
  889. #unionfs layers: RW (top) RO1 RO2 PUPMODE
  890. #full install, flash drive: tmpfs PDEV1 3
  891. #First boot (or pfix=ram): tmpfs pup_xxx.sfs 5
  892. #pup_save is a partition: PDEV1 pup_xxx.sfs 6
  893. #ditto, but flash drive: tmpfs PDEV1 pup_xxx.sfs 7
  894. #Normal running puppy: pup_save.3fs pup_xxx.sfs 12
  895. #ditto, but flash drive: tmpfs pup_save.3fs pup_xxx.sfs 13
  896. #Multisession cd/dvd: tmpfs folders(tmpfs2) pup_xxx.sfs 77
  897. CREATETMPFS="";CREATEPDEV1="";CREATEPUPXXXSFS="";CREATEPUPSAVE2FS="";CREATEFOLDERS=""
  898. case $PUPMODE in #w003 changed some save-layer to 'ro+wh' so that whiteouts files are recognised...
  899. 3) CREATETMPFS="/pup_rw";CREATEPDEV1="/pup_ro1"
  900. OLDFILESMNTPT="/pup_ro1";NEWFILESMNTPT="/pup_ro1";UMNTRW="/pup_rw=rw:";UMNTRO0="/pup_ro1=ro+wh:";;
  901. 5) CREATETMPFS="/pup_rw";CREATEPUPXXXSFS="/pup_ro2"
  902. OLDFILESMNTPT="";NEWFILESMNTPT="/pup_ro2";UMNTRW="/pup_rw=rw:";UMNTRO1="/pup_ro2=ro";;
  903. 6) CREATEPDEV1="/pup_rw";CREATEPUPXXXSFS="/pup_ro2"
  904. OLDFILESMNTPT="/pup_rw";NEWFILESMNTPT="/pup_ro2";UMNTRW="/pup_rw=rw:";UMNTRO1="/pup_ro2=ro";;
  905. 7) CREATETMPFS="/pup_rw";CREATEPDEV1="/pup_ro1";CREATEPUPXXXSFS="/pup_ro2"
  906. OLDFILESMNTPT="/pup_ro1";NEWFILESMNTPT="/pup_ro2";UMNTRW="/pup_rw=rw:";UMNTRO0="/pup_ro1=ro+wh:";UMNTRO1="/pup_ro2=ro";;
  907. 12) CREATEPUPSAVE2FS="/pup_rw";CREATEPUPXXXSFS="/pup_ro2"
  908. OLDFILESMNTPT="/pup_rw";NEWFILESMNTPT="/pup_ro2";UMNTRW="/pup_rw=rw:";UMNTRO1="/pup_ro2=ro";;
  909. 13) CREATETMPFS="/pup_rw";CREATEPUPSAVE2FS="/pup_ro1";CREATEPUPXXXSFS="/pup_ro2"
  910. OLDFILESMNTPT="/pup_ro1";NEWFILESMNTPT="/pup_ro2";UMNTRW="/pup_rw=rw:";UMNTRO0="/pup_ro1=ro+wh:";UMNTRO1="/pup_ro2=ro";;
  911. 77) CREATETMPFS="/pup_rw";CREATEFOLDERS="/pup_ro1";CREATEPUPXXXSFS="/pup_ro2"
  912. OLDFILESMNTPT="/pup_ro1";NEWFILESMNTPT="/pup_ro2";UMNTRW="/pup_rw=rw:";UMNTRO0="/pup_ro1=ro+wh:";UMNTRO1="/pup_ro2=ro";;
  913. *) RDSH="yes";; #precaution.
  914. esac
  915. if [ "$CREATEPDEV1" != "" ];then
  916. if [ "$DEV2PUP" ];then #100915
  917. DEV="`echo -n "$DEV2PUP" | cut -f 1 -d '|'`"
  918. FS="`echo -n "$DEV2PUP" | cut -f 2 -d '|'`"
  919. else #session saved to boot partition.
  920. DEV="$PDEV1"
  921. FS="$DEV1FS"
  922. fi
  923. [ "`echo "$FS" | grep 'ext[234]'`" != "" ] && echo "/dev/$DEV $CREATEPDEV1 $FS defaults 1 1" >> /etc/fstab #v2.21
  924. if [ "$PFSCK" = "yes" -a "$pdev1" = "" ]; then
  925. FSCKME="$DEV $FS"
  926. fsckme_func $FSCKME
  927. fi
  928. mount -t $FS /dev/$DEV $CREATEPDEV1
  929. check_status $?
  930. #save is not a ${DISTRO_FILE_PREFIX}save file, but a partition on a layered-fs layer...
  931. if [ "$CREATEPDEV1" = "/pup_rw" -o "$CREATEPDEV1" = "/pup_ro1" ];then #v2.20b
  932. SMNTPT="$CREATEPDEV1"
  933. PUPSAVE="$DEV,$FS,/" #deliberately left last param as only /.
  934. fi
  935. fi
  936. if [ "$CREATEPUPSAVE2FS" != "" ];then
  937. PUPSAVEDEV="`echo -n "$PUPSAVE" | cut -f 1 -d ','`"
  938. PUPSAVEFS="`echo -n "$PUPSAVE" | cut -f 2 -d ','`"
  939. PUPSAVEFILE="`echo -n "$PUPSAVE" | cut -f 3 -d ','`"
  940. #normal ${DISTRO_FILE_PREFIX}save.2fs file. just mount it from where it is...
  941. echo -n "Loading personal file $PUPSAVEFILE ($PUPSAVEDEV)..." > /dev/console
  942. [ "`echo "$PUPSAVEFS" | grep 'ext[234]'`" != "" ] && echo "/dev/$PUPSAVEDEV /mnt/dev_save $PUPSAVEFS defaults 1 1" >> /etc/fstab #v2.21
  943. mntfunc $PUPSAVEFS /dev/$PUPSAVEDEV /mnt/dev_save noatime #-t $PUPSAVEFS -o noatime /dev/$PUPSAVEDEV /mnt/dev_save
  944. if [ $? -eq 0 ];then
  945. SMNTPT="/mnt/dev_save"
  946. #is the ${DISTRO_FILE_PREFIX}save encrypted?...
  947. if [ ! "`echo "$PUPSAVEFILE" | grep '_crypt'`" = "" ];then
  948. case $PUPSAVEFILE in
  949. *cryptx*) #see /etc/rc.d/rc.shutdown.
  950. CRYPTO='-E 1' #v2.16final '-e xor' --bug, loads xor.ko which is something else.
  951. ;;
  952. *)
  953. CRYPTO='-e aes'
  954. ;;
  955. esac
  956. fi
  957. if [ -d /mnt/dev_save${PUPSAVEFILE} ]; then
  958. # Check partition if user calls for savefile check
  959. if [ "$PFSCK" = "yes" -a "$pdev1" = "" ]; then
  960. umount /mnt/dev_save
  961. MOUNTED=$(cat /proc/mounts | grep $PUPSAVEDEV |cut -f 2 -d ' ')
  962. MNTOPT=$(cat /proc/mounts | grep $PUPSAVEDEV |cut -f 4 -d ' ')
  963. umount $MOUNTED
  964. FSCKME="$(echo $PUPSAVE | tr ',' ' ')"
  965. fsckme_func $FSCKME
  966. mntfunc $PUPSAVEFS /dev/$PUPSAVEDEV $MOUNTED $MNTOPT
  967. mntfunc $PUPSAVEFS /dev/$PUPSAVEDEV /mnt/dev_save noatime
  968. fi
  969. rm -r -f "$CREATEPUPSAVE2FS"
  970. ln -s /mnt/dev_save${PUPSAVEFILE} $CREATEPUPSAVE2FS
  971. elif [ "$CRYPTO" != "" ] ; then
  972. echo "" >/dev/console
  973. echo "Mounting encrypted $PUPSAVEFILE..." > /dev/console
  974. while true; do
  975. #note, cryptoloop does not work with jounalled fs, hence have to use ext2 only.
  976. # if pupsave increase requested
  977. if [ -f /mnt/dev_save/pupsaveresizenew.txt ];then #131225 changed to function
  978. . /mnt/dev_save/pupsaveresizenew.txt
  979. if echo ${PUPSAVEFILEX}|grep -q ${PUPSAVEFILE##*/} ;then #131231
  980. if [ ! -e /bin/e2fsck ];then
  981. echo -e -n "\\033[1;31m SORRY, cannot resize ${PUPSAVEFILE} \\033[0;39m" > /dev/console #31=red
  982. rm -f /mnt/dev_save/pupsaveresizenew.txt
  983. else
  984. resize_pupsave_func #131225
  985. fi # end pupsave increase, old code removed 131225
  986. mnt_enc_pupsave_func
  987. fsck_pupsave_func /dev/loop1 #131225
  988. else
  989. mnt_enc_pupsave_func
  990. fi #131225
  991. else
  992. mnt_enc_pupsave_func
  993. fi
  994. echo "/dev/loop1 $CREATEPUPSAVE2FS ext2 defaults 1 1" >> /etc/fstab #v2.21
  995. [ "$PFSCK" = "yes" ] && fsckme_func loop1 ext2 #100318 however, commented out as there was an old not that f.s. check on an encrypted pupsave is broken. #140106 SFR: re-enabled
  996. mount -t ext2 -o noatime,rw /dev/loop1 $CREATEPUPSAVE2FS #only ext2 allowed.
  997. MNTSTAT=$?
  998. if [ "$MNTSTAT" = "0" ] ; then
  999. echo -n "...successfully mounted" >/dev/console
  1000. break
  1001. else
  1002. [ ! -e /bin/e2fsck ] && break #111120
  1003. echo -en "\\033[1;31m" >/dev/console #31=red
  1004. echo "Can't mount file, press ENTER key to try again." >/dev/console
  1005. echo "Or, any other char then ENTER for f.s. check then try again." > /dev/console
  1006. echo -n "Or, for developers type 'quit' to drop out to console: " > /dev/console
  1007. echo -en "\\033[0;39m" >/dev/console
  1008. read crypttryagain
  1009. echo > /dev/console
  1010. [ "$crypttryagain" = "quit" ] && exec /bin/sh >/dev/console 2>&1 #v3.98
  1011. [ "$crypttryagain" != "" ] && e2fsck -y -f /dev/loop1 >/dev/console
  1012. losetup -d /dev/loop1
  1013. fi
  1014. done
  1015. else #pupsave not encrypted.
  1016. # if pupsave increase requested
  1017. if [ -f /mnt/dev_save/pupsaveresizenew.txt ];then #131225 changed to function
  1018. . /mnt/dev_save/pupsaveresizenew.txt
  1019. if echo ${PUPSAVEFILEX}|grep -q ${PUPSAVEFILE##*/} ;then
  1020. if [ ! -e /bin/e2fsck ];then
  1021. echo -e -n "\\033[1;31m SORRY, cannot resize ${PUPSAVEFILE} \\033[0;39m" > /dev/console #31=red
  1022. rm -f /mnt/dev_save/pupsaveresizenew.txt
  1023. else
  1024. resize_pupsave_func #131225
  1025. fsck_pupsave_func /mnt/dev_save$PUPSAVEFILE #131225
  1026. fi
  1027. fi
  1028. fi
  1029. # end pupsave increase
  1030. losetup /dev/loop1 /mnt/dev_save${PUPSAVEFILE}
  1031. SFFS='ext'`echo -n "$PUPSAVEFILE" | rev | cut -c 3`
  1032. echo "/dev/loop1 $CREATEPUPSAVE2FS $SFFS defaults 1 1" >> /etc/fstab
  1033. [ "$PFSCK" = "yes" ] && fsckme_func loop1 $SFFS #100318
  1034. mount -t $SFFS -o noatime /dev/loop1 $CREATEPUPSAVE2FS
  1035. if [ $? -ne 0 ];then
  1036. if [ -e /bin/e2fsck ];then #111120
  1037. e2fsck -y -f /dev/loop1 > /dev/console #-y answer yes to all repair questions.
  1038. mount -t $SFFS -o noatime /dev/loop1 $CREATEPUPSAVE2FS
  1039. fi
  1040. fi
  1041. fi
  1042. fi
  1043. STATUS=$? #101028
  1044. check_status $STATUS
  1045. #101028 ask if upgrading save-file...
  1046. if [ $STATUS -eq 0 ];then
  1047. if [ $PUPMODE -eq 12 -o $PUPMODE -eq 13 ];then #4+8 or 4+8+1
  1048. OLDDISTRO_VERSION="`grep '^DISTRO_VERSION' $CREATEPUPSAVE2FS/etc/DISTRO_SPECS | cut -f 2 -d '=' | cut -f 2 -d "'" | cut -f 2 -d '"' | cut -f 1 -d ' '`" #110422
  1049. if vercmp ${DISTRO_VERSION} gt ${OLDDISTRO_VERSION} ;then #110422
  1050. if [ "$NUMPUPSAVES" != "0" ];then #save-file(s) found.
  1051. echo -e "\\033[1;36m" >/dev/console #36=aquablue
  1052. echo "This save-file was last used with version $OLDDISTRO_VERSION of Puppy." >/dev/console
  1053. echo "Hit the ENTER key only if it is okay to upgrade this file, or to not use it and boot up in RAM only type any other printable character." >/dev/console
  1054. echo -n "ENTER only to upgrade: " >/dev/console
  1055. echo -en "\\033[0;39m" >/dev/console
  1056. read noupgradesf
  1057. if [ "$noupgradesf" != "" ];then
  1058. echo -en "\\033[1;35m" >/dev/console #35=purple
  1059. echo "Backing off, not using save-file, booting in RAM only, PUPMODE=5..." >/dev/console
  1060. echo -en "\\033[0;39m" >/dev/console
  1061. sync
  1062. if [ -L "$CREATEPUPSAVE2FS" ]; then
  1063. rm -f "$CREATEPUPSAVE2FS" #get rid of save-folder
  1064. mkdir $CREATEPUPSAVE2FS
  1065. else
  1066. umount $CREATEPUPSAVE2FS #unmount the save-file.
  1067. fi
  1068. PUPMODE=5
  1069. CREATETMPFS="";CREATEPDEV1="";CREATEPUPXXXSFS="";CREATEPUPSAVE2FS="";CREATEFOLDERS=""
  1070. CREATETMPFS="/pup_rw";CREATEPUPXXXSFS="/pup_ro2"
  1071. OLDFILESMNTPT="";NEWFILESMNTPT="/pup_ro2";UMNTRW="/pup_rw=rw:";UMNTRO1="/pup_ro2=ro"
  1072. fi
  1073. fi
  1074. #check if puppy.sfs copied to same place as save-file...
  1075. if [ "`echo -n "$BOOTDRV" | grep -f /tmp/OPTICALDRIVES0`" != "" ];then #110205 booting off cd.
  1076. if [ "$CREATEPUPSAVE2FS" ];then #did not do the backoff above.
  1077. xPUPSFSDEV="`echo -n "$PUPSFS" | cut -f 1 -d ','`" #checking puppy.sfs file.
  1078. xPUPSFSFS="`echo -n "$PUPSFS" | cut -f 2 -d ','`"
  1079. xPUPSFSFILE="`echo -n "$PUPSFS" | cut -f 3 -d ','`"
  1080. basepupsfs="`basename $xPUPSFSFILE`"
  1081. if [ "`echo -n "$xPUPSFSDEV" | grep -f /tmp/OPTICALDRIVES0`" != "" ];then #110205
  1082. #it is on the cd, so checkout copying it to hd...
  1083. echo -e "\\033[1;36m" >/dev/console #36=aquablue
  1084. echo "The main Puppy file '${basepupsfs}' is being loaded off the optical disc." >/dev/console
  1085. echo "Very slow! Type ENTER key only to copy it to the same partition as the save-file then on next boot it will load fast. Type any printable char not to copy it." >/dev/console
  1086. echo -n "ENTER key only to copy: " >/dev/console
  1087. echo -en "\\033[0;39m" >/dev/console
  1088. read nocopysfs
  1089. if [ "$nocopysfs" = "" ];then
  1090. echo -en "\\033[1;35m" >/dev/console #35=purple
  1091. echo "'${basepupsfs}' now copying to hard drive (but only available next boot)..." >/dev/console
  1092. echo -en "\\033[0;39m" >/dev/console
  1093. PPATTERN="/dev/$xPUPSFSDEV "
  1094. PUPSFSDEVMNTPT="`mount | grep -m1 "$PPATTERN" | cut -f 3 -d ' '`"
  1095. if [ "$PUPSFSDEVMNTPT" = "" ];then
  1096. mntfunc $xPUPSFSFS /dev/$xPUPSFSDEV /mnt/dev_ro2 #-t $PUPSFSFS /dev/$PUPSFSDEV /mnt/dev_ro2
  1097. PUPSFSDEVMNTPT="/mnt/dev_ro2"
  1098. UMOUNTME="/mnt/dev_ro2" #mark for unmounting.
  1099. fi
  1100. #110424 do not copy puppy*.sfs into a sub-dir...
  1101. cp -f ${PUPSFSDEVMNTPT}/*.sfs /mnt/dev_save/
  1102. sync
  1103. fi
  1104. fi
  1105. fi
  1106. fi
  1107. fi
  1108. fi
  1109. fi
  1110. fi
  1111. #there are technical problems with loading a swap partition/file before the union
  1112. #is created, so not doing it until rc.sysinit runs. however, if a tmpfs needs to be
  1113. #created here, set it's size in anticipation of a swap being loaded...
  1114. EXTRAALLOCK=0
  1115. SWAPPART="`echo "$PCPARTSALL" | grep '|swap|' | head -n 1`"
  1116. [ "$SWAPPART" ] && SWAPPARTSIZE=`echo -n "$SWAPPART" | cut -f 3 -d '|'`
  1117. [ $SWAPPARTSIZE ] && EXTRAALLOCK=`expr $SWAPPARTSIZE \/ 2`
  1118. if [ $EXTRAALLOCK -eq 0 ];then
  1119. [ -f ${SMNTPT}/pupswap.swp ] && SWAPFILESIZEBYTES=`stat -c %s ${SMNTPT}/pupswap.swp`
  1120. [ $SWAPFILESIZEBYTES ] && EXTRAALLOCK=`expr $SWAPFILESIZEBYTES \/ 2048` #use half. 110521 also convert bytes to kb.
  1121. fi
  1122. FREEK=0
  1123. if [ "$CREATETMPFS" != "" ];then
  1124. FREEK=`expr $RAMSIZE \/ 2` #half of physical.
  1125. [ $PUPMODE -eq 77 ] && FREEK=`expr $FREEK - 50000` #need some slack.
  1126. ALLOCK=`expr $FREEK + $EXTRAALLOCK`
  1127. mount -t tmpfs -o size=${ALLOCK}k tmpfs $CREATETMPFS
  1128. fi
  1129. #RW (top) layer now has a tmpfs, PDEV1 or ${DISTRO_FILE_PREFIX}save mounted on it. calc free space...
  1130. [ $FREEK -eq 0 ] && FREEK=`df | grep ' /pup_rw' | tr -s ' ' | cut -f 4 -d ' '`
  1131. [ ! $FREEK ] && FREEK=0
  1132. if [ "$CREATEFOLDERS" != "" ];then
  1133. PUPSAVEDEV="`echo -n "$PUPSAVE" | cut -f 1 -d ','`"
  1134. PUPSAVEFS="`echo -n "$PUPSAVE" | cut -f 2 -d ','`"
  1135. PUPSAVEFILE="`echo -n "$PUPSAVE" | cut -f 3 -d ','`"
  1136. mount -o noatime -t $PUPSAVEFS /dev/$PUPSAVEDEV /mnt/dev_ro1 #mnt the cd.
  1137. #create a tmpfs to load the folders...
  1138. ALLOCK=`expr $RAMSIZE \/ 2 - 50000` #allocate half of physical ram. + leave 50M slack.
  1139. mount -t tmpfs -o size=${ALLOCK}k tmpfs $CREATEFOLDERS #/pup_ro1
  1140. #load the folders from the cd...
  1141. ####START LOAD FOLDERS####
  1142. CDMNTPT="/mnt/dev_ro1" #where the multisession cd is mounted.
  1143. DESTDIR="$CREATEFOLDERS" #dest dir has a tmpfs mntd on it, into which to copy folders.
  1144. BKFOLDERS="`ls -1 -r $CDMNTPT | grep '^20[0-9][0-9]'`"
  1145. BKLASTFOLDER="`echo "$BKFOLDERS" | head -n 1`"
  1146. #a boot option allows ignore last n sessions, also need to create a badlist...
  1147. if [ "$PIGNORELAST" ];then
  1148. BKBADLIST="`echo "$BKFOLDERS" | head -n ${PIGNORELAST}`"
  1149. if [ -f $CDMNTPT/$BKLASTFOLDER/.badfolders ];then
  1150. cp $CDMNTPT/$BKLASTFOLDER/.badfolders $DESTDIR/
  1151. if [ ! $? -eq 0 ];then
  1152. #fallback, in case last folder badly corrupted...
  1153. BKPREVFOLDER="`echo "$BKFOLDERS" | head -n 2 | tail -n 1`"
  1154. [ -f $CDMNTPT/$BKPREVFOLDER/.badfolders ] && cp $CDMNTPT/$BKPREVFOLDER/.badfolders $DESTDIR/
  1155. fi
  1156. fi
  1157. echo "$BKBADLIST" >> $DESTDIR/.badfolders
  1158. #note, rc.shutdown and savesession-dvd 'touch' this file so it will get saved.
  1159. sync
  1160. else
  1161. [ -f $CDMNTPT/$BKLASTFOLDER/.badfolders ] && cp $CDMNTPT/$BKLASTFOLDER/.badfolders $DESTDIR/
  1162. fi
  1163. [ -f $DESTDIR/.badfolders ] && BKBADLIST="`cat $DESTDIR/.badfolders | tr "\n" " "`"
  1164. BKFOLDERS="`echo -n "$BKFOLDERS" | tr "\n" " "`"
  1165. for ONEFOLDER in $BKFOLDERS
  1166. do
  1167. if [ ! "`echo -n "$BKBADLIST" | grep "$ONEFOLDER"`" = "" ];then
  1168. echo "Folder $ONEFOLDER marked bad." >/dev/console
  1169. continue #ignore bad folder.
  1170. fi
  1171. echo -n "Loading folder $ONEFOLDER from CD/DVD..." >/dev/console
  1172. #need to be careful not to overfill the ramdisk...
  1173. FREERAMDISK=`df 2>/dev/null | grep "$DESTDIR" | head -n 1 | tr -s " " | cut -f 4 -d " "`
  1174. SIZEFOLDER=`du -k -s ${CDMNTPT}/${ONEFOLDER} | cut -f 1`
  1175. if [ -d ${CDMNTPT}/${ONEFOLDER}/archive ];then
  1176. SIZEARCHIVE=`du -k -s ${CDMNTPT}/${ONEFOLDER}/archive | cut -f 1`
  1177. else
  1178. SIZEARCHIVE=0
  1179. fi
  1180. SIZESOURCE=`expr $SIZEFOLDER - $SIZEARCHIVE`
  1181. if [ $FREERAMDISK -gt $SIZESOURCE ];then
  1182. #well, -u will only copy if files newer, so less stuff may get copied than calc'd above.
  1183. #need to copy everything except archive folder...
  1184. [ -d $CDMNTPT/$ONEFOLDER/bin ] && cp -a -u $CDMNTPT/$ONEFOLDER/bin $DESTDIR/ > /dev/null 2>&1
  1185. [ -d $CDMNTPT/$ONEFOLDER/sbin ] && cp -a -u $CDMNTPT/$ONEFOLDER/sbin $DESTDIR/ > /dev/null 2>&1
  1186. [ -d $CDMNTPT/$ONEFOLDER/etc ] && cp -a -u $CDMNTPT/$ONEFOLDER/etc $DESTDIR/ > /dev/null 2>&1
  1187. [ -d $CDMNTPT/$ONEFOLDER/lib ] && cp -a -u $CDMNTPT/$ONEFOLDER/lib $DESTDIR/ > /dev/null 2>&1
  1188. [ -d $CDMNTPT/$ONEFOLDER/opt ] && cp -a -u $CDMNTPT/$ONEFOLDER/opt $DESTDIR/ > /dev/null 2>&1
  1189. if [ -d $CDMNTPT/$ONEFOLDER/root/.var_saved ];then #100820 see /etc/rc.d/functions4puppy
  1190. mkdir -p $DESTDIR/var
  1191. cp -a -u $CDMNTPT/$ONEFOLDER/root/.var_saved/* $DESTDIR/var/ > /dev/null 2>&1
  1192. fi
  1193. [ -d $CDMNTPT/$ONEFOLDER/root ] && cp -a -u $CDMNTPT/$ONEFOLDER/root $DESTDIR/ > /dev/null 2>&1
  1194. [ -d $CDMNTPT/$ONEFOLDER/root/.var_saved ] && rm -rf $DESTDIR/root/.var_saved > /dev/null 2>&1 #100820
  1195. [ -d $CDMNTPT/$ONEFOLDER/usr ] && cp -a -u $CDMNTPT/$ONEFOLDER/usr $DESTDIR/ > /dev/null 2>&1
  1196. [ $DEVTMPFSFLG -eq 0 ] && [ -d $CDMNTPT/$ONEFOLDER/dev ] && cp -a -u $CDMNTPT/$ONEFOLDER/dev $DESTDIR/ > /dev/null 2>&1 #v411 130612
  1197. cp -a -u $CDMNTPT/$ONEFOLDER/*.sfs $DESTDIR/ > /dev/null 2>&1 #v3.97
  1198. #delete deleted files (.wh.filename)... 110212 screen out .wh..wh..opq
  1199. WHITEOUTS="`find $DESTDIR -xdev -type f -name .wh.* | grep -v '__dir_opaque' | grep -v '.wh..wh.'`" #110212
  1200. echo "$WHITEOUTS" |
  1201. while read DELWHITE
  1202. do
  1203. DELFILE="`echo -n "$DELWHITE" | sed -e 's/\\.wh\\.//g'`"
  1204. if [ -e "$DELFILE" ];then
  1205. rm -rf "$DELFILE"
  1206. rm -rf "$DELWHITE"
  1207. fi
  1208. done
  1209. check_status 0 #display 'done' for each folder loaded.
  1210. else
  1211. echo -n -e "\\033[70G\\033[1;31m" >/dev/console #red text on column 70.
  1212. echo -n "RAM full" >/dev/console
  1213. echo -e "\\033[0;39m" >/dev/console
  1214. break
  1215. fi
  1216. done
  1217. sync
  1218. ####END LOAD FOLDERS####
  1219. umount /mnt/dev_ro1 #unmount the cd.
  1220. fi
  1221. OLDDISTRO_VERSION="$DISTRO_VERSION" #110422
  1222. [ -f $OLDFILESMNTPT/etc/puppyversion ] && OLDDISTRO_VERSION="`cat $OLDFILESMNTPT/etc/puppyversion`" #old pre-w464 installation. 110422
  1223. [ -f $OLDFILESMNTPT/etc/DISTRO_SPECS ] && OLDDISTRO_VERSION="`grep '^DISTRO_VERSION' $OLDFILESMNTPT/etc/DISTRO_SPECS | cut -f 2 -d '=' | cut -f 2 -d "'" | cut -f 2 -d '"' | cut -f 1 -d ' '`" #w012 w478 110422
  1224. #110801 moved up...
  1225. REASON=''
  1226. vercmp $DISTRO_VERSION gt $OLDDISTRO_VERSION && REASON='upgrade' #110422
  1227. [ $PUPMODE -eq 5 ] && REASON='firstboot'
  1228. #110810 some builds may have many scsi drivers in initrd, if needed will have already loaded, so delete them...
  1229. if [ "$REASON" != "" ];then
  1230. mkdir /tmp/scsi-keep
  1231. for ONEKEEP in imm.ko ppa.ko raid_class.ko sg.ko scsi_wait_scan.ko
  1232. do
  1233. ONEFND="`find /lib/modules/$KERNELVER/kernel/drivers/scsi -type f -name $ONEKEEP`"
  1234. [ "$ONEFND" ] && cp -a $ONEFND /tmp/scsi-keep/
  1235. done
  1236. rm -rf /lib/modules/$KERNELVER/kernel/drivers/scsi
  1237. cp -a /tmp/scsi-keep /lib/modules/$KERNELVER/kernel/drivers/scsi #restore needed.
  1238. fi
  1239. #110810 problem kernel numbering 2.6.32-40, 2.6.32-44 both in /lib/modules/2.6.32...
  1240. if [ "$REASON" = "upgrade" ];then
  1241. if [ -d /pup_rw/lib/modules/initrd ];then
  1242. rm -rf /pup_rw/lib/modules/initrd
  1243. rm -f /pup_rw/lib/modules/modules.*
  1244. fi
  1245. if [ -d /pup_ro1/lib/modules/initrd ];then
  1246. rm -rf /pup_ro1/lib/modules/initrd
  1247. rm -f /pup_ro1/lib/modules/modules.*
  1248. fi
  1249. fi
  1250. #move modules to main f.s...
  1251. #(do this before loading ${DISTRO_FILE_PREFIX}-xxx.sfs, to free up ram space)...
  1252. if [ "$ZDRVINIT" = "yes" ];then
  1253. #the entire kitchen sink of modules is in the initrd.
  1254. ZDRV='' #/sbin/modprobe needs this.
  1255. #what if deleted modules due to lack space in ${DISTRO_FILE_PREFIX}save, but now more free space?... v4.01...
  1256. [ ! -d /pup_rw/lib/modules/all-firmware ] && [ ! -d /pup_ro1/lib/modules/all-firmware ] && [ $FREEK -gt 24000 ] && REASON='restore'
  1257. if [ "$REASON" != "" ];then
  1258. [ -d /pup_rw/lib/modules ] && rm -rf /pup_rw/lib/modules
  1259. [ -d /pup_ro1/lib/modules ] && rm -rf /pup_ro1/lib/modules
  1260. mkdir -p /pup_rw/lib
  1261. mv /lib/modules /pup_rw/lib/
  1262. mkdir -p /pup_rw/initrd
  1263. cp -af /DISTRO_SPECS /pup_rw/initrd/
  1264. cp -af /init /pup_rw/initrd/
  1265. sync
  1266. fi
  1267. else
  1268. #the initrd does have some modules, move them to the main layered f.s...
  1269. #v4.02 moved this up. had it down after the the unionfs setup (just want it same place as the above code).
  1270. [ ! -d /pup_rw/lib/modules/$KERNELVER/initrd ] && [ ! -d /pup_ro1/lib/modules/$KERNELVER/initrd ] && REASON="new"
  1271. if [ "$REASON" = "new" ];then #110810 change test.
  1272. mkdir -p /pup_rw/lib/modules/$KERNELVER #PUPMODE=5, this dir not exist.
  1273. mv /lib/modules/$KERNELVER /pup_rw/lib/modules/$KERNELVER/initrd
  1274. rm -f /pup_rw/lib/modules/$KERNELVER/initrd/modules.*
  1275. sync
  1276. #note: /etc/rc.d/rc.sysinit will detect them and run depmod.
  1277. fi
  1278. fi
  1279. COPY2RAM=""
  1280. COPYMSG='copying to ram' #purple
  1281. if [ "$CREATEPUPXXXSFS" != "" ];then
  1282. #load puppy.sfs...
  1283. PUPSFSDEV="`echo -n "$PUPSFS" | cut -f 1 -d ','`"
  1284. PUPSFSFS="`echo -n "$PUPSFS" | cut -f 2 -d ','`"
  1285. PUPSFSFILE="`echo -n "$PUPSFS" | cut -f 3 -d ','`"
  1286. basepupsfs="`basename $PUPSFSFILE`"
  1287. echo -n "Loading the '${basepupsfs}' main file..." > /dev/console
  1288. if [ "$PUPSFSDEV" = "rootfs" ];then #humongous initrd.
  1289. PUPSFSDEVMNTPT="" #actually it's '/'.
  1290. COPY2RAM='yes' #actually it is already in ram, but code below puts it in a tmpfs.
  1291. else
  1292. PPATTERN="/dev/$PUPSFSDEV "
  1293. PUPSFSDEVMNTPT="`mount | grep -m1 "$PPATTERN" | cut -f 3 -d ' '`"
  1294. if [ "$PUPSFSDEVMNTPT" = "" ];then
  1295. mntfunc $PUPSFSFS /dev/$PUPSFSDEV /mnt/dev_ro2 #-t $PUPSFSFS /dev/$PUPSFSDEV /mnt/dev_ro2
  1296. PUPSFSDEVMNTPT="/mnt/dev_ro2"
  1297. UMOUNTME="/mnt/dev_ro2" #mark for unmounting.
  1298. fi
  1299. fi
  1300. #if there's heaps of ram, copy puppy.sfs to a tmpfs...
  1301. #v405 fast media plus more than 256MB ram then definitely worth copying to ram...
  1302. SIZESFSK=`du -k ${PUPSFSDEVMNTPT}${PUPSFSFILE} | cut -f 1`
  1303. SIZESFSK=$(($SIZESFSK + 1000)) #some slack.
  1304. MINRAM2CPY=$(($SIZESFSK * 2)) #100222 technosaurus: in case of very big puppies.
  1305. #100920 decide whether to copy .sfs's to ram (see prior decision above)...
  1306. pdPATTERN="`echo "$PUPSFSDEV" | sed -e 's/[0-9]*$//'` "
  1307. if [ "$PNOCOPY" != "yes" ];then
  1308. [ "`echo -n "$ATADRIVES" | grep "$pdPATTERN"`" = "" ] && COPYCONTENDER='yes' #test if not fast internal drive.
  1309. [ $PUPMODE -eq 5 ] && COPYCONTENDER='yes'
  1310. [ "$DEV1FS" = "iso9660" ] && COPYCONTENDER='yes'
  1311. [ "$DEV1FS" = "udf" ] && COPYCONTENDER='yes' #130128
  1312. [ $RAMSIZE -gt 700000 ] && COPYCONTENDER='yes' #130728 always try to copy sfs to ram if >=700MB.
  1313. fi
  1314. [ "$PCOPY" = "yes" ] && COPYCONTENDER='yes'
  1315. #130728 bump minimum ram size... was 220000
  1316. [ "$COPYCONTENDER" = "yes" ] && [ $RAMSIZE -gt 400000 ] && [ $RAMSIZE -gt $MINRAM2CPY ] && COPY2RAM="yes"
  1317. if [ "$COPY2RAM" = "yes" ];then
  1318. mount -t tmpfs -o size=${SIZESFSK}k tmpfs /mnt/tmpfs
  1319. if [ "${PUPSFSDEVMNTPT}" = "" ];then #v403 humongous initrd.
  1320. mv -f ${PUPSFSDEVMNTPT}${PUPSFSFILE} /mnt/tmpfs/
  1321. else
  1322. echo -e -n " \\033[1;35m${COPYMSG}\\033[0;39m" > /dev/console #purple.
  1323. cp -af ${PUPSFSDEVMNTPT}${PUPSFSFILE} /mnt/tmpfs/
  1324. fi
  1325. sync
  1326. SFSBASENAME="`basename $PUPSFSFILE`"
  1327. losetup /dev/loop0 /mnt/tmpfs/${SFSBASENAME}
  1328. #101013 moved down [ "$UMOUNTME" != "" ] && umntfunc $UMOUNTME
  1329. else
  1330. losetup /dev/loop0 ${PUPSFSDEVMNTPT}${PUPSFSFILE}
  1331. fi
  1332. mount -r -t squashfs -o noatime /dev/loop0 $CREATEPUPXXXSFS #usually /pup_ro2.
  1333. fi
  1334. ###TODO: above code-block almost same as below, could probably combine###
  1335. ZLAYER='' #v4.02
  1336. ZFACTOR='' #v426
  1337. #note, traditionally, loop2 kept free for scripts to use.
  1338. if [ "$ZDRVINIT" != "yes" ];then
  1339. #v4.02 if ZDRV located, and mounted, put it into the layered-fs...
  1340. if [ "$ZDRV" != "" ];then
  1341. ZDEV="`echo "$ZDRV" | cut -f 1 -d ','`"
  1342. ZFS="`echo "$ZDRV" | cut -f 2 -d ','`"
  1343. ZFILE="`echo "$ZDRV" | cut -f 3 -d ','`"
  1344. MNT_ZFILE=""
  1345. if [ "$ZDEV" = "rootfs" ];then #101102 humongous initrd.
  1346. MNT_ZFILE="" #actually it's '/'.
  1347. COPY2RAM='yes' #actually it is already in ram, but code below puts it in a tmpfs.
  1348. else
  1349. zPATTERN="/dev/$ZDEV "
  1350. MNT_ZFILE="`mount | grep -m1 "$zPATTERN" | cut -f 3 -d ' '`"
  1351. fi
  1352. ZBASENAME="`basename $ZFILE`" #v426 moved up.
  1353. if [ "$MNT_ZFILE" != "" ];then
  1354. if [ "$COPY2RAM" = "yes" ];then
  1355. SIZEZK=`du -k ${MNT_ZFILE}${ZFILE} | cut -f 1`
  1356. SIZEZK=`expr $SIZEZK + 1000` #some slack.
  1357. mount -t tmpfs -o size=${SIZEZK}k tmpfs /mnt/tmpfs4
  1358. if [ "$MNT_ZFILE" = "" ];then #101101 humongous initrd.
  1359. mv -af ${MNT_ZFILE}${ZFILE} /mnt/tmpfs4/
  1360. else
  1361. cp -af ${MNT_ZFILE}${ZFILE} /mnt/tmpfs4/
  1362. fi
  1363. sync
  1364. losetup /dev/loop4 /mnt/tmpfs4/${ZBASENAME}
  1365. else
  1366. losetup /dev/loop4 ${MNT_ZFILE}${ZFILE}
  1367. fi
  1368. mount -r -t squashfs -o noatime /dev/loop4 /pup_z
  1369. if [ $? -eq 0 ];then
  1370. ZLAYER=':/pup_z=ro'
  1371. ZFACTOR="$ZBASENAME" #v426
  1372. fi
  1373. fi
  1374. fi
  1375. fi
  1376. #130513 create pupdesk.flg...
  1377. if [ $PUPMODE -eq 5 ];then
  1378. if [ -s /tmp/RWPART ];then
  1379. pdFLG=0
  1380. pdDEV="$(cat /tmp/RWPART | cut -f 1 -d '|')"
  1381. pdFS="$(cat /tmp/RWPART | cut -f 2 -d '|')"
  1382. pdMNTPT="$(cat /proc/mounts | grep "/dev/${pdDEV} " | cut -f 2 -d ' ')"
  1383. if [ ! "$pdMNTPT" ];then
  1384. mkdir -p /mnt/$pdDEV
  1385. mntfunc $pdFS /dev/$pdDEV /mnt/$pdDEV #130518
  1386. pdFLG=1
  1387. pdMNTPT="/mnt/${pdDEV}"
  1388. fi
  1389. if [ ! -f ${pdMNTPT}/pupdesk.flg ];then
  1390. touch ${pdMNTPT}/pupdesk.flg #read in quicksetup.
  1391. else
  1392. #quicksetup writes auto-selected driver into pupdesk.flg (at previous boot).
  1393. mkdir -p /pup_rw/var/local #130518
  1394. cp -f ${pdMNTPT}/pupdesk.flg /pup_rw/var/local/quicksetup-pupmode5-autodriver #xorgwizard-cli reads this.
  1395. mkdir -p /pup_rw/root #130518
  1396. touch /pup_rw/root/.xorgwizard-reenter #see /root/.profile, will cause xorgwizard to run.
  1397. #...see also /etc/rc.d/rc.sysinit
  1398. fi
  1399. [ $pdFLG -eq 1 ] && umntfunc $pdMNTPT
  1400. fi
  1401. else
  1402. [ -f /tmp/RWPART ] && rm -f /tmp/RWPART
  1403. fi
  1404. ALAYER=''
  1405. AFACTOR=''
  1406. if [ "$ADRV" != "" ];then
  1407. ADEV="`echo "$ADRV" | cut -f 1 -d ','`"
  1408. AFS="`echo "$ADRV" | cut -f 2 -d ','`"
  1409. AFILE="`echo "$ADRV" | cut -f 3 -d ','`"
  1410. MNT_AFILE=""
  1411. aPATTERN="/dev/$ADEV "
  1412. MNT_AFILE="`mount | grep -m1 "$aPATTERN" | cut -f 3 -d ' '`"
  1413. ABASENAME="`basename $AFILE`" #v426 moved up.
  1414. if [ "$MNT_AFILE" != "" ];then
  1415. if [ "$COPY2RAM" = "yes" ];then
  1416. SIZEZK=`du -k ${MNT_AFILE}${AFILE} | cut -f 1`
  1417. SIZEZK=`expr $SIZEZK + 1000` #some slack.
  1418. mount -t tmpfs -o size=${SIZEZK}k tmpfs /mnt/tmpfs2
  1419. cp -af ${MNT_AFILE}${AFILE} /mnt/tmpfs2/
  1420. sync
  1421. losetup /dev/loop2 /mnt/tmpfs2/${ABASENAME}
  1422. else
  1423. losetup /dev/loop2 ${MNT_AFILE}${AFILE}
  1424. fi
  1425. mount -r -t squashfs -o noatime /dev/loop2 /pup_a > /dev/console 2>&1
  1426. if [ $? -eq 0 ];then
  1427. ALAYER='/pup_a=ro:'
  1428. AFACTOR="$ABASENAME" #v426
  1429. fi
  1430. fi
  1431. fi
  1432. YLAYER=''
  1433. YFACTOR=''
  1434. if [ "$YDRV" != "" ];then
  1435. YDEV="`echo "$YDRV" | cut -f 1 -d ','`"
  1436. YFS="`echo "$YDRV" | cut -f 2 -d ','`"
  1437. YFILE="`echo "$YDRV" | cut -f 3 -d ','`"
  1438. MNT_YFILE=""
  1439. yPATTERN="/dev/$YDEV "
  1440. MNT_YFILE="`mount | grep -m1 "$yPATTERN" | cut -f 3 -d ' '`"
  1441. YBASENAME="`basename $YFILE`" #v426 moved up.
  1442. if [ "$MNT_YFILE" != "" ];then
  1443. if [ "$COPY2RAM" = "yes" ];then
  1444. SIZEZK=`du -k ${MNT_YFILE}${YFILE} | cut -f 1`
  1445. SIZEZK=`expr $SIZEZK + 1000` #some slack.
  1446. mount -t tmpfs -o size=${SIZEZK}k tmpfs /mnt/tmpfs3
  1447. cp -af ${MNT_YFILE}${YFILE} /mnt/tmpfs3/
  1448. sync
  1449. losetup /dev/loop3 /mnt/tmpfs3/${YBASENAME}
  1450. else
  1451. losetup /dev/loop3 ${MNT_YFILE}${YFILE}
  1452. fi
  1453. mount -r -t squashfs -o noatime /dev/loop3 /pup_y > /dev/console 2>&1
  1454. if [ $? -eq 0 ];then
  1455. YLAYER='/pup_y=ro:'
  1456. YFACTOR="$YBASENAME" #v426
  1457. fi
  1458. fi
  1459. fi
  1460. [ "$UMOUNTME" != "" ] && umntfunc $UMOUNTME #101013 puppy.sfs was copied to tmpfs so can unmount partition.
  1461. check_status 0 #$?
  1462. ########################END LOADING PUPPY FILES########################
  1463. #120215 may have PSUBDIR already, but use this method... (i want to be able to locate the initrd.gz)
  1464. zPSUBDIR=''
  1465. [ "$PUPSFS" ] && zPSUBDIR="`echo -n "$PUPSFS" | cut -f 3 -d ',' | sed -e 's%/[^/]*$%%'`" #ex: sda3,ext2,/pup220/xxx.sfs will return /pup220
  1466. [ "$zPSUBDIR" = "" -o "$zPSUBDIR" = "/" ] && zPSUBDIR="$PSUBDIR"
  1467. #...this will be written to /etc/rc.d/PUPSTATE
  1468. #/etc/PUPSTATE passes useful variables to the running puppy...
  1469. mkdir -p /pup_rw/etc/rc.d
  1470. echo "PUPMODE=$PUPMODE" > /pup_rw/etc/rc.d/PUPSTATE
  1471. echo "PDEV1='$PDEV1'" >> /pup_rw/etc/rc.d/PUPSTATE
  1472. echo "DEV1FS='$DEV1FS'" >> /pup_rw/etc/rc.d/PUPSTATE
  1473. echo "PUPSFS='$PUPSFS'" >> /pup_rw/etc/rc.d/PUPSTATE
  1474. echo "PUPSAVE='$PUPSAVE'" >> /pup_rw/etc/rc.d/PUPSTATE
  1475. echo "PMEDIA='$PMEDIA'" >> /pup_rw/etc/rc.d/PUPSTATE
  1476. echo '#ATADRIVES is all internal ide/pata/sata drives, excluding optical, excluding usb...' >> /pup_rw/etc/rc.d/PUPSTATE
  1477. echo "ATADRIVES='$ATADRIVES'" >> /pup_rw/etc/rc.d/PUPSTATE
  1478. echo '#ATAOPTICALDRIVES is list of non-usb optical drives...' >> /pup_rw/etc/rc.d/PUPSTATE #110206
  1479. echo "ATAOPTICALDRIVES='$ATAOPTICALDRIVES'" >> /pup_rw/etc/rc.d/PUPSTATE
  1480. echo '#these directories are unionfs/aufs layers in /initrd...' >> /pup_rw/etc/rc.d/PUPSTATE
  1481. echo "SAVE_LAYER='$OLDFILESMNTPT'" >> /pup_rw/etc/rc.d/PUPSTATE
  1482. echo "PUP_LAYER='$NEWFILESMNTPT'" >> /pup_rw/etc/rc.d/PUPSTATE
  1483. #if [ $SMNTPT ];then
  1484. echo "#The partition that has the ${DISTRO_FILE_PREFIX}save file is mounted here..." >> /pup_rw/etc/rc.d/PUPSTATE
  1485. echo "PUP_HOME='${SMNTPT}'" >> /pup_rw/etc/rc.d/PUPSTATE
  1486. echo '#(in /initrd) ...note, /mnt/home is a link to it.' >> /pup_rw/etc/rc.d/PUPSTATE
  1487. #fi
  1488. echo '#this file has extra kernel drivers and firmware...' >> /pup_rw/etc/rc.d/PUPSTATE
  1489. echo "ZDRV='$ZDRV'" >> /pup_rw/etc/rc.d/PUPSTATE #v2.22
  1490. echo "ADRV='$ADRV'" >> /pup_rw/etc/rc.d/PUPSTATE
  1491. echo "YDRV='$YDRV'" >> /pup_rw/etc/rc.d/PUPSTATE
  1492. echo '#complete set of modules in the initrd (moved to main f.s.)...' >> /pup_rw/etc/rc.d/PUPSTATE
  1493. echo "ZDRVINIT='$ZDRVINIT'" >> /pup_rw/etc/rc.d/PUPSTATE #v4.02
  1494. echo '#Partition no. override on boot drive to which session is (or will be) saved...' >> /pup_rw/etc/rc.d/PUPSTATE
  1495. echo "PSAVEMARK='$PSAVEMARK'" >> /pup_rw/etc/rc.d/PUPSTATE
  1496. if [ "$PLANG" ];then #120215 L18L. 120217 bring this back, seems like a good thing!
  1497. echo "#PLANG is written to LANG in /etc/profile by init script initrd...
  1498. PLANG=${PLANG}
  1499. OUTPUT_CHARSET=UTF-8
  1500. export OUTPUT_CHARSET" >> /pup_rw/etc/rc.d/PUPSTATE
  1501. fi
  1502. echo "PSUBDIR='${zPSUBDIR}'" >> /pup_rw/etc/rc.d/PUPSTATE #120215
  1503. #older ${DISTRO_FILE_PREFIX}save.2fs <v2.16 will not have this file...
  1504. [ ! -f $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG ] && touch $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG
  1505. #note, OLDFILESMNTPT can also be "" so BOOTCONFIG needs to exist in initrd also.
  1506. . $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG #can have EXTRASFSLIST variable.
  1507. #110217 very bad hack, see /etc/rc.d/rc.update, rc.shutdown.
  1508. [ ! -f $OLDFILESMNTPT/var/local/etc_profile_at_shutdown ] && cp -f $OLDFILESMNTPT/etc/profile $OLDFILESMNTPT/var/local/etc_profile_at_shutdown
  1509. ######################SETUP LAYERED FILESYSTEM########################
  1510. echo -n "Setting up the layered filesystem..." > /dev/console #STEP FIVE
  1511. #are there any other sfs files to load at bottom layers?...
  1512. NEWUNIONRECORD=""
  1513. CNTLOOP=5 ; UMNTRO=""
  1514. if [ "$PUPSAVE" != "" ];then
  1515. if [ "$SMNTPT" != "" -o $PUPMODE -eq 77 ];then #v3.97
  1516. touch /tmp/EXTRASFSS #100711
  1517. SFSSDIR="$SMNTPT"
  1518. #100711 look in top and in psubdir...
  1519. xSFSSDIRx="" #100711
  1520. xPSUBDIR="`echo -n "$PUPSAVE" | cut -f 3 -d ',' | sed -e 's%/[^/]*$%%'`" #ex: sda3,ext2,/pup220/spupsave.2fs will return /pup220
  1521. [ "$xPSUBDIR" ] && xSFSSDIRx="${SMNTPT}${xPSUBDIR}"'/*.sfs' #100711
  1522. [ $PUPMODE -eq 77 ] && SFSSDIR="$DESTDIR" #v3.97
  1523. #find all the extra sfs files...
  1524. touch /tmp/LOGONEBASES
  1525. #v424 modified to only load selection made in BootManager...
  1526. if [ "$EXTRASFSLIST" != "" ];then #in /etc/rc.d/BOOTCONFIG
  1527. #130514 shinobar: extra sfs in the order of EXTRASFSLIST, subdir first
  1528. for ONEEXTRA in $EXTRASFSLIST ; do
  1529. ONEBASE="`basename $ONEEXTRA`"
  1530. echo "$ONEBASE" | grep -qE '^z|^pup[_-]' && continue
  1531. echo "/tmp/EXTRASFSS" | grep -q "$ONEBASE" && continue # avoid loading duplicates.
  1532. [ "$xPSUBDIR" != "" ] && [ -s "$SFSSDIR$xPSUBDIR/$ONEBASE" ] && echo "$SFSSDIR$xPSUBDIR/$ONEBASE" >> /tmp/EXTRASFSS && continue
  1533. [ -s "$SFSSDIR/$ONEBASE" ] && echo "$SFSSDIR/$ONEBASE" >> /tmp/EXTRASFSS && continue
  1534. done
  1535. fi
  1536. UMNTRO="" ; EXTRASFSLIST=""
  1537. if [ -s /tmp/EXTRASFSS ];then #100711
  1538. for ONEEXTRA in `cat /tmp/EXTRASFSS | tr '\n' ' '`
  1539. do
  1540. ONEBASE="`basename $ONEEXTRA`"
  1541. EXTRASFSLIST="${EXTRASFSLIST}${ONEBASE} " #construct list of actually used.
  1542. losetup /dev/loop${CNTLOOP} $ONEEXTRA
  1543. mount -r -t squashfs -o noatime /dev/loop${CNTLOOP} /pup_ro${CNTLOOP}
  1544. [ $? -eq 0 ] && UMNTRO="${UMNTRO}:/pup_ro${CNTLOOP}=ro"
  1545. CNTLOOP=`expr $CNTLOOP + 1`
  1546. [ $CNTLOOP -eq 10 ] && break
  1547. #...only support adding 3 extra .sfs files, as performance degrades as each layer added.
  1548. #...v410 bugfix, change 6 to 7 so can have 3 sfs files.
  1549. #...w015 change 7 to 10 so can have 6 sfs files.
  1550. done
  1551. fi
  1552. #keep a record of different layer configurations...
  1553. SAVEFILE="`echo -n "$PUPSAVE" | cut -f 3 -d ','`"
  1554. SAVEFILENAMEONLY="`basename $SAVEFILE`"
  1555. SFSFILE="`echo -n "$PUPSFS" | cut -f 3 -d ','`"
  1556. SFSFILENAMEONLY="`basename $SFSFILE`"
  1557. RECORDLIST="$SAVEFILENAMEONLY $AFACTOR $YFACTOR $SFSFILENAMEONLY $ZFACTOR $EXTRASFSLIST" #v426
  1558. NEWUNIONRECORD="`echo "$RECORDLIST" | tr -s ' ' | sed -e 's/ $//'`"
  1559. #120130 bring back Underdog Linux...
  1560. [ ! "$UNDERDOG" ] && [ "$xPSUBDIR" ] && [ -f "${SMNTPT}${xPSUBDIR}/underdog.lnx" ] && UNDERDOG="`cat "${SMNTPT}${xPSUBDIR}/underdog.lnx"`"
  1561. [ ! "$UNDERDOG" ] && [ -f $SFSSDIR/underdog.lnx ] && UNDERDOG="`cat ${SFSSDIR}/underdog.lnx`"
  1562. fi
  1563. fi
  1564. #120130 bring back Underdog Linux...
  1565. if [ "$UNDERDOG" ];then #note, 'underdog' can also be specified on kernel commandline.
  1566. udPTN1="${UNDERDOG}|"
  1567. FNDPART="`echo "$PCPARTS0" | grep "$udPTN1"`" #ex: sda1|ext3
  1568. if [ "$FNDPART" ];then
  1569. udPTN2="/dev/${UNDERDOG} "
  1570. UDMNTPT="`mount | grep -m1 "$udPTN2" | cut -f 3 -d ' '`"
  1571. if [ ! "$UDMNTPT" ];then #must not be mounted.
  1572. udFS="`echo -n "$FNDPART" | cut -f 2 -d '|'`"
  1573. mount -r -t $udFS /dev/$UNDERDOG /pup_ro${CNTLOOP}
  1574. if [ $? -eq 0 ];then
  1575. UMNTRO="${UMNTRO}:/pup_ro${CNTLOOP}=ro"
  1576. #fixes to prevent library clashes... (got out of puppy 2.x)
  1577. MNTFIX='/pup_rw'
  1578. [ "`echo -n "$UMNTRO" | grep 'pup_ro1'`" != "" ] && MNTFIX='/pup_ro1'
  1579. [ ! -f $MNTFIX/lib/.wh.i686 ] && touch /pup_rw/lib/.wh.i686 #hides /lib/i686
  1580. #puppy needs dir name /usr/lib/qt at bootup (see rc.profile)...
  1581. REALQTDIR="`find /pup_ro${CNTLOOP}/usr/lib -maxdepth 1 -type d -name 'qt*' | tail -n 1 | sed -e "s/\/pup_ro${CNTLOOP}\/usr\/lib\///"`"
  1582. if [ "$REALQTDIR" ];then
  1583. if [ ! -e $MNTFIX/usr/lib/qt ];then
  1584. [ "`find /pup_ro${CNTLOOP}/usr/lib -maxdepth 1 -xtype d -name qt`" = "" ] && ln -s $REALQTDIR /pup_rw/usr/lib/qt
  1585. fi
  1586. fi
  1587. CNTLOOP=`expr $CNTLOOP + 1`
  1588. fi
  1589. fi
  1590. fi
  1591. fi
  1592. #update /etc/rc.d/BOOTCONFIG with latest layered-fs layers configuration... #100222 fix...
  1593. xBOOTCONFIG="`grep -v '^PREVUNIONRECORD' $OLDFILESMNTPT/etc/rc.d/BOOTCONFIG | sed -e 's/^LASTUNIONRECORD/PREVUNIONRECORD/'`"
  1594. echo "$xBOOTCONFIG" > /pup_rw/etc/rc.d/BOOTCONFIG
  1595. #sync
  1596. echo "LASTUNIONRECORD='$NEWUNIONRECORD'" >> /pup_rw/etc/rc.d/BOOTCONFIG
  1597. [ "$LASTUNIONRECORD" = "$NEWUNIONRECORD" ] && NEWUNIONRECORD="" #used below.
  1598. #...if layers changed since last boot, code further down will do whiteout files purge.
  1599. #.../etc/rc.d/rc.update reads BOOTCONFIG, updates menu (etc) if layers changed.
  1600. #after switch_root, rc.sysinit calls rc.update, but need to do pre-cleaning...
  1601. if [ "$OLDFILESMNTPT" != "" ];then
  1602. #an empty tmp is required for mounting a tmpfs onto later...
  1603. rm -rf $OLDFILESMNTPT/tmp/*
  1604. rm -rf $OLDFILESMNTPT/tmp/.[0-9a-zA-Z]*
  1605. if [ ! -L $OLDFILESMNTPT/usr/X11R6 ];then #test if a symlink.
  1606. #this is supposed to be a link to X11R7. <2.10 it won't be...
  1607. if [ -d $OLDFILESMNTPT/usr/X11R6 ];then
  1608. mkdir -p $OLDFILESMNTPT/usr/X11R7
  1609. cp -af $OLDFILESMNTPT/usr/X11R6/* $OLDFILESMNTPT/usr/X11R7/
  1610. rm -rf $OLDFILESMNTPT/usr/X11R6
  1611. fi
  1612. [ -d X11R7 ] && ln -s X11R7 $OLDFILESMNTPT/usr/X11R6
  1613. fi
  1614. rm -rf $OLDFILESMNTPT/root/tmp 2>/dev/null
  1615. rm -f $OLDFILESMNTPT/root/.wh.tmp 2>/dev/null
  1616. NEWPVERSION="$DISTRO_VERSION" #110422
  1617. if [ -f $OLDFILESMNTPT/etc/puppyversion ];then
  1618. OLDPVERSION="`cat $OLDFILESMNTPT/etc/puppyversion`" #old pre-w464 installation. 110422
  1619. rm -f $OLDFILESMNTPT/etc/puppyversion #no longer used.
  1620. fi
  1621. [ -f $OLDFILESMNTPT/etc/DISTRO_SPECS ] && OLDPVERSION="`grep '^DISTRO_VERSION' $OLDFILESMNTPT/etc/DISTRO_SPECS | cut -f 2 -d '=' | cut -f 2 -d '"' | cut -f 2 -d "'" | cut -f 1 -d ' '`" #w478 110422
  1622. [ "$OLDPVERSION" = "" ] && OLDPVERSION="$NEWPVERSION"
  1623. if vercmp ${NEWPVERSION} gt ${OLDPVERSION} ; then
  1624. #make sure that the official boot scripts will be visible at top
  1625. rm -f $OLDFILESMNTPT/etc/rc.d/functions
  1626. rm -f $OLDFILESMNTPT/etc/rc.d/functions4puppy4
  1627. rm -f $OLDFILESMNTPT/etc/rc.d/rc.country
  1628. rm -f $OLDFILESMNTPT/etc/rc.d/rc.network_basic
  1629. rm -f $OLDFILESMNTPT/etc/rc.d/rc.services
  1630. rm -f $OLDFILESMNTPT/etc/rc.d/rc.shutdown
  1631. rm -f $OLDFILESMNTPT/etc/rc.d/rc.sysinit
  1632. rm -f $OLDFILESMNTPT/etc/rc.d/rc.update
  1633. fi
  1634. #110422 decrement dotted version number. hard, just set to 0.0...
  1635. [ "$PCLEAN" = "yes" ] && xOLDPVERSION='0.0' #110422
  1636. [ "$PPURGE" = "yes" ] && xOLDPVERSION='0.0' #110422
  1637. if vercmp ${NEWPVERSION} gt ${xOLDPVERSION} ; then #110422
  1638. echo -e "\\033[1;35m" >/dev/console #35=purple.
  1639. echo "Version cleanup, restoring 'official' files, please wait..." >/dev/console
  1640. echo -en "\\033[0;39m" >/dev/console
  1641. echo "(with a slow CPU this may take sometime, please be patient)" >/dev/console
  1642. #v2.16 do not overwrite rox desktop setup, as /etc/rc.d/rc.update now handles it...
  1643. [ -f $OLDFILESMNTPT/root/Choices/ROX-Filer/PuppyPin ] && touch $OLDFILESMNTPT/root/Choices/ROX-Filer/PuppyPin
  1644. [ -f $OLDFILESMNTPT/root/Choices/ROX-Filer/globicons ] && touch $OLDFILESMNTPT/root/Choices/ROX-Filer/globicons
  1645. mkdir $OLDFILESMNTPT/tmp/versioncleanup
  1646. #make sure that the official boot scripts will be visible at top... 110722 fix...
  1647. rm -f $OLDFILESMNTPT/etc/rc.d/functions
  1648. rm -f $OLDFILESMNTPT/etc/rc.d/functions4puppy4
  1649. rm -f $OLDFILESMNTPT/etc/rc.d/rc.country
  1650. rm -f $OLDFILESMNTPT/etc/rc.d/rc.network_basic
  1651. rm -f $OLDFILESMNTPT/etc/rc.d/rc.services
  1652. rm -f $OLDFILESMNTPT/etc/rc.d/rc.shutdown
  1653. rm -f $OLDFILESMNTPT/etc/rc.d/rc.sysinit
  1654. rm -f $OLDFILESMNTPT/etc/rc.d/rc.update
  1655. #i think if a file exists both in OLDFILESMNTPT and in NEWFILESMNTPT, remove
  1656. #it from OLDFILESMNTPT (as OLDFILESMNTPT is upper layer and will hide the
  1657. #'official' file. But, only do it if 'official' file has a newer modify date...
  1658. cd $NEWFILESMNTPT
  1659. #v2.12 this while-loop has become ultra-slow... seems upx compressed execs
  1660. #responsible, recently upx-ed all the execs, now restore busybox, grep, cp.
  1661. DOTCNT=0
  1662. find ./ -noleaf -type f | sed -e 's/^\.//g' |
  1663. while read ONENEW
  1664. do
  1665. DOTCNT=`expr $DOTCNT + 1`
  1666. [ $DOTCNT -gt 100 ] && DOTCNT=0 #display a dot every time cnts to 100.
  1667. [ $DOTCNT -eq 100 ] && echo -n '*' >/dev/console #v2.12
  1668. #note, screens out spaces also...
  1669. [ ! "`echo -n "$ONENEW" | grep -E '^/dev|^/tmp|^/proc| '`" = "" ] && continue
  1670. ONEBASE="`basename $OLDFILESMNTPT$ONENEW`"
  1671. OLDDIR="`dirname $OLDFILESMNTPT$ONENEW`"
  1672. #a whiteout file 'on top' will hide the 'official' file...
  1673. [ -f $OLDDIR/.wh.$ONEBASE ] && rm -f $OLDDIR/.wh.$ONEBASE
  1674. [ -f $OLDDIR/.wh.__dir_opaque ] && rm -f $OLDDIR/.wh.__dir_opaque #v424 not needed for aufs2
  1675. [ -f $OLDDIR/.wh..wh..opq ] && rm -f $OLDDIR/.wh..wh..opq #110212 recent aufs2, but probably not needed.
  1676. #let's get paranoid and imagine upper-directories also wiped...
  1677. while [ ! "$OLDDIR" = "/" ];do
  1678. OLDDIR="`dirname $OLDDIR`"
  1679. UP1BASE="`basename $OLDDIR`"
  1680. [ -f $OLDDIR/.wh.$UP1BASE ] && rm -f $OLDDIR/.wh.$UP1BASE
  1681. [ -f $OLDDIR/.wh.__dir_opaque ] && rm -f $OLDDIR/.wh.__dir_opaque #v424 not needed for aufs2
  1682. [ -f $OLDDIR/.wh..wh..opq ] && rm -f $OLDDIR/.wh..wh..opq #110212 recent aufs2, but probably not needed.
  1683. done
  1684. #now check for 'old' files on top layer...
  1685. if [ -f $OLDFILESMNTPT$ONENEW ];then
  1686. #note, this is inaccurate due to local timezone not yet set...
  1687. #i got this 'stat' off ibiblio, v3.3. i think older version than in main puppy f.s...
  1688. MODIFOLD=`$PUPFILESDIR/bin/stat -c %Y $OLDFILESMNTPT$ONENEW`
  1689. MODIFNEW=`$PUPFILESDIR/bin/stat -c %Y $NEWFILESMNTPT$ONENEW`
  1690. [ "$PPURGE" = "yes" ] && MODIFNEW=`expr $MODIFOLD + 1` #force overwrite all.
  1691. if [ $MODIFNEW -ge $MODIFOLD ];then
  1692. echo -n " $ONENEW " >/dev/console
  1693. ONEDIR="`dirname $ONENEW`"
  1694. mkdir -p $OLDFILESMNTPT/tmp/versioncleanup$ONEDIR
  1695. cp -af $OLDFILESMNTPT$ONENEW $OLDFILESMNTPT/tmp/versioncleanup$ONEDIR/
  1696. rm -f $OLDFILESMNTPT$ONENEW
  1697. fi
  1698. fi
  1699. done
  1700. echo >/dev/console
  1701. cd /
  1702. fi
  1703. #need to cleanup whiteout files if a new .sfs layer has been added...
  1704. if [ "$NEWUNIONRECORD" != "" -o "$PPURGE" = "yes" ];then
  1705. #find all .wh.__dir_opaque files at the OLDFILESMNTPT layer... v424 bugfixes... 110212 .wh..wh..opq ...
  1706. cd $OLDFILESMNTPT
  1707. find ./ -noleaf -type f -name ".wh.*" | sed -e 's/^\.//g' |
  1708. while read ONEOPAQUE #examples: /usr/src/.wh.__dir_opaque, /usr/src/.wh.bin
  1709. do
  1710. ONEDIR="`dirname $ONEOPAQUE`" #ex: /usr/src
  1711. WHBASE="`basename $ONEOPAQUE`" #ex: .wh.bin
  1712. if [ "$WHBASE" != ".wh.__dir_opaque" -a "$WHBASE" != ".wh..wh..opq" ];then #aufs2 always enter this condition... 110212 extra test.
  1713. #example, .wh.bin alongside bin directory means it is deleted...
  1714. ONEDEL="`echo -n "$WHBASE" | sed -e 's/^\\.wh\\.//g'`" #ex: bin
  1715. ONEDIR="${ONEDIR}/${ONEDEL}" #ex: /usr/src/bin
  1716. [ ! -e ".${ONEDIR}" ] && continue
  1717. fi
  1718. #if same dir exists lower layer, then wipe the opaque file...
  1719. [ -d /pup_ro3${ONEDIR} ] && rm -f ${OLDFILESMNTPT}${ONEOPAQUE}
  1720. [ -d /pup_ro4${ONEDIR} ] && rm -f ${OLDFILESMNTPT}${ONEOPAQUE}
  1721. [ -d /pup_ro5${ONEDIR} ] && rm -f ${OLDFILESMNTPT}${ONEOPAQUE}
  1722. [ -d /pup_ro6${ONEDIR} ] && rm -f ${OLDFILESMNTPT}${ONEOPAQUE}
  1723. [ -d /pup_ro7${ONEDIR} ] && rm -f ${OLDFILESMNTPT}${ONEOPAQUE}
  1724. [ -d /pup_ro8${ONEDIR} ] && rm -f ${OLDFILESMNTPT}${ONEOPAQUE}
  1725. [ -d /pup_ro9${ONEDIR} ] && rm -f ${OLDFILESMNTPT}${ONEOPAQUE}
  1726. done
  1727. cd /
  1728. fi
  1729. if vercmp $NEWPVERSION gt $xOLDPVERSION ; then #110422
  1730. vPATTERN="s%^DISTRO_VERSION=.*%DISTRO_VERSION='${xOLDPVERSION}'%" #110122 mod 110422
  1731. sed -e "$vPATTERN" $OLDFILESMNTPT/etc/DISTRO_SPECS > /tmp/distro_specs_old
  1732. cp -f /tmp/distro_specs_old $OLDFILESMNTPT/etc/DISTRO_SPECS #so rc.update will run.
  1733. sync
  1734. OLDstr='to'
  1735. [ "$xOLDPVERSION" != "0.0" ] && OLDstr="from version $xOLDPVERSION to"
  1736. echo -e "\\033[1;35m" >/dev/console #34=blue, 33=yellow, 32=green, 31=red, 35=purple, 36=aquablue, 38=black.
  1737. [ "$PCLEAN" = "yes" ] && echo "This is a simulated version upgrade, which performs a file cleanup." >/dev/console
  1738. [ "$PPURGE" = "yes" ] && echo "This is a radical file cleanup for broken systems, could alter some settings." >/dev/console
  1739. echo "You are upgrading Puppy ${OLDstr} ${NEWPVERSION}." >/dev/console #110122 mod
  1740. echo "Overwritten old files have been moved to /tmp/versioncleanup/" >/dev/console
  1741. echo "After bootup please examine this directory (before shutdown) for anything that you might like to recover. Pausing 30 secs so you can read this msg..." >/dev/console
  1742. echo -en "\\033[0;39m" >/dev/console
  1743. sleep 30 #so can see above messages.
  1744. fi
  1745. fi
  1746. [ "$RDSH" = "6" ] && exec /bin/sh >/dev/console 2>&1 #w091027
  1747. #create the layered f.s.... ***THE BIG EVENT***
  1748. if [ "$LAYERFS" = "aufs" ];then
  1749. mount -t aufs -o udba=reval,diropq=w,dirs=${UMNTRW}${UMNTRO0}${ALAYER}${YLAYER}${UMNTRO1}${ZLAYER}${UMNTRO} unionfs /pup_new
  1750. else #unionfs
  1751. UMNTRW="`echo -n "$UMNTRW" | sed -e 's/+wh//g'`" #w003 'ro+wh' not accepted by unionfs, change back to 'ro'.
  1752. mount -t unionfs -o dirs=${UMNTRW}${UMNTRO0}${ALAYER}${YLAYER}${UMNTRO1}${ZLAYER}${UMNTRO} unionfs /pup_new
  1753. fi
  1754. check_status $? #END STEP FIVE
  1755. #######################END SETUP UNIONFS LAYERED FILESYSTEM###################
  1756. #101127 pakt: code adapted from bchafy's Xin
  1757. #his description: "A precfg area for faster re-mastering, no need to regenerate a .SFS
  1758. #every time you want to change the core, and no need for a hard drive to store customizations"
  1759. if [ -d $PUPSFSDEVMNTPT/precfg ];then
  1760. echo -n "Overlaying preconfig files..." > /dev/console
  1761. SRC="$PUPSFSDEVMNTPT"/precfg
  1762. DEST="/pup_new"
  1763. cd $SRC
  1764. for i in `find . -not -type d -print`; do
  1765. BASEFILE="$i"
  1766. SRCFILE="$SRC/$BASEFILE"
  1767. DESTFILE="$DEST/$BASEFILE"
  1768. DESTDIR=`dirname $DESTFILE`
  1769. MASK="777"
  1770. if test -f "$DESTFILE"; then
  1771. MASK=`stat -c %a $DESTFILE`
  1772. fi
  1773. mkdir -p $DESTDIR
  1774. cp -f $SRCFILE $DESTFILE
  1775. chmod $MASK $DESTFILE
  1776. done
  1777. check_status 0
  1778. fi
  1779. #END PRECONFIG STEP
  1780. #######################SETUP SWITCH TO MAIN FILESYSTEM#######################
  1781. echo -n "Performing a 'switch_root' to the layered filesystem..." > /dev/console
  1782. #prepare everything for doing a switch_root...
  1783. #cpio archive does switch_root, lose the initial-ramfs, so move all mntd...
  1784. mkdir -p /pup_new/initrd
  1785. mkdir -p /pup_new/initrd/pup_ro1
  1786. mkdir -p /pup_new/initrd/pup_ro2
  1787. mkdir -p /pup_new/initrd/pup_ro3
  1788. mkdir -p /pup_new/initrd/pup_ro4
  1789. mkdir -p /pup_new/initrd/pup_ro5
  1790. mkdir -p /pup_new/initrd/pup_ro6
  1791. mkdir -p /pup_new/initrd/pup_ro7
  1792. mkdir -p /pup_new/initrd/pup_ro8
  1793. mkdir -p /pup_new/initrd/pup_ro9
  1794. mkdir -p /pup_new/initrd/pup_rw
  1795. mkdir -p /pup_new/initrd/pup_z
  1796. mkdir -p /pup_new/initrd/pup_a
  1797. mkdir -p /pup_new/initrd/pup_y
  1798. mkdir -p /pup_new/initrd/mnt
  1799. mkdir -p /pup_new/initrd/mnt/data
  1800. mkdir -p /pup_new/initrd/mnt/dev_ro1
  1801. mkdir -p /pup_new/initrd/mnt/dev_ro2
  1802. mkdir -p /pup_new/initrd/mnt/dev_save
  1803. mkdir -p /pup_new/initrd/mnt/swap
  1804. mkdir -p /pup_new/initrd/mnt/tmpfs
  1805. mkdir -p /pup_new/initrd/mnt/tmpfs2
  1806. mkdir -p /pup_new/initrd/mnt/tmpfs3
  1807. mkdir -p /pup_new/initrd/mnt/tmpfs4
  1808. mkdir -p /pup_new/initrd/mnt/zdrv
  1809. mkdir -p /pup_new/initrd/mnt/adrv
  1810. mkdir -p /pup_new/initrd/mnt/ydrv
  1811. mkdir -p /pup_new/initrd/tmp
  1812. for ONEMNT in `mount | cut -f 3 -d ' ' | grep -v 'pup_new' | grep '^/pup_' | tr '\n' ' '`
  1813. do
  1814. mount -o move $ONEMNT /pup_new/initrd${ONEMNT}
  1815. done
  1816. for ONEMNT in `mount | cut -f 3 -d ' ' | grep '^/mnt/' | tr '\n' ' '`
  1817. do
  1818. mount -o move $ONEMNT /pup_new/initrd${ONEMNT}
  1819. done
  1820. if [ "${PUPSAVEFILE}" -a -d /pup_new/initrd/mnt/dev_save${PUPSAVEFILE} ]; then
  1821. if [ "${CREATEPUPSAVE2FS}" -a -L "${CREATEPUPSAVE2FS}" ]; then
  1822. rm -r -f "/pup_new/initrd${CREATEPUPSAVE2FS}"
  1823. ln -s /initrd/mnt/dev_save${PUPSAVEFILE} /pup_new/initrd${CREATEPUPSAVE2FS} #for after the switch root
  1824. fi
  1825. fi
  1826. #v4.02 bring back, but allocate more space (/4 instead of /8)....
  1827. #v3.97 a problem can run out of /tmp space, remove...
  1828. #to minimise writes to pup_save and to speedup, tmpfs on /tmp...
  1829. if [ "$CREATETMPFS" != "/pup_rw" ];then #test if no tmpfs on unionfs top layer.
  1830. ALLOCK=`expr $RAMSIZE \/ 4 + $EXTRAALLOCK`
  1831. #v424 don't create tmpfs if have versioncleanup dir... 100423 try again...
  1832. [ ! -e /pup_new/tmp/versioncleanup ] && mount -t tmpfs -o size=${ALLOCK}k tmpfs /pup_new/tmp
  1833. fi
  1834. #PNOX is a boot param. /etc/profile prevents X from starting if this file exists...
  1835. [ "$PNOX" = "yes" ] && touch /pup_new/tmp/bootcnt.txt
  1836. cp -a /DISTRO_SPECS /pup_new/initrd/
  1837. cp -a /DISTRO_SPECS /pup_new/etc #james - so we don't duplicate in main SFS
  1838. cp -af /tmp/* /pup_new/initrd/tmp/ #keep any log files.
  1839. #091122
  1840. mkdir -p /pup_new/lib/keymaps
  1841. cp -a -f /lib/keymaps/* /pup_new/lib/keymaps/
  1842. mkdir -p /pup_new/lib/consolefonts
  1843. cp -a -f /lib/consolefonts/* /pup_new/lib/consolefonts/
  1844. if [ "$KMAP" ];then #because PKEYS boot param was defined.
  1845. echo -n "$KMAP" > /pup_new/etc/keymap
  1846. echo -n "$FONTMAP" > /pup_new/etc/fontmap
  1847. echo -n "$CODEPAGE" > /pup_new/etc/codepage
  1848. fi
  1849. #091225 copy exes to main f.s.
  1850. if [ -f /bin/TARGETEXES ];then
  1851. for ONEEXE in `cat /bin/TARGETEXES` #ex: sbin/e2fsck
  1852. do
  1853. BASEEXE="`basename $ONEEXE`"
  1854. [ ! -e /pup_new/$ONEEXE ] && cp -f /bin/$BASEEXE /pup_new/$ONEEXE
  1855. done
  1856. cp -f /bin/TARGETEXES /pup_new/bin/ #100113 puppyinstaller needs this.
  1857. fi
  1858. #120215 if PLANG set here, carry it over...
  1859. if [ "$PLANG" ];then
  1860. langPTN="s%^LANG=.*%LANG=${PLANG}%"
  1861. sed -i -e "$langPTN" /pup_new/etc/profile
  1862. fi
  1863. #110114 if a drive unplugged in previous boot, but plugged in at bootup, device-nodes will be missing in main f.s...
  1864. #james: moves /dev management last, before switch root
  1865. if [ $DEVTMPFSFLG -eq 0 ];then #130612
  1866. cp -a -u -f /dev/* /pup_new/dev/
  1867. fi
  1868. #RDSH is a boot param. exit to initial ramdisk shell...
  1869. if [ "$RDSH" = "yes" ];then
  1870. echo > /dev/console
  1871. echo "Dropped to initramfs shell. Type 'exec switch' to continue booting Puppy." > /dev/console
  1872. exec /bin/sh >/dev/console 2>&1
  1873. fi
  1874. #v3.01 a bit untidy, but cd may still be mounted when it doesn't have to be...
  1875. case $PMEDIA in
  1876. *cd)
  1877. [ "$PDEV1" ] && umount /dev/$PDEV1 2>/dev/null #okay if it fails.
  1878. ;;
  1879. esac
  1880. sync
  1881. #killall -USR1 hotplug2 #v423
  1882. umount /proc/bus/usb
  1883. umount /sys
  1884. umount /dev
  1885. umount /proc
  1886. #now using cpio archive for initramfs 'initial ramdisk'...
  1887. exec switch_root /pup_new /sbin/init
  1888. ###END###