rc.sysinit-UNIPUP 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. #!/bin/sh
  2. #(c) copyright Barry Kauler 2008, puppylinux.com
  3. #2008 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
  4. #This is the first startup script for UniPup, which runs entirely in initramfs.
  5. #The 'createpuppy_unipup' script in Unleashed renames this from 'rc.sysinit-UNIPUP' to
  6. #'rc.sysinit' (replacing any older rc.sysinit in the Unleashed build environment).
  7. #Note, UniPup does not have an 'init' script (/init is a symlink to /bin/busybox).
  8. #Note, do not edit this script. It reloads from initrd.gz at bootup.
  9. #v404 first release. written from scratch, aiming for simplicity and speed.
  10. #v405 alsa fix.
  11. #v406 load apm.ko if no acpi.
  12. #v409 gparted create ext3 part. failed, fixed by making /etc/mtab a symlink.
  13. #v411 added minix|ext4|xfs support.
  14. #v411 changed default to aufs, implement pfix values nox, nosave, nosfs
  15. #v411 fix mouse detection logic.
  16. #v411 can use old network wizard (from 403, based on 400)
  17. #v411 return of 'puppyserialdetect', for usb/ps2 mouse detection only. now 'puppyinputdetect'.
  18. #v411 extra 'sleep 1' as rerwin reports usb mouse may need it some hardware.
  19. #v411 choosemousefunc().
  20. #v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
  21. #v555 pup files renamed to woofr555.sfs, woofsave.tar.gz, woofu555.sfs.
  22. #100126 move syslogd, klogd to /etc/init.d/00sys_logger
  23. #100131 bugfix detect multiple cd/dvd drives.
  24. . /etc/rc.d/functions4puppy4
  25. . /etc/DISTRO_SPECS
  26. status_func() {
  27. if [ $1 -eq 0 ];then
  28. /bin/echo -e "\\033[72G\\033[1;32mdone\\033[0;39m" >/dev/console #green [done] msg.
  29. else
  30. /bin/echo -e "\\033[70G\\033[1;31mfailed\\033[0;39m" >/dev/console #red [failed].
  31. STATUS=0
  32. fi
  33. }
  34. . /etc/rc.d/MODULESCONFIG #modules loading configuration.
  35. #PUPPYVERSION=`cat /etc/puppyversion`
  36. PATH=/bin:/sbin
  37. [ $layerfs ] && LAYERFS=$layerfs #boot param.
  38. [ ! $LAYERFS ] && LAYERFS=aufs #aufs or unionfs v411
  39. [ $loglevel ] && LOGLEVEL=$loglevel #boot param.
  40. [ $pmedia ] && PMEDIA=$pmedia #boot parameter, broad category of boot media. ex: cd.
  41. [ $pdev1 ] && PDEV1=$pdev1 #boot parameter, partition have booted off. ex: hda3
  42. STATUS=0
  43. #v411...
  44. if [ "$pfix" ];then
  45. for ONEFIX in `echo -n "$pfix" | tr ',' ' '`
  46. do
  47. case $ONEFIX in
  48. nox) PNOX="yes";; #do not start X.
  49. nosave) PNOSAVE="yes";; #do not load any ${DISTRO_FILE_PREFIX}save file.
  50. nosfs) PNOSFS="yes";; #do not load any sfs files at all.
  51. esac
  52. done
  53. fi
  54. ##############MAKE FILESYSTEM USABLE################
  55. echo -n "Making the 'RAM filesystem' usable..." >/dev/console #need this redirection!
  56. busybox mount -t proc none /proc ;STATUS=$((STATUS+$?))
  57. busybox mount -t sysfs none /sys ;STATUS=$((STATUS+$?))
  58. busybox mount -t rootfs -o remount,rw rootfs / ;STATUS=$((STATUS+$?))
  59. busybox mount /dev/pts ;STATUS=$((STATUS+$?))
  60. #ln -s /proc/mounts /etc/mtab #resize2fs,e2fsck need this.
  61. #...um, no, as my /bin/mount,umount scripts generate /etc/mtab.
  62. #v409 mount/umount scripts no longer write to /etc/mtab, as gparted failed to create a
  63. #ext3 partition -- dunno why. Instead, now have /etc/mtab a symlink to /proc/mounts...
  64. rm -f /etc/mtab
  65. ln -s /proc/mounts /etc/mtab
  66. #redirect all output to a log file (must do after remount rw)...
  67. [ ! "$LOGLEVEL" ] && exec 1>/tmp/bootsysinit.log 2>&1
  68. status_func $STATUS
  69. #################LOAD KERNEL MODULES################
  70. echo -n "Loading kernel modules..." >/dev/console
  71. #ha ha, this is putting the cart before the horse!...
  72. #(will need to save /etc/MODULESCONFIG into the initrd.gz file at shutdown, if modified)
  73. #setup blacklist... (SKIPLIST is in /etc/MODULESCONFIG)
  74. BLACKLISTVARS="`echo "$SKIPLIST" | tr '\-' '_' | tr ' ' '\n' | sed -e 's/^/blacklist /' | grep -v ' $'`"
  75. echo "$BLACKLISTVARS" > /tmp/pup_event_modprobe.conf #read in /sbin/pup_event_backend_d
  76. #v405 udevd calls /sbin/pup_event_backend_modprobe, which needs this...
  77. echo -n '0' > /tmp/pup_event_alsa_cnt
  78. #my intention is for puppy to work with either of these...
  79. if [ -f /sbin/udevd ];then
  80. /sbin/udevd --daemon
  81. else
  82. pup_event_backend_d >/tmp/pup_event_backend_errors 2>&1 & #hotplug daemon. my homebrew replacement for udevd.
  83. fi
  84. sleep 0.1
  85. #replay uevents from /sys...
  86. MODALIASES="`ls /sys/bus/*/devices/*/modalias`"
  87. for ONEMODALIAS in $MODALIASES
  88. do
  89. ONEPATH="`dirname $ONEMODALIAS`"
  90. if [ -e ${ONEPATH}/uevent ];then
  91. echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
  92. sleep 0.02
  93. fi
  94. done
  95. #do something to fill small time-slot... rc.shutdown uses this info...
  96. #this is an exclusion list, files that will not be saved to user's ${DISTRO_FILE_PREFIX}save...
  97. find /bin -mount -type f > /tmp/init_startup_files
  98. find /sbin -mount -type f >> /tmp/init_startup_files
  99. find /etc -mount -type f >> /tmp/init_startup_files
  100. find /root -mount -type f >> /tmp/init_startup_files
  101. find /opt -mount -type f >> /tmp/init_startup_files
  102. find /lib -mount -type f >> /tmp/init_startup_files
  103. #driver now builtin to libata pata kernel... do this for old kernel...
  104. if [ -e /proc/ide ];then
  105. #ide zip or ide ls-120 drive?...
  106. [ ! "`dmesg | grep "ATAPI FLOPPY"`" = "" ] && modprobe ide-floppy
  107. fi
  108. modprobe nls_cp437 #these needed by vfat/ntfs/ext2 f.s.'s.
  109. modprobe nls_iso8859-1 # "
  110. modprobe fuse
  111. modprobe $LAYERFS #unionfs or aufs.
  112. modprobe squashfs
  113. #we can determine ide/sata drives at this point (drivers builtin to kernel)...
  114. #old kernel, no pata, have /proc/ide, these will be sata only...
  115. #ATADRIVES="`ls -1 /sys/block | grep '^sd' | tr '\n' ' '`"
  116. ATADRIVES="`cat /proc/partitions | grep "sd[a-z]$" | tr -s " " | cut -f 5 -d " " | tr "\n" " "`"
  117. [ ! -d /proc/acpi ] && modprobe apm #v406
  118. status_func 0
  119. ######################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
  124. swapon $ONESWAP
  125. status_func $?
  126. done
  127. #################MISC. SYSTEM SETUP#################
  128. #100126 moved to /etc/init.d/00sys_logger...
  129. #syslogd -m 0
  130. #klogd
  131. KERNVER="`uname -r`"
  132. echo -e "${DISTRO_NAME} Linux\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue
  133. echo "1" > /proc/sys/net/ipv4/ip_dynaddr
  134. hostname -F /etc/hostname
  135. ################WAIT MODULES LOADED##################
  136. #previous module loading may not have completed...
  137. echo -n "Waiting for modules to complete loading..." >/dev/console
  138. WAITCNT=0
  139. PCIPCMCIA="`elspci -l | grep -o '060700'`"
  140. PCIUSB="`elspci -l | grep -o -E '0C0300|0C0310|0C0320'`"
  141. if [ "$PCIPCMCIA" != "" ];then #this may be slow to respond.
  142. echo -n " pcmcia" >/dev/console
  143. while [ $WAITCNT -lt 10 ];do
  144. [ "`lsmod | grep -E '^yenta_socket |^tcic |^i82092 |^i82365 |^pd6729 '`" != "" ] && break
  145. WAITCNT=`expr $WAITCNT + 1`
  146. sleep 1
  147. echo -n " $WAITCNT" >/dev/console
  148. done
  149. fi
  150. if [ "$PCIUSB" != "" ];then #this may be slow to respond.
  151. echo -n " usb" >/dev/console
  152. PCIUSBNUM=`echo "$PCIUSB" | sort -u | wc -l`
  153. while [ $WAITCNT -lt 10 ];do
  154. [ `lsmod | grep -o -E '^uhci_hcd|^ohci_hcd|^ehci_hcd' | wc -l` -ge $PCIUSBNUM ] && break
  155. WAITCNT=`expr $WAITCNT + 1`
  156. sleep 1
  157. echo -n " $WAITCNT" >/dev/console
  158. done
  159. fi
  160. #replay uevents from /sys (more interfaces as a consequence of above drivers loaded)...
  161. #note, this also a workaround for kernel 'bug' where entries appear in /sys but no uevent
  162. #gets generated (yes it happens in 2.6.25.x kernel!)
  163. [ -e /sys/bus/pcmcia/devices ] && NEWPCMCIA="`ls /sys/bus/pcmcia/devices/*/modalias | tr '\n' ' '`"
  164. [ -e /sys/bus/usb/devices ] && NEWUSB="`ls /sys/bus/usb/devices/*/modalias | tr '\n' ' '`"
  165. for ONEMODALIAS in ${NEWPCMCIA}${NEWUSB}
  166. do
  167. ONEPATH="`dirname $ONEMODALIAS`"
  168. if [ -e ${ONEPATH}/uevent ];then
  169. echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
  170. sleep 0.02
  171. fi
  172. done
  173. #wait for usb-storage drives to become available...
  174. #note, pup_event_backend_d and udevd both log to this file when load modules
  175. # (the latter via udev handler script /sbin/pup_event_backend_modprobe)...
  176. if [ "`grep 'usb_storage' /tmp/pup_event_module_devpath_log`" != "" ];then #see pup_event_backend_d
  177. echo -n " usb-storage" >/dev/console
  178. while [ $WAITCNT -lt 15 ];do
  179. [ "`dmesg | grep 'usb-storage: device scan complete'`" != "" ] && break
  180. sleep 1
  181. WAITCNT=`expr $WAITCNT + 1`
  182. echo -n " $WAITCNT" >/dev/console
  183. done
  184. #precaution, make sure have got them all...
  185. USBSTORAGES=`/bin/dmesg | grep "usb-storage: device found at" | wc -l`
  186. while [ $WAITCNT -lt 15 ];do
  187. AVAILABLEUSBSTORAGES=`/bin/dmesg | grep "usb-storage: device scan complete" | wc -l`
  188. [ $AVAILABLEUSBSTORAGES -ge $USBSTORAGES ] && break
  189. sleep 1
  190. WAITCNT=`expr $WAITCNT + 1`
  191. echo -n " $WAITCNT" >/dev/console
  192. done
  193. fi
  194. sleep 1 #v411 a bit extra. rerwin reports usb mouse detection problem some hardware.
  195. #(delay before usb mouse info appears in /proc/bus/input/devices)
  196. status_func 0
  197. ################FIND PUPPY FILES################
  198. echo -n "Looking for ${DISTRO_NAME} files in PC..." >/dev/console
  199. PUPMODE=16
  200. [ -f /${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs ] && USRSFS="rootfs,rootfs,/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs"
  201. #note, i think this is sorted so sr* drives list last (needed here)...
  202. PROBEPART="`probepart -m | grep -E 'vfat|ntfs|ext2|ext3|reiserfs|minix|ext4|xfs|iso9660'`" #v411
  203. for ONEFOUND in $PROBEPART
  204. do
  205. ONEPART="`echo -n "$ONEFOUND" | cut -f 1 -d '|' | cut -f 3 -d '/'`"
  206. ONEFS="`echo -n "$ONEFOUND" | cut -f 2 -d '|'`"
  207. [ "$ONEFS" = "iso9660" -a "$USRSFS" != "" ] && continue #probe optical last resort.
  208. mkdir -p /mnt/$ONEPART
  209. mount -t $ONEFS /dev/$ONEPART /mnt/$ONEPART
  210. if [ $? -ne 0 ];then #for slow usb optical drives...
  211. sleep 5
  212. mount -t $ONEFS /dev/$ONEPART /mnt/$ONEPART
  213. fi
  214. if [ $? -eq 0 ];then
  215. [ -f /mnt/$ONEPART/${DISTRO_FILE_PREFIX}save.tar.gz ] && PUPSAVE="${ONEPART},${ONEFS},/${DISTRO_FILE_PREFIX}save.tar.gz"
  216. if [ -f /mnt/$ONEPART/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs ];then
  217. USRSFS="${ONEPART},${ONEFS},/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs"
  218. continue #do not unmount.
  219. fi
  220. umount /mnt/$ONEPART
  221. fi
  222. done
  223. [ "$USRSFS" = "" ] && STATUS=1
  224. [ "$PNOSFS" = "yes" ] && USRSFS="" #v411
  225. [ "$PNOSAVE" = "yes" ] && PUPSAVE="" #v411
  226. #/${DISTRO_FILE_PREFIX}u<puppyversion>.sfs is the complete /usr directory compressed. mount as a layerfs...
  227. if [ "$USRSFS" ];then
  228. USRMNTPT=""
  229. USRPART="`echo -n "$USRSFS" | cut -f 1 -d ','`"
  230. USRFS="`echo -n "$USRSFS" | cut -f 2 -d ','`"
  231. USRNAME="`echo -n "$USRSFS" | cut -f 3 -d ','`"
  232. [ "$USRPART" != "rootfs" ] && USRMNTPT="/mnt/$USRPART"
  233. if [ -f ${USRMNTPT}/initrd.gz -a -f ${USRMNTPT}/vmlinuz ];then
  234. PDEV1="$USRPART"
  235. DEV1FS="$USRFS"
  236. fi
  237. mkdir -p /.mnt/usr
  238. mkdir /.mnt/tmpfs1
  239. busybox losetup /dev/loop0 ${USRMNTPT}${USRNAME} #/${DISTRO_FILE_PREFIX}u${DISTRO_VERSION}.sfs
  240. busybox mount -r -t squashfs -o noatime /dev/loop0 /.mnt/usr
  241. busybox mount -t tmpfs tmpfs /.mnt/tmpfs1 #default size is "half of memory".
  242. if [ "$LAYERFS" = "aufs" ];then
  243. busybox mount -t aufs -o udba=reval,diropq=w,dirs=/.mnt/tmpfs1=rw:/.mnt/usr=ro unionfs /usr
  244. else #unionfs
  245. busybox mount -t unionfs -o dirs=/.mnt/tmpfs1=rw:/.mnt/usr=ro unionfs /usr
  246. fi
  247. STATUS=$?
  248. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin
  249. fi
  250. if [ "$PUPSAVE" ];then
  251. SAVEPART="`echo -n "$PUPSAVE" | cut -f 1 -d ','`"
  252. SAVEFS="`echo -n "$PUPSAVE" | cut -f 2 -d ','`"
  253. SAVENAME="`echo -n "$PUPSAVE" | cut -f 3 -d ','`"
  254. aPATTERN="/dev/${SAVEPART} "
  255. if [ "`mount | grep "$aPATTERN"`" = "" ];then
  256. MNTFLAG="yes"
  257. mount -t $SAVEFS /dev/$SAVEPART /mnt/$SAVEPART
  258. STATUS=$((STATUS+$?))
  259. fi
  260. if [ $STATUS -eq 0 ];then
  261. if [ -f /mnt/${SAVEPART}${SAVENAME} ];then
  262. echo -n " loading" >/dev/console
  263. #this reads the save file...
  264. tar -x -z -f /mnt/${SAVEPART}${SAVENAME} -C /
  265. sync
  266. if [ -f /mnt/${SAVEPART}initrd.gz -a -f /mnt/${SAVEPART}vmlinuz -a "${PDEV1}" = "" ];then
  267. PDEV1="$SAVEPART"
  268. DEV1FS="$SAVEFS"
  269. fi
  270. PUPMODE=24 #16+8
  271. fi
  272. fi
  273. [ "$MNTFLAG" ] && umount /dev/$SAVEPART
  274. fi
  275. echo "PUPMODE=$PUPMODE
  276. PDEV1='${PDEV1}'
  277. DEV1FS='${DEV1FS}'
  278. PUPSAVE='${PUPSAVE}'
  279. USRSFS='${USRSFS}'" > /etc/rc.d/PUPSTATE
  280. if [ -e /proc/ide ];then
  281. echo "SATADRIVES='${ATADRIVES}'" >> /etc/rc.d/PUPSTATE #kernel supports /dev/hd*.
  282. else
  283. echo "ATADRIVES='${ATADRIVES}'" >> /etc/rc.d/PUPSTATE
  284. fi
  285. ln -sf / /mnt/home
  286. status_func $STATUS
  287. ##############USER SELECTED MODULES##################
  288. #the user can select extra modules to load in the BootManager...
  289. if [ "$ADDLIST" != "" ];then #variable is in /etc/rc.d/MODULESCONFIG
  290. echo -n "Loading user-selected modules..." >/dev/console
  291. for MODULE in $ADDLIST
  292. do
  293. MPARAMS=""
  294. if [ `echo -n "$MODULE" | tr ':' ' ' | wc -w` -gt 1 ];then
  295. MPARAMS="`echo -n "$MODULE" | cut -f 2-9 -d ':' | tr ':' ' '`"
  296. MODULE="`echo -n "$MODULE" | cut -f 1 -d ':'`"
  297. fi
  298. echo -n " $MODULE" >/dev/console
  299. echo "Loading module $MODULE $MPARAMS"
  300. firmware_module_func #install firmware tarball. see functions4puppy4.
  301. modprobe $MODULE $MPARAMS
  302. done
  303. status_func 0
  304. fi
  305. [ "$PNOSFS" = "yes" ] && exec /bin/sh >/dev/console 2>&1 #v411 drop out.
  306. ###################SETUP SERVICES################
  307. echo -n "Setting up services (network, printing, etc.)..." >/dev/console
  308. if [ -e /dev/modem ];then
  309. setserial -v -b /dev/modem auto_irq skip_test autoconfig
  310. check_status 0
  311. fi
  312. #had hoped to retire this, but HardInfo needs it...
  313. [ "`lsmod | grep '^usbcore'`" != "" ] && busybox mount -t usbfs none /proc/bus/usb
  314. #v411 can use old network wizard (from 403, based on 400)...
  315. CHECKOLDWIZ="`ls -1 /etc/*[0-9]mode 2>/dev/null`" #ex: eth0mode, wlan0mode.
  316. if [ "$CHECKOLDWIZ" != "" -a -d /usr/local/net_setup ];then
  317. #note, old wizard is located in /usr/local/net_setup.
  318. /usr/local/net_setup/etc/rc.d/rc.network &
  319. else
  320. /etc/rc.d/rc.network &
  321. fi
  322. /etc/rc.d/rc.services & #run scripts in /etc/rc.d/init.d
  323. echo -e "\\033[62G\\033[1;33m[backgrounded]\\033[0;39m" >/dev/console #column 62, yellow.
  324. ############RECOGNISE MEDIA DEVICES################
  325. echo -n "Recognising media devices..." >/dev/console
  326. #recognise optical drives...
  327. echo -n ' optical' >/dev/console
  328. OPTCNT=1;CDTYPE="";DVDTYPE="";CDBURNERTYPE=""
  329. OPTICALS="`grep '^drive name:' /proc/sys/dev/cdrom/info | grep -o -E 'sr.*|hd.*' | tr '\t' ' '`"
  330. [ -L /dev/cdrom ] && CDTYPE="`readlink /dev/cdrom | cut -f 3 -d '/'`"
  331. [ -L /dev/dvd ] && DVDTYPE="`readlink /dev/dvd | cut -f 3 -d '/'`"
  332. [ -f /etc/cdburnerdevice ] && CDBURNERTYPE="`cat /etc/cdburnerdevice`"
  333. [ "`echo "$OPTICALS" | grep "$CDTYPE"`" = "" ] && CDTYPE="" #no longer exists.
  334. [ "`echo "$OPTICALS" | grep "$DVDTYPE"`" = "" ] && DVDTYPE="" #no longer exists.
  335. [ "`echo "$OPTICALS" | grep "$CDBURNERTYPE"`" = "" ] && CDBURNERTYPE="" #no longer exists.
  336. for ONEOPTICAL in $OPTICALS
  337. do
  338. ONENUM="`echo -n "$ONEOPTICAL" | cut -c 3`"
  339. [ "$CDTYPE" = "" ] && CDTYPE="$ONEOPTICAL"
  340. [ "$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
  341. [ "$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
  342. OPTCNT=`expr $OPTCNT + 1`
  343. done
  344. rm -f /dev/cdrom; rm -f /dev/dvd; rm -f /etc/cdburnerdevice
  345. [ "$CDTYPE" ] && ln -sf /dev/$CDTYPE /dev/cdrom
  346. [ "$DVDTYPE" ] && ln -sf /dev/$DVDTYPE /dev/dvd
  347. [ "$CDBURNERTYPE" ] && echo -n "$CDBURNERTYPE" > /etc/cdburnerdevice
  348. [ "$DVDTYPE" ] && hdparm -d1 /dev/$DVDTYPE >/dev/null 2>&1
  349. #recognise mouse... v411...
  350. #note, if wanted to detect serial mouse here, k2.6.25.16 has module 'sermouse' that must be loaded (currently in xwin).
  351. echo -n ' mouse' >/dev/console
  352. if [ ! -f /etc/mousedevice_sticky ];then #see functions4puppy4.
  353. PS2MOUSEDEV="";USBMOUSEDEV="";SERMOUSEDEV="";MOUSEDEV="nothing"
  354. [ -f /etc/mousedevice ] && MOUSEDEV="`cat /etc/mousedevice`"
  355. #v411 return of puppyserialdetect for usb/ps2 mouse detection only...
  356. PUPPYINPUTDETECT="`/sbin/puppyinputdetect -mup`" #same thing from Jesse, but has no serial code.
  357. [ "$PUPPYINPUTDETECT" = "" ] && sleep 1 && PUPPYINPUTDETECT="`/sbin/puppyinputdetect -mup`" #rerwin: retry after delay.
  358. # ...v411 note, i also put in a permanent 'sleep 1' further up.
  359. [ "`echo "$PUPPYINPUTDETECT" | grep 'Type:USB-mouse'`" != "" ] && USBMOUSEDEV="input/mice"
  360. [ "`echo "$PUPPYINPUTDETECT" | grep 'Type:PS2-mouse'`" != "" ] && PS2MOUSEDEV="psaux"
  361. [ "`echo "$MOUSEDEV" | grep '^tty'`" != "" ] && SERMOUSEDEV="$MOUSEDEV" #fallback or manual choice.
  362. MOUSECHOICES="${USBMOUSEDEV}|${SERMOUSEDEV}|${PS2MOUSEDEV}"
  363. if [ "`echo -n "$MOUSECHOICES" | grep "$MOUSEDEV"`" = "" ];then
  364. #MOUSEDEV is not one of the existing choices, so must choose an existing mouse...
  365. NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 1 -d '|'`"
  366. [ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 2 -d '|'`"
  367. [ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="`echo -n "$MOUSECHOICES" | cut -f 3 -d '|'`"
  368. #as we don't probe for a serial mouse, if no usb or ps2 mouse, fallback to assuming there must be a serial mouse...
  369. [ "$NEWMOUSEDEV" = "" ] && NEWMOUSEDEV="ttyS0"
  370. echo -n "$NEWMOUSEDEV" > /etc/mousedevice
  371. echo -n "$MOUSEDEV" > /etc/oldmousedevice
  372. ln -snf $NEWMOUSEDEV /dev/mouse
  373. choosemousefunc > /dev/console #see functions4puppy4.
  374. fi
  375. fi
  376. #TODO: simplify above, use 'input/mice' for ps2 mouse also, but may need to modify Xorg/Xvesa/Input Wizards.
  377. # (may also have to remove builtin psaux driver from kernel).
  378. #recognise keyboard...
  379. echo -n ' keyboard' >/dev/console
  380. /etc/rc.d/rc.country #this asks for keyboard layout.
  381. status_func 0
  382. #personal boot script here...
  383. if [ ! -f /etc/rc.d/rc.local ];then
  384. echo '#this file called from rc.sysinit' > /etc/rc.d/rc.local
  385. echo '#you can edit this file' >> /etc/rc.d/rc.local
  386. echo '#When firewall is installed, will append lines to this file...' >> /etc/rc.d/rc.local
  387. fi
  388. . /etc/rc.d/rc.local
  389. #v411 PNOX is a boot param. /etc/profile prevents X from starting if this file exists...
  390. [ "$PNOX" = "yes" ] && touch /tmp/bootcnt.txt
  391. #that's it. next stop is /etc/profile...
  392. ###END###