rc.sysinit 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. #!/bin/ash
  2. #(c) copyright Barry Kauler 2008, puppylinux.com
  3. #2008 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  4. #v404 first release. rewritten from scratch, aiming for simplicity and speed.
  5. #v405 fix for alsa.
  6. #v406 load apm.ko if no acpi.
  7. #v408 explicitly load battery, ac, thermal, fan modules.
  8. #v409 gparted create ext3 part. failed, fixed by making /etc/mtab a symlink.
  9. #v411 fix mouse detection logic.
  10. #v411 can use old network wizard (from 403, based on 400)
  11. #v411 return of 'puppyserialdetect', for usb/ps2 mouse detection only. now 'puppyinputdetect'.
  12. #v411 extra 'sleep 1' as rerwin reports usb mouse may need it some hardware.
  13. #v411 choosemousefunc().
  14. #v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
  15. #v412 bugfix usb-storage wait loop.
  16. #w001 ubuntu module-init-tools not configured to support gzipped modules.
  17. #w004 LANG=C, faster. /bin/ash, even faster.
  18. #w463 rerwin: special mwave modem handling.
  19. #w463 mouse scrollwheel fix.
  20. #w468 full-hd-install, write to PUPSTATE after remount r/w.
  21. #w478 moved depmod code up above call to rc.update.
  22. #w481 fix crappy depmod, 'out of memory' in first boot 64MB RAM (no swap).
  23. #v423 k2.6.29.6 dmesg has warning that ehci-hcd should load before uhci-hcd and ohci-hid.
  24. #v424 fix LAYERFS variable.
  25. #v424 fix secondary uevent replay. now finds ssb devices.
  26. #v431 secondary uevent replay, fix for old kernels < 2.6.24
  27. #v432 make alsa-card-number generation multithread-safe; start modprobe protection/serialization daemon
  28. #100126 move syslogd, klogd to /etc/init.d/00sys_logger
  29. #100127 anticipate bug gunzip modules from initrd.
  30. #100131 bugfix detect multiple cd/dvd drives.
  31. #100214 one config of 2.6.33 has base floppy and ps/2 mouse support not builtin.
  32. #100216 jemimah's Pwireless2 now supported. 100217 slight modification.
  33. #100227 integrate /usr/local/bin/defaultconnect for setup tool choice.
  34. #100228 rerwin: make alsa-card-number generation multithread-safe; start modprobe protection/serialization daemon
  35. #100304 modify pwireless choice. 100306 added Simple Network Setup.
  36. #100316 perform f.s. check if improper shutdown. 100319 unset TZ, always load /dev/shm.
  37. #100513 test to prevent msg on stderr.
  38. #100611 UDEV_LOG=2 to prevent non-critical o/p to screen at bootup and shutdown.
  39. #100628 shinobar: launch rc.network if eth0 is usable.
  40. #100703 load fbcon module: needed by some xorg drivers when exit to console (ex: nouveau).
  41. #100814 record cumulative tx/rx, see also network_tray and rc.shutdown.
  42. #100831 fix KERNMAJ for olpc people, have 'uname -r' returning version with '_'.
  43. #100903 rerwin: acc tx/rx added pupdial support.
  44. #100908 rerwin: -7.5-fix modem patch.
  45. #100911 fsckme.err filename changed to fsckme.flg. see also initNEW, init (initramfs), rc.shutdown.
  46. #101007 Network detection improvements from shinobar.
  47. #101012 have restored 'depmod-FULL' name to 'depmod'.
  48. #101107 rerwin: Reset alsa card numbers, but retain wizard card assignments in alsa.conf.
  49. #101119 /sbin/pup_event_backend_modprobe has been rewritten, repercussions here.
  50. #101202 hack, remove some firmware tarballs. ***TEMPORARY HACK***
  51. #101210 new path /tmp/pup_event_backend for files logged by /sbin/pup_event_backend_*.
  52. #101216 mkdir /tmp/simple_network_setup.
  53. #110113 make sure /dev/mixer removed, see test in /etc/init.d/10alsa.
  54. #110126 fix ATADRIVES variable for full-hd installation.
  55. #110302 wasn't getting the right uevents for my 3g modem, use 'udevadm trigger'.
  56. #110304 remove nodes in /dev/snd -- reports that these may be wrong after a reboot.
  57. #110405 fix 'free' applet output format different in later versions of busybox.
  58. #110426 move done/failed/backgrounded 2 places to right (also in init script).
  59. #110430 fixups for fido (non-root user). 110503 removed.
  60. #110502 fix creation of owner:group for device nodes. 110503 fix permission fsckme.flg.
  61. #110511 2nd uevent replay: now using udevadm for usb, ssb and pcmcia.
  62. #110513 rcrsn51: udevadm usb replay fix, properly detect scanners etc.
  63. #110712 fixes for kernel with usb core (including usb-storage) drivers builtin.
  64. #110722 get rid of stray modules.* files, may occur when mix usage of the two depmods.
  65. #110814 01micko: ensure unique hostname.
  66. #110814 kernel with inbuilt usb drivers, usbfs was not mounting on /proc/bus/usb.
  67. #110823 mavrothal: Check if it is an OLPC XO and add the devices.
  68. #120124 tracing problem of b43 firmware not loading, peebee posted udev trace, determined ssb uevent replay missing, found test for <2.6.24 kernel broken for 3.x.
  69. #120216 slight mods to make sss translation easy (see /usr/share/sss/script_strings).
  70. #120217 improvement for full hd install, non-english.
  71. #120301 need to load console font earlier.
  72. #120301 a problem if initrd has kernel default font, switching here changes all o/p from initrd to partial garbage.
  73. #120313 fix 120301 font garbage. 120331 clear requires redirection to /dev/console.
  74. #120409 no longer deleting /tmp/* in rc.shutdown... (note, init script in initrd.gz wipes it)
  75. #120423 pemasu: /dev/mouse was missing in full install.
  76. #120503 if kernel mounts a f.s. on /dev, removes my skeleton /dev
  77. #120505 remove network reconnect flag if it exists.
  78. #120704 introduce /etc/rc.d/BOOTCONSTRAINED. written by 3builddistro.
  79. #120706 removed some sync's, think they are bad idea in this script.
  80. #120709 BOOT_UDEVDCHILDREN from /etc/rc.d/BOOTCONSTRAINED
  81. #120716 log size of ram, read by /sbin/initNEW for f.s. check.
  82. #120717 log ext2,3,4 f.s. that have reached maximal mount count.
  83. #130201 quieten the 'modinfo ehci_hcd'.
  84. #130311 use modinfo to test if fbcon builtin.
  85. #130318 support kmod (see also 3builddistro, rc.update).
  86. #130501 support setting up X in PUPMODE=5. further fixup.
  87. #130504 moved up, i think fbcon needs to be loaded before intel, nouveau modules load.
  88. #130509 quicksetup creates pupdesk.flg with auto-selected driver stored in it. xorgwizard-cli reads this.
  89. #130513 remove 130509, code now in init script in initrd.
  90. #130513 init in initrd creates /root/.xorgwizard-reenter, need to ask kbd/locale even though auto-X at 1st boot...
  91. #130618 3builddistro sets 'DEVTMPFSFLG' variable.
  92. #130629 need directory /tmp/pup_event_ipc, to support new pup_event IPC.
  93. #130630 bring back tmpfs on /tmp for full HD installation.
  94. # always use devtmpfs
  95. mount -t devtmpfs devtmpfs /dev
  96. DEVTMPFSFLG=1
  97. #unset TZ #100319 busybox hwclock gives priority to this (rather than /etc/localtime) and 'init' has set it wrong.
  98. #...comment-out for now. note, TZ now set in rc.country.
  99. ORIGLANG="`grep '^LANG=' /etc/profile | cut -f 2 -d '=' | cut -f 1 -d ' '`" #120217
  100. ORIGLANG1="${ORIGLANG%_*}" #ex: en
  101. export LANG=C
  102. . /etc/rc.d/functions4puppy4
  103. . /etc/DISTRO_SPECS
  104. . /etc/rc.d/BOOTCONSTRAINED #120704 has BOOT_DISABLESWAP, BOOT_ATIME, BOOT_DIRTYWRITE.
  105. status_func() {
  106. if [ $1 -eq 0 ];then
  107. /bin/echo -n -e "\\033[74G\\033[1;32m" >/dev/console #green [done] msg. 110426: change 72 to 74.
  108. /bin/echo -n "done" >/dev/console #done
  109. /bin/echo -e "\\033[0;39m" >/dev/console
  110. else
  111. /bin/echo -n -e "\\033[72G\\033[1;31m" >/dev/console #red [failed]. 110426: change 70 to 72.
  112. /bin/echo -n "failed" >/dev/console #failed
  113. /bin/echo -e "\\033[0;39m" >/dev/console
  114. STATUS=0
  115. fi
  116. return $1 #return with same status as entry param.
  117. }
  118. loadswap_func() { #w481 made into a function.
  119. echo "LOAD SWAP"
  120. #load a swap partition...
  121. for ONESWAP in `fdisk -l | grep ' Linux swap' | cut -f 1 -d ' ' | tr '\n' ' '`
  122. do
  123. echo -n "Loading swap partition $ONESWAP..." >/dev/console #loading swap partition
  124. swapon $ONESWAP
  125. status_func $?
  126. [ $? -eq 0 ] && SWAPON="yes"
  127. done
  128. #if no go, try for a swap file...
  129. if [ "$SWAPON" != "yes" ];then
  130. SWAPFILE="/pupswap.swp"
  131. if [ -f /initrd${PUP_HOME}${SWAPFILE} ];then
  132. echo -n "Loading swap file ${SWAPFILE}..." >/dev/console #loading swap file
  133. swapon /initrd${PUP_HOME}${SWAPFILE}
  134. status_func $?
  135. [ $? -eq 0 ] && SWAPON="yes"
  136. fi
  137. if [ -f $SWAPFILE ];then
  138. echo -n "Loading swap file ${SWAPFILE}..." >/dev/console
  139. swapon $SWAPFILE
  140. status_func $?
  141. [ $? -eq 0 ] && SWAPON="yes"
  142. fi
  143. fi
  144. }
  145. #if have just done a switch_root, output a 'done' message...
  146. [ -d /initrd ] && status_func 0 #note, /initrd does not exist when a full-hd installation.
  147. . /etc/rc.d/MODULESCONFIG #modules loading configuration.
  148. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin
  149. [ $loglevel ] && LOGLEVEL=$loglevel #boot param.
  150. [ $pmedia ] && PMEDIA=$pmedia #boot parameter, broad category of boot media. ex: cd.
  151. [ $pdev1 ] && PDEV1=$pdev1 #boot parameter, partition have booted off. ex: hda3
  152. #120301 a problem if initrd has kernel default font, switching here changes all o/p from initrd to partial garbage.
  153. #workaround, clear the screen...
  154. if [ -d /initrd ];then #120313 fix...
  155. PLANG1=`grep '^PLANG=' /etc/rc.d/PUPSTATE | cut -f 2 -d '=' | cut -f 1 -d '_'`
  156. [ ! "$PLANG1" ] && PLANG1='en'
  157. [ "$ORIGLANG1" != "$PLANG1" ] && clear > /dev/console #120331 redirection is required.
  158. fi
  159. load_consolefont #120301 if this was done in initrd then it would carry through, and this would not be needed.
  160. #...this is done in rc.country, but needs to be move above all the o/p to /dev/console.
  161. STATUS=0
  162. ##############MAKE FILESYSTEM USABLE################
  163. #echo "MAKE FILESYSTEM USABLE"
  164. echo -n "Making the filesystem usable..." >/dev/console #making filesystem usable. need this redirection!
  165. busybox mount -t proc none /proc ;STATUS=$((STATUS+$?))
  166. if [ ! -d /initrd ];then #w468
  167. if [ "$BOOT_ATIME" ];then #120704 see /etc/rc.d/BOOTCONSTRAINED, variable set in 3builddistro.
  168. busybox mount -o remount,rw,${BOOT_ATIME} / #have set this to 'relatime'.
  169. else
  170. busybox mount -o remount,rw /
  171. fi
  172. #120409 no longer deleting /tmp/* in rc.shutdown... (note, init script in initrd.gz wipes it)
  173. rm -rf /tmp/*
  174. rm -rf /tmp/.[0-9a-zA-Z]*
  175. echo 'PUPMODE=2' > /etc/rc.d/PUPSTATE
  176. if [ "$ORIGLANG1" != "en" ];then #120217
  177. echo "OUTPUT_CHARSET=UTF-8
  178. export OUTPUT_CHARSET" >> /etc/rc.d/PUPSTATE
  179. fi
  180. fi
  181. . /etc/rc.d/PUPSTATE #variables created at bootup by init script in initrd.
  182. if [ "$BOOT_DIRTYWRITE" ];then #120704 see /etc/rc.d/BOOTCONSTRAINED, variable set in 3builddistro.
  183. #i have set this as 1500 which is 15 seconds (default is 5 seconds).
  184. echo $BOOT_DIRTYWRITE > /proc/sys/vm/dirty_writeback_centisecs #refer: http://www.lesswatts.org/tips/disks.php
  185. fi
  186. #v409 mount/umount scripts no longer write to /etc/mtab, as gparted failed to create a
  187. #ext3 partition -- dunno why. Instead, now have /etc/mtab a symlink to /proc/mounts...
  188. rm -f /etc/mtab
  189. ln -s /proc/mounts /etc/mtab
  190. #redirect all output to a log file (must do after remount rw)...
  191. [ ! "$LOGLEVEL" ] && exec 1>/tmp/bootsysinit.log 2>&1
  192. mkdir -p /dev/pts #120503 if kernel mounts a f.s. on /dev, removes my skeleton /dev
  193. busybox mount /dev/pts ;STATUS=$((STATUS+$?))
  194. mkdir /sys 2>/dev/null
  195. busybox mount -t sysfs none /sys ;STATUS=$((STATUS+$?))
  196. ##v2.20 some apps need shm (shared memory) (ex: xfdiff)... 100319 do this always...
  197. FREERAM=`free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 4 -d ' '` #w481 110405
  198. QTRFREERAM=`expr $FREERAM \/ 4`
  199. mkdir -p /dev/shm #120503 if kernel mounts a f.s. on /dev, removes my skeleton /dev
  200. mount -t tmpfs -o size=${QTRFREERAM}k shmfs /dev/shm ;STATUS=$((STATUS+$?))
  201. if [ ! -d /initrd ];then
  202. #130630 restore tmpfs on /tmp...
  203. #120717 this is not so good on raspi with only 256MB RAM, but saves flash writes and faster...
  204. mount -t tmpfs -o size=${QTRFREERAM}k tmpfs /tmp ;STATUS=$((STATUS+$?))
  205. #120716 /sbin/init needs to know ramdisk size, before /sys mounted...
  206. [ ! -f /var/local/ram_size_bytes ] && [ -e /sys/block/ram0/size ] && cat /sys/block/ram0/size > /var/local/ram_size_bytes
  207. #120717 log maximal mount counts, potentially rc.shutdown can then not delete /fsckme.flg...
  208. #dmesg | grep -o 'EXT[2,3,4]-fs.*running e2fsck is recommended' > /tmp/dmesg_e2fsck_warnings1
  209. dmesg | grep -o 'EXT[2,3,4]-fs.*maximal mount count reached' > /tmp/dmesg_e2fsck_warnings1
  210. #example lines:
  211. #EXT3-fs (sda9): warning: mounting fs with errors, running e2fsck is recommended
  212. #EXT3-fs (sda10): warning: maximal mount count reached, running e2fsck is recommended
  213. fi
  214. #w478 moved this code above call to rc.update...
  215. KERNVER="`uname -r`"
  216. #w469 may need to run 'depmod'...
  217. #live-cd may have been built without the modules.* files.
  218. #initrd init script copied modules to /lib/modules/<kernver>/initrd/.
  219. if [ ! -f /lib/modules/${KERNVER}/modules.dep ];then
  220. NEEDDEPMOD="yes" #w469 files may not be there to save space.
  221. [ -d /lib/modules/${KERNVER}/initrd ] && NEEDGUNZIP="yes"
  222. elif [ -d /lib/modules/${KERNVER}/initrd ];then
  223. #100127 remove leading '/' from '/initrd/' for comaptibility with depmod-FULL...
  224. if [ "`cat /lib/modules/${KERNVER}/modules.dep | cut -f 1 -d ':' | grep 'initrd/'`" = "" ];then
  225. NEEDDEPMOD="yes" #w469 files may not be there to save space.
  226. NEEDGUNZIP="yes"
  227. fi
  228. fi
  229. if [ "$NEEDGUNZIP" = "yes" ];then
  230. gunzip -f -r /lib/modules/${KERNVER}/initrd #w482 shinobar.
  231. fi
  232. #101012 have restored depmod-FULL name to 'depmod'...
  233. if [ "$NEEDDEPMOD" = "yes" ];then
  234. echo -n ' depmod' >/dev/console
  235. if which kmod;then #130418
  236. #do not use busybox depmod, ever.
  237. depmod #should be linked to kmod.
  238. else
  239. #110722 get rid of stray modules.* files, may occur when mix usage of the two depmods...
  240. mkdir -p /tmp/rc_sysinit_dump
  241. mv -f /lib/modules/${KERNVER}/modules.* /tmp/rc_sysinit_dump
  242. [ -f /tmp/rc_sysinit_dump/modules.builtin ] && mv -f /tmp/rc_sysinit_dump/modules.builtin /lib/modules/${KERNVER}/
  243. [ -f /tmp/rc_sysinit_dump/modules.order ] && mv -f /tmp/rc_sysinit_dump/modules.order /lib/modules/${KERNVER}/
  244. rm -f /tmp/rc_sysinit_dump/modules.*
  245. if [ "`busybox | grep 'depmod'`" != "" ];then
  246. busybox depmod #use busybox depmod if available.
  247. else
  248. depmod
  249. fi
  250. fi
  251. fi
  252. [ $layerfs ] && LAYERFS=$layerfs #boot param.
  253. [ ! $LAYERFS ] && LAYERFS=aufs #aufs or unionfs
  254. [ "`modinfo aufs 2>/dev/null`" = "" ] && LAYERFS=unionfs #precaution.
  255. status_func $STATUS
  256. #Load fstab entries
  257. mount -a
  258. #######################VERSION UPDATE##########################
  259. echo "VERSION UPDATE"
  260. #force update when new version of ${DISTRO_NAME}...
  261. echo -n "Updating..." >/dev/console #updating
  262. /etc/rc.d/rc.update $PUPMODE
  263. #sync
  264. status_func $STATUS
  265. #110814 01micko: http://www.murga-linux.com/puppy/viewtopic.php?p=550932#550932
  266. if [ "`cat /etc/hostname`" = "puppypc" ];then
  267. echo -n "Updating unique hostname..." >/dev/console #hostname
  268. echo "puppypc${RANDOM}" > /etc/hostname
  269. PUPHOSTNAME="`cat /etc/hostname`"
  270. HOSTSFILEFIRST="`grep -w 'puppypc' /etc/hosts|sed 's% puppypc%%'`"
  271. HOSTSFILEREST="`grep -v 'puppypc' /etc/hosts`"
  272. echo "$HOSTSFILEFIRST $PUPHOSTNAME" > /etc/hosts
  273. echo "$HOSTSFILEREST" >> /etc/hosts
  274. status_func 0
  275. fi
  276. #Ensure kernel-specific firmware.dep file present.
  277. [ ! -e /etc/modules/firmware.dep.$KERNVER ] \
  278. && mv -f /etc/modules/firmware.dep /etc/modules/firmware.dep.$KERNVER
  279. #101202 hack, remove some firmware tarballs, no longer used...
  280. #dgcmodem: i have removed the /etc/init.d/Dgcmodem script from firmware tarball (so don't delete it).
  281. #refer: /usr/sbin/pupdial_init_hotpluggable.
  282. for ONEFIRM in cdcacm hso ipwireless nozomi usbserial
  283. do
  284. if [ -f /lib/modules/all-firmware/${ONEFIRM}.tar.gz ];then
  285. rm -f /lib/modules/all-firmware/${ONEFIRM}.tar.gz
  286. ofPATTERN='/^'"${ONEFIRM}"':/d'
  287. sed -i -e "$ofPATTERN" /etc/modules/firmware.dep.$KERNVER
  288. fi
  289. done
  290. #################LOAD KERNEL MODULES################
  291. echo "LOAD KERNEL MODULES"
  292. echo -n "Loading kernel modules..." >/dev/console
  293. MODALIASES="`ls /sys/bus/*/devices/*/modalias`"
  294. #101119 new /sbin/pup_event_backend_modprobe, these must be deleted every boot...
  295. rm -f /etc/modprobe.d/alsa_card*.conf 2>/dev/null
  296. touch /etc/modules/firmware.dep.inst.${KERNVER} #make sure exists.
  297. rm -f /dev/ttyUSB* 2>/dev/null #101210 may have been left there if modem plugged in at shutdown.
  298. rm -f /dev/mixer 2>/dev/null #110113 make sure removed, see test in /etc/init.d/10alsa.
  299. rm -f /dev/snd/* #110304 after a reboot, some of these may be wrong.
  300. mkdir /tmp/rc_sysinit #101210 for logging into.
  301. mkdir /tmp/pup_event_backend #101210 for logging into, see /sbin/pup_event_backend_modprobe.
  302. mkdir /tmp/simple_network_setup #101216
  303. mkdir -p /tmp/pup_event_ipc #130629 for new pup_event IPC.
  304. #101119 no longer using /tmp/pup_event_modprobe.conf, put blacklist into /etc/modprobe.d/...
  305. rm -f /etc/modprobe.d/blacklist*.conf
  306. BLACKLISTVARS="`echo "$SKIPLIST" | tr '\-' '_' | tr ' ' '\n' | sed -e 's/^/blacklist /' | grep -v ' $'`"
  307. echo "$BLACKLISTVARS" > /etc/modprobe.d/blacklist.conf
  308. if [ ! -d /initrd ];then #v423 full hd install.
  309. #100214 one config of 2.6.33 has base floppy and ps/2 mouse support not builtin. have this in 'init' also...
  310. [ "`modinfo floppy 2>/dev/null`" != "" ] && modprobe floppy > /dev/null 2>&1
  311. [ "`modinfo psmouse 2>/dev/null`" != "" ] && modprobe psmouse
  312. #v423 have this in 'init', probably need here too...
  313. if [ "`echo "$MODALIASES" | grep 'bc0Csc03i10'`" != "" ];then
  314. modprobe yenta-socket #101119
  315. [ $? -eq 0 ] && sleep 2
  316. fi
  317. #v423 k2.6.29.6 dmesg has warning that ehci-hcd should load before uhci-hcd and ohci-hid
  318. # this is contrary to my understanding all these years, but oh well, let's do it...
  319. ELSPCI="`elspci -l`" #jesses great little utility.
  320. [ "`echo "$ELSPCI" | grep '0C0320'`" != "" ] && modprobe ehci-hcd > /dev/null 2>&1 #110712 maybe builtin to kernel.
  321. #...perhaps a udev rule could have done this?
  322. fi
  323. #130504 moved up, i think fbcon needs to be loaded before intel, nouveau modules load...
  324. #101119 i really only want to load this for a kms-enabled video...
  325. KMS=no
  326. [ "`cat /proc/cmdline | grep 'modeset=1'`" != "" ] && KMS=yes
  327. [ "`cat /etc/modprobe.d/* | grep '^options .* modeset=1'`" != "" ] && KMS=yes
  328. [ "$KMS" = "yes" ] && [ "`modinfo fbcon 2>/dev/null`" != "" ] && modprobe fbcon #100703 needed by some xorg drivers when exit to console (ex: nouveau). 110712 maybe builtin. 130311 maybe builtin.
  329. #130618 devtmpfs-enabled kernel, initrd may have loaded it on /dev, if DEVTMPFSFLG<>0.
  330. if [ $DEVTMPFSFLG -ne 0 ];then
  331. #device nodes created by kernel in initrd are all 'root' group. fix (before starting udevd)...
  332. chmod 660 /dev/* 2>/dev/null
  333. chmod 666 /dev/null
  334. chmod 666 /dev/zero
  335. chgrp tty /dev/[pt]ty*
  336. chgrp tty /dev/console #bugfix 140617
  337. chgrp video /dev/fb0
  338. chgrp floppy /dev/fd[0-9]
  339. chgrp disk /dev/[hs]d[a-z]*
  340. chgrp disk /dev/fuse
  341. chgrp disk /dev/mmcblk*
  342. chgrp cdrom /dev/sr[0-9]
  343. chmod 666 /dev/usb/* #rcrsn51 finally added 140618
  344. chmod -R 1777 /dev/shm #SFR .. ditto
  345. chmod 666 /dev/urandom #and again
  346. fi
  347. #my intention is for puppy to work with either of these...
  348. if [ -f /sbin/udevd ];then
  349. #100611 UDEV_LOG=2 to prevent non-critical o/p to screen at bootup and shutdown...
  350. UDEVVER=`udevd --version`
  351. if [ $UDEVVER -gt 150 ];then
  352. #100611 v151 is recommended for kernel 2.6.27+.
  353. #110502 change 'never' to 'early', fixes device nodes created with correct owner:group...
  354. if [ "$BOOT_UDEVDCHILDREN" ];then #120709
  355. UDEV_LOG=2 /sbin/udevd --daemon --resolve-names=early --children-max=${BOOT_UDEVDCHILDREN} #BOOT_UDEVDCHILDREN=1 good idea?
  356. else
  357. UDEV_LOG=2 /sbin/udevd --daemon --resolve-names=early
  358. fi
  359. else
  360. UDEV_LOG=2 /sbin/udevd --daemon
  361. fi
  362. else
  363. #note, this script is no longer in Puppy.
  364. pup_event_backend_d >/tmp/pup_event_backend_errors 2>&1 & #hotplug daemon. my homebrew replacement for udevd.
  365. fi
  366. sleep 0.1
  367. #replay uevents from /sys...
  368. for ONEMODALIAS in $MODALIASES
  369. do
  370. ONEPATH="`dirname $ONEMODALIAS`"
  371. if [ -e ${ONEPATH}/uevent ];then
  372. echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
  373. sleep 0.02
  374. fi
  375. done
  376. if [ ! -d /initrd ];then #full hd installation.
  377. modprobe nls_cp437 > /dev/null 2>&1 #these needed by vfat/ntfs/ext2 f.s.'s. 110712 maybe builtin.
  378. modprobe nls_iso8859-1 > /dev/null 2>&1 # "
  379. modprobe fuse
  380. modprobe $LAYERFS #unionfs or aufs.
  381. modprobe squashfs
  382. #we can determine ide/sata drives at this point (drivers builtin to kernel)...
  383. #110126 define ATADRIVES as all internal ide/pata/sata drives (not usb), except optical...
  384. #110712 rewritten to handle kernel with usb driver built-in...
  385. 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!
  386. ALLDRVS="`echo "$ALLDRVS0" | tr '\n' ' '`" #all *except* usb!
  387. [ "$ALLDRVS" = " " ] && ALLDRVS=""
  388. ATADRIVES="`echo "$ALLDRVS0" | grep -v '^sr' | tr '\n' ' '`"
  389. [ "$ATADRIVES" = " " ] && ATADRIVES=""
  390. ATAOPTICALDRIVES="`echo "$ALLDRVS0" | grep '^sr' | tr '\n' ' '`"
  391. [ "$ATAOPTICALDRIVES" = " " ] && ATAOPTICALDRIVES=""
  392. if [ -e /proc/ide ];then #110126
  393. for ONEIDE in `ls -1 /proc/ide | grep '^hd' | tr '\n' ' '`
  394. do
  395. if [ "`cat /proc/ide/${ONEIDE}/media`" = "cdrom" ];then
  396. ATAOPTICALDRIVES="${ATAOPTICALDRIVES}${ONEIDE} "
  397. else
  398. ATADRIVES="${ATADRIVES}${ONEIDE} "
  399. fi
  400. done
  401. fi
  402. ATADRIVES0="`echo -n "$ATADRIVES" | tr ' ' '\n'`"
  403. ATAOPTICALDRIVES0="`echo -n "$ATAOPTICALDRIVES" | tr ' ' '\n'`"
  404. echo '#ATADRIVES is all internal ide/pata/sata drives, excluding optical, excluding usb...' >> /etc/rc.d/PUPSTATE
  405. echo "ATADRIVES='${ATADRIVES}'" >> /etc/rc.d/PUPSTATE
  406. echo '#ATAOPTICALDRIVES is list of non-usb optical drives...' >> /etc/rc.d/PUPSTATE #110206
  407. echo "ATAOPTICALDRIVES='$ATAOPTICALDRIVES'" >> /etc/rc.d/PUPSTATE
  408. fi
  409. [ ! -d /proc/acpi ] && modprobe apm #v406
  410. #110823 mavrothal: Check if it is an OLPC XO and add the devices...
  411. ISITANXO=`cat /sys/class/dmi/id/product_name`
  412. if [ "$ISITANXO" = "XO" ] && [ $UDEVVER -gt 150 ] ; then
  413. udevadm trigger --action=add --subsystem-match="input" --subsystem-match="sound"
  414. udevadm settle
  415. fi
  416. status_func 0
  417. ######################LOAD SWAP#####################
  418. [ "$BOOT_DISABLESWAP" ] && SWAPON="$BOOT_DISABLESWAP" #120704 now ask in 3builddistro if want use swap file/partition. anything not "yes" means no.
  419. [ "$SWAPON" != "yes" ] && loadswap_func
  420. #################MISC. SYSTEM SETUP#################
  421. echo "MISC. SYSTEM SETUP"
  422. #100126 moved to /etc/init.d/00sys_logger...
  423. #syslogd -m 0
  424. #klogd
  425. echo -e "${DISTRO_NAME} Linux\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue
  426. echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  427. hostname -F /etc/hostname
  428. rm -f /mnt/home 2>/dev/null
  429. if [ ! -d /initrd ];then
  430. PUP_HOME='/'
  431. echo "PUP_HOME='/'" >> /etc/rc.d/PUPSTATE
  432. ln -s / /mnt/home
  433. else
  434. if [ "$PUP_HOME" ];then #see /etc/rc.d/PUPSTATE
  435. if [ "$PUP_HOME" = "/pup_ro1" -o "$PUP_HOME" = "/pup_rw" ];then
  436. #note, PUPMODE=6 will have PUP_HOME=/pup_rw.
  437. #in the case of the persistent storage being the partition itself, this will be mounted
  438. #on /initrd/pup_ro1 (tmpfs on pup_rw for restricted writes) or directly on /initrd/pup_rw
  439. #and we do not really want users to access it as it is a unionfs layer. Instead, they are
  440. #already accessing it as "/".
  441. ln -s / /mnt/home
  442. else
  443. ln -s /initrd${PUP_HOME} /mnt/home
  444. fi
  445. fi
  446. fi
  447. ################WAIT MODULES LOADED##################
  448. echo "WAIT MODULES LOADED"
  449. #previous module loading may not have completed...
  450. echo -n "Waiting for modules to complete loading..." >/dev/console
  451. WAITCNT=0
  452. PCIPCMCIA="`elspci -l | grep -o '060700'`"
  453. if [ "$PCIPCMCIA" != "" ];then #this may be slow to respond.
  454. echo -n " pcmcia" >/dev/console
  455. while [ $WAITCNT -lt 10 ];do
  456. [ "`lsmod | grep -E '^yenta_socket |^tcic |^i82092 |^i82365 |^pd6729 '`" != "" ] && break
  457. WAITCNT=`expr $WAITCNT + 1`
  458. sleep 1
  459. echo -n " $WAITCNT" >/dev/console
  460. done
  461. fi
  462. PCIUSB="`elspci -l | grep -o -E '0C0300|0C0310|0C0320'`"
  463. #note, if initrd then usb-storage will have already loaded...
  464. USBBUILTIN='no'
  465. if [ "`modinfo ehci_hcd 2>/dev/null`" = "" ];then #110712 130201 shut this up.
  466. #kernel has usb core drivers (and usb-storage) builtin.
  467. USBBUILTIN='yes'
  468. else
  469. if [ "$PCIUSB" != "" ];then #this may be slow to respond.
  470. echo -n " usb" >/dev/console
  471. PCIUSBNUM=`echo "$PCIUSB" | sort -u | wc -l`
  472. while [ $WAITCNT -lt 10 ];do
  473. [ `lsmod | grep -o -E '^uhci_hcd|^ohci_hcd|^ehci_hcd' | wc -l` -ge $PCIUSBNUM ] && break
  474. WAITCNT=`expr $WAITCNT + 1`
  475. sleep 1
  476. echo -n " $WAITCNT" >/dev/console
  477. done
  478. fi
  479. fi
  480. if vercmp $KERNVER lt '2.6.24';then #120124
  481. [ -e /sys/bus/pcmcia/devices ] && NEWPCMCIA="`ls /sys/bus/pcmcia/devices/*/modalias | tr '\n' ' '`"
  482. [ -e /sys/bus/usb/devices ] && NEWUSB="`ls /sys/bus/usb/devices/*/modalias | tr '\n' ' '`"
  483. for ONEMODALIAS in ${NEWPCMCIA}${NEWUSB}
  484. do
  485. ONEPATH="`dirname $ONEMODALIAS`"
  486. if [ -e ${ONEPATH}/uevent ];then
  487. echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
  488. sleep 0.02
  489. fi
  490. done
  491. else
  492. #110511 now using udevadm for usb, ssb and pcmcia... 110513 keep ssb as before...
  493. #v424 try it a different way, this also fixes ssb devices (such as b43.ko)...
  494. [ -e /sys/bus/ssb/devices ] && NEWSSB="`ls /sys/bus/ssb/devices/*/uevent 2>/dev/null | tr '\n' ' '`"
  495. for ONEUEVENT in ${NEWSSB} #${NEWPCMCIA}${NEWUSB}${NEWSSB} #110511
  496. do
  497. ONEPATH="`dirname $ONEUEVENT`"
  498. #the check for 'modalias' file is maybe needed for old kernel?...
  499. [ ! -e ${ONEPATH}/modalias ] && [ "`grep 'MODALIAS' $ONEUEVENT`" = "" ] && continue
  500. echo add > $ONEUEVENT
  501. sleep 0.02
  502. done
  503. # #110302 wasn't getting the right uevents for my 3g modem...
  504. # udevadm trigger --action=add --subsystem-match=usb
  505. # #TODO i think need this:
  506. udevadm trigger --action=add --subsystem-match="pcmcia*" --subsystem-match="usb*"
  507. fi
  508. if [ "$USBBUILTIN" = "no" ];then #110712
  509. #wait for usb-storage drives to become available...(already done if initrd)
  510. #note, pup_event_backend_d and udevd both log to this file when load modules
  511. # (the latter via udev handler script /sbin/pup_event_backend_modprobe)...
  512. #101119 /tmp/pup_event_backend/pup_event_module_devpath_log* now multiple files (see /sbin/pup_event_backend_modprobe)
  513. if [ "`cat /tmp/pup_event_backend/pup_event_module_devpath_log* | grep 'usb_storage'`" != "" ];then #see pup_event_backend_modprobe
  514. echo -n " usb-storage" >/dev/console
  515. while [ $WAITCNT -lt 15 ];do
  516. [ "`dmesg | grep 'usb-storage: device scan complete'`" != "" ] && break
  517. sleep 1
  518. WAITCNT=`expr $WAITCNT + 1`
  519. echo -n " $WAITCNT" >/dev/console
  520. done
  521. #precaution, make sure have got them all... v412 need sort -u...
  522. USBSTORAGES=`/bin/dmesg | grep "usb-storage: device found at" | sort -u | wc -l`
  523. while [ $WAITCNT -lt 15 ];do
  524. AVAILABLEUSBSTORAGES=`/bin/dmesg | grep "usb-storage: device scan complete" | wc -l`
  525. [ $AVAILABLEUSBSTORAGES -ge $USBSTORAGES ] && break
  526. sleep 1
  527. WAITCNT=`expr $WAITCNT + 1`
  528. echo -n " $WAITCNT" >/dev/console
  529. done
  530. fi
  531. sleep 1 #v411 a bit extra. rerwin reports usb mouse detection problem some hardware.
  532. #(delay before usb mouse info appears in /proc/bus/input/devices)
  533. fi
  534. status_func 0
  535. ##############USER SELECTED MODULES##################
  536. echo "USER SELECTED MODULES"
  537. #the user can select extra modules to load in the BootManager...
  538. if [ "$ADDLIST" != "" ];then #variable is in /etc/rc.d/MODULESCONFIG
  539. echo -n "Loading user-selected modules..." >/dev/console
  540. for MODULE in $ADDLIST
  541. do
  542. MPARAMS=""
  543. if [ `echo -n "$MODULE" | tr ':' ' ' | wc -w` -gt 1 ];then
  544. MPARAMS="`echo -n "$MODULE" | cut -f 2-9 -d ':' | tr ':' ' '`"
  545. MODULE="`echo -n "$MODULE" | cut -f 1 -d ':'`"
  546. fi
  547. echo -n " $MODULE" >/dev/console
  548. echo "Loading module $MODULE $MPARAMS"
  549. firmware_tarball_func #install firmware tarball. see functions4puppy4.
  550. #for mwave.ko (modem), do not load module, just the firmware, which has script that correctly loads mwave.ko.
  551. [ "$MODULE" != "mwave" ] && modprobe $MODULE $MPARAMS
  552. done
  553. status_func 0
  554. fi
  555. ###################SETUP SERVICES################
  556. echo "SETUP SERVICES"
  557. echo -n "Setting up services (network, printing, etc.)..." >/dev/console
  558. if [ -h /dev/modem ];then
  559. DEVM="`readlink /dev/modem`"
  560. case $DEVM in
  561. modem) #error, circular link.
  562. rm -f /dev/modem
  563. DEVM=""
  564. ;;
  565. /dev/*) #wrong format.
  566. DEVM="`echo -n "$DEVM" | cut -f 3,4 -d '/'`"
  567. ln -snf $DEVM /dev/modem
  568. ;;
  569. esac
  570. case $DEVM in
  571. ttyS[0-9]) #apparently setserial can crash with other modems.
  572. setserial -v -b /dev/modem auto_irq skip_test autoconfig
  573. ;;
  574. esac
  575. fi
  576. #had hoped to retire this, but HardInfo, Pupscan need it... 110814 fix test...
  577. [ -e /proc/bus/usb ] && busybox mount -t usbfs none /proc/bus/usb
  578. #v408 only needed for 2.6.21.7, as 2.6.25.x loads these automatically...
  579. #v408 kirk: Check for laptop battery...
  580. modprobe battery
  581. if [ -d /proc/acpi/battery ]; then
  582. results="`find /proc/acpi/battery -mindepth 1 -type d`"
  583. if [ ! -z "$results" ]; then
  584. modprobe ac
  585. modprobe thermal
  586. modprobe fan
  587. else
  588. rmmod battery
  589. fi
  590. fi
  591. #100814 100903 record cumulative tx/rx, see also network_tray and rc.shutdown...
  592. UPDATE_MONTH="`date +%b`"
  593. CURRENT_MONTH="`cat /var/local/sns/current_month`"
  594. if [ "$UPDATE_MONTH" != "$CURRENT_MONTH" ];then
  595. echo "$UPDATE_MONTH" > /var/local/sns/current_month
  596. for ONECOUNT in sns/r sns/t pupdial/isp1/r pupdial/isp1/t pupdial/isp2/r pupdial/isp2/t;do
  597. echo -n 0 > /var/local/${ONECOUNT}x_bytes_month
  598. done
  599. fi
  600. #120505 remove this so that /usr/bin/xwin does not try another auto network connect (ref: /usr/sbin/hostname-set)...
  601. [ -f /tmp/simple_network_setup/network_default_reconnect_required_flag ] && rm -f /tmp/simple_network_setup/network_default_reconnect_required_flag
  602. #120505 ***NOTE: this code block extracted to /usr/sbin/network_default_connect. in future could delete it here and call that script.***
  603. #100227 choose default network tool...
  604. DEFAULTCONNECT="`cat /usr/local/bin/defaultconnect | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
  605. [ "`grep 'gprs' /usr/local/bin/defaultconnect`" != "" ] && DEFAULTCONNECT='pgprs-connect'
  606. [ "$DEFAULTCONNECT" = "gkdial" ] && DEFAULTCONNECT="pupdial" #for older pups.
  607. NETCHOICE="$DEFAULTCONNECT" #101007 shinobar
  608. case $DEFAULTCONNECT in
  609. Pwireless2)
  610. NETCHOICE='Pwireless2'
  611. ;;
  612. net-setup.sh)
  613. NETCHOICE='net-setup.sh'
  614. ;;
  615. net_wiz_classic)
  616. NETCHOICE='net_wiz_classic'
  617. ;;
  618. sns)
  619. NETCHOICE='sns'
  620. ;;
  621. connectwizard) #try determine which tool was used to setup networking... 101007
  622. if [ -s /etc/simple_network_setup/connections ];then #100306
  623. NETCHOICE='sns'
  624. else
  625. CHECKOLDWIZ="`ls -1 /etc/*[0-9]mode 2>/dev/null`" #ex: eth0mode, wlan0mode.
  626. if [ "$CHECKOLDWIZ" != "" -a -d /usr/local/net_setup ];then
  627. NETCHOICE='net_wiz_classic'
  628. else
  629. CHECKNEWWIZ="`ls -1 /etc/network-wizard/network/interfaces 2>/dev/null`"
  630. if [ "$CHECKNEWWIZ" != "" ];then
  631. NETCHOICE='net-setup.sh'
  632. else
  633. [ -f /usr/local/Pwireless2/interface ] && NETCHOICE='Pwireless2' #100304
  634. fi
  635. fi
  636. fi
  637. ;;
  638. esac
  639. [ -f /etc/init.d/Pwireless2 ] && chmod 644 /etc/init.d/Pwireless2 #prevent jemimah's script from running. 100304 100513
  640. case $NETCHOICE in
  641. Pwireless2)
  642. #this only sets up interface 'lo'...
  643. /etc/rc.d/rc.network_basic
  644. #jemimah's script is in /etc/init.d/Pwireless2
  645. chmod 755 /etc/init.d/Pwireless2 #make executable so it will run.
  646. #i want to run it right now, as a separate process (rc.services will ignore it)...
  647. /etc/init.d/Pwireless2 start &
  648. ;;
  649. net-setup.sh)
  650. /etc/rc.d/rc.network &
  651. ;;
  652. net_wiz_classic)
  653. #note, old wizard is located in /usr/local/net_setup.
  654. /usr/local/net_setup/etc/rc.d/rc.network &
  655. ;;
  656. sns) #100306
  657. /etc/rc.d/rc.network_basic #this only sets up interface 'lo'.
  658. /usr/local/simple_network_setup/rc.network &
  659. ;;
  660. connectwizard) #101007 shinobar
  661. #100628 shinobar: launch rc.network if eth0 is usable
  662. RCNETWORK=/etc/rc.d/rc.network_basic #this only sets up interface 'lo'.
  663. # eth0 usable?
  664. if /sbin/ifconfig eth0 &>/dev/null ;then
  665. if [ -x /etc/rc.d/rc.network ]; then
  666. RCNETWORK=/etc/rc.d/rc.network
  667. elif [ -e /etc/init.d/Pwireless2 ]; then
  668. chmod 755 /etc/init.d/Pwireless2
  669. fi
  670. fi
  671. $RCNETWORK &
  672. ;;
  673. *) #101007 shinobar
  674. /etc/rc.d/rc.network_basic &
  675. ;;
  676. esac
  677. /etc/rc.d/rc.services & #run scripts in /etc/rc.d/init.d
  678. echo -e "\\033[64G\\033[1;33m[backgrounded]\\033[0;39m" >/dev/console #column 62, yellow. 110426: 64
  679. ############RECOGNISE MEDIA DEVICES################
  680. echo "RECOGNISE MEDIA DEVICES"
  681. STATUS=0
  682. echo -n "Recognising media devices..." >/dev/console
  683. #recognise optical drives...
  684. echo -n ' optical' >/dev/console
  685. OPTCNT=1;CDTYPE="";DVDTYPE="";CDBURNERTYPE=""
  686. OPTICALS="`grep '^drive name:' /proc/sys/dev/cdrom/info | grep -o -E 'sr.*|hd.*' | tr '\t' ' '`"
  687. [ -L /dev/cdrom ] && CDTYPE="`readlink /dev/cdrom | cut -f 3 -d '/'`"
  688. [ -L /dev/dvd ] && DVDTYPE="`readlink /dev/dvd | cut -f 3 -d '/'`"
  689. [ -f /etc/cdburnerdevice ] && CDBURNERTYPE="`cat /etc/cdburnerdevice`"
  690. [ "`echo "$OPTICALS" | grep "$CDTYPE"`" = "" ] && CDTYPE="" #no longer exists.
  691. [ "`echo "$OPTICALS" | grep "$DVDTYPE"`" = "" ] && DVDTYPE="" #no longer exists.
  692. [ "`echo "$OPTICALS" | grep "$CDBURNERTYPE"`" = "" ] && CDBURNERTYPE="" #no longer exists.
  693. for ONEOPTICAL in $OPTICALS
  694. do
  695. ONENUM="`echo -n "$ONEOPTICAL" | cut -c 3`"
  696. [ "$CDTYPE" = "" ] && CDTYPE="$ONEOPTICAL"
  697. [ "$DVDTYPE" = "" ] && [ "`grep '^Can read DVD' /proc/sys/dev/cdrom/info | head -n 1 | grep -o '[01].*' | sed -e 's/[^01]//g' | cut -c $OPTCNT`" = "1" ] && DVDTYPE="$ONEOPTICAL" #100131
  698. [ "$CDBURNERTYPE" = "" ] && [ "`grep '^Can write CD' /proc/sys/dev/cdrom/info | head -n 1 | grep -o '[01].*' | sed -e 's/[^01]//g' | cut -c $OPTCNT`" = "1" ] && CDBURNERTYPE="$ONEOPTICAL" #100131
  699. OPTCNT=`expr $OPTCNT + 1`
  700. done
  701. rm -f /dev/cdrom; rm -f /dev/dvd; rm -f /etc/cdburnerdevice
  702. [ "$CDTYPE" ] && ln -sf /dev/$CDTYPE /dev/cdrom
  703. [ "$DVDTYPE" ] && ln -sf /dev/$DVDTYPE /dev/dvd
  704. [ "$CDBURNERTYPE" ] && echo -n "$CDBURNERTYPE" > /etc/cdburnerdevice
  705. [ "$DVDTYPE" ] && hdparm -d1 /dev/$DVDTYPE >/dev/null 2>&1
  706. echo -n ' input' >/dev/console #100131
  707. if [ ! -s /etc/mousedevice ];then #120423 change -f to -s test.
  708. echo -n "input/mice" > /etc/mousedevice
  709. ln -snf input/mice /dev/mouse
  710. else
  711. [ "`cat /etc/mousedevice`" = "psaux" ] && echo -n "input/mice" > /etc/mousedevice
  712. fi
  713. #120423 pemasu: /dev/mouse was missing in full install...
  714. MOUSELINK="`cat /etc/mousedevice`" #(refer /usr/sbin/input-wizard for examples)
  715. if [ ! -e /dev/$MOUSELINK ];then #precaution, in case mouse interface is gone (unlikely, being paranoid).
  716. echo -n "input/mice" > /etc/mousedevice
  717. ln -snf input/mice /dev/mouse
  718. fi
  719. [ ! -e /dev/mouse ] && ln -s $MOUSELINK /dev/mouse
  720. #recognise keyboard...
  721. #echo -n ' keyboard' >/dev/console
  722. #130513 init in initrd creates /root/.xorgwizard-reenter, need to ask kbd/locale even though auto-X at 1st boot...
  723. ASKME=''
  724. [ $PUPMODE -eq 5 ] && [ -f /root/.xorgwizard-reenter ] && ASKME='ask'
  725. /etc/rc.d/rc.country ${ASKME} ;STATUS=$((STATUS+$?)) #this asks for keyboard layout.
  726. status_func $STATUS
  727. ############MISC DESKTOP STUFF##################
  728. echo "MISC. DESKTOP STUFF"
  729. if [ "$PUPMODE" = "77" ];then #77=multisession cd/dvd.
  730. if [ "`cat /root/Choices/ROX-Filer/PuppyPin | grep "savesession"`" = "" ];then
  731. echo '<icon x="768" y="128" label="save">/usr/sbin/savesession-dvd</icon>' >> /root/Choices/ROX-Filer/PuppyPin
  732. grep -v '/pinboard' /root/Choices/ROX-Filer/PuppyPin > /tmp/PuppyPin-CPY
  733. #sync
  734. cp -f /tmp/PuppyPin-CPY /root/Choices/ROX-Filer/PuppyPin
  735. echo '</pinboard>' >> /root/Choices/ROX-Filer/PuppyPin
  736. fi
  737. fi
  738. #save button on desktop when booted from flash drive...
  739. if [ $PUPMODE -eq 3 -o $PUPMODE -eq 7 -o $PUPMODE -eq 13 ];then #pup_rw is tmpfs.
  740. if [ "`cat /root/Choices/ROX-Filer/PuppyPin | grep "save2flash"`" = "" ];then
  741. echo '<icon x="768" y="128" label="save">/usr/sbin/save2flash</icon>' >> /root/Choices/ROX-Filer/PuppyPin
  742. grep -v '/pinboard' /root/Choices/ROX-Filer/PuppyPin > /tmp/PuppyPin-CPY
  743. #sync
  744. cp -f /tmp/PuppyPin-CPY /root/Choices/ROX-Filer/PuppyPin
  745. echo '</pinboard>' >> /root/Choices/ROX-Filer/PuppyPin
  746. fi
  747. fi
  748. ###################PERSONAL BOOT SCRIPT######################
  749. echo "PERSONAL BOOT SCRIPT"
  750. #personal boot script here...
  751. if [ ! -f /etc/rc.d/rc.local ];then
  752. echo '#this file called from rc.sysinit' > /etc/rc.d/rc.local
  753. echo '#you can edit this file' >> /etc/rc.d/rc.local
  754. echo '#When firewall is installed, will append lines to this file...' >> /etc/rc.d/rc.local
  755. fi
  756. . /etc/rc.d/rc.local
  757. #100316 improper shutdown check. see above, also rc.shutdown and /sbin/init...
  758. if [ ! -d /initrd ];then #if no /initrd, full hd install.
  759. [ ! $PDEV1 ] && PDEV1="`df | grep ' /$' | grep '^/dev/' | cut -f 1 -d ' ' | cut -f 3 -d '/'`"
  760. [ ! $DEV1FS ] && DEV1FS="`mount | grep ' on / ' | grep '^/dev/' | cut -f 5 -d ' '`"
  761. if [ "$PDEV1" -a "$DEV1FS" ];then
  762. [ "`grep '^PDEV1' /etc/rc.d/PUPSTATE`" = "" ] && echo "PDEV1='$PDEV1'" >> /etc/rc.d/PUPSTATE
  763. [ "`grep '^DEV1FS' /etc/rc.d/PUPSTATE`" = "" ] && echo "DEV1FS='$DEV1FS'" >> /etc/rc.d/PUPSTATE
  764. #this file gets removed by rc.shutdown if a proper shutdown...
  765. echo -n "${PDEV1},${DEV1FS}," > /fsckme.flg #ex: sda7,ext3,
  766. busybox chmod 666 /fsckme.flg #110503 so non-root can delete it.
  767. fi
  768. else
  769. if [ "$PUPSAVE" ];then
  770. echo -n "$PUPSAVE" > /initrd${PUP_HOME}/fsckme.flg #ex: sda7,ext3,/pupsave-10MAR2010.2fs
  771. busybox chmod 666 /initrd${PUP_HOME}/fsckme.flg #110503 so non-root can delete it.
  772. fi
  773. fi
  774. if [ "$BOOT_SCHEDULER" ];then #120704 see /etc/rc.d/BOOTCONSTRAINED, variable set in 3builddistro.
  775. #my kernel defaults to 'cfq', change to 'deadline'. refer: http://tombuntu.com/index.php/2008/09/04/four-tweaks-for-using-linux-with-solid-state-drives/
  776. if [ "$PDEV1" ];then
  777. PDEV="`echo -n "$PDEV1" | sed -e 's%[0-9]*$%%' -e 's%p$%%'`" #mmcblk0p2 becomes mmcblk0
  778. if [ "`cat /sys/block/${PDEV}/queue/scheduler | grep "$BOOT_SCHEDULER"`" != "" ];then #check available.
  779. if [ "`cat /sys/block/${PDEV}/queue/scheduler | cut -f 2 -d '[' | cut -f 1 -d ']' | grep "$BOOT_SCHEDULER"`" = "" ];then #check not already chosen.
  780. #sync
  781. echo $BOOT_SCHEDULER > /sys/block/${PDEV}/queue/scheduler
  782. echo 1 > /sys/block/${PDEV}/queue/iosched/fifo_batch
  783. fi
  784. fi
  785. fi
  786. fi
  787. # peebee work around for rfkill in some HP laptops
  788. rfkill list | grep -q "yes"
  789. BLOCKED="$?"
  790. if [ "$BLOCKED" = 0 ];then
  791. rfkill unblock wlan
  792. fi
  793. # SFR hack for IO bug http://murga-linux.com/puppy/viewtopic.php?p=681383#681383
  794. KERNVER=${KERNVER%%-*} # just for appending "-4g","-PAE" or whatever
  795. if [ ! "$PUPMODE" = 5 ];then
  796. if vercmp $KERNVER ge 3.2 ;then
  797. if vercmp $KERNVER lt 3.8 ;then
  798. case "$DEV1FS" in
  799. ntfs|vfat|ext2)
  800. mount -o remount,sync /dev/loop1 # changed 130210, SFR
  801. ;;
  802. esac
  803. fi
  804. fi
  805. fi
  806. #that's it. next stop is /etc/profile...
  807. ###END###