rc.sysinit 37 KB

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