forked from puppylinux-woof-CE/woof-CE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.sysinit
executable file
·742 lines (656 loc) · 28.4 KB
/
rc.sysinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
#!/bin/ash
#(c) copyright Barry Kauler 2008, puppylinux.com
#2008 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
# see also initNEW -> /sbin/init, init (initramfs), rc.shutdown.
#
# How rc.sysinit is triggered:
# - /sbin/init executes busybox init or minit
# - busybox init is controlled by /etc/inittab
# /etc/inittab: rc.sysinit is specified as ::sysinit:
# - also read /etc/inittab.README
#
# eudev is enforced - min 151 - 175+ recommended
#
#w004 LANG=C, faster. /bin/ash, even faster.
#w481 fix crappy depmod, 'out of memory' in first boot 64MB RAM (no swap).
#v424 fix secondary uevent replay. now finds ssb devices.
#100131 bugfix detect multiple cd/dvd drives.
#100703 load fbcon module: needed by some xorg drivers when exit to console (ex: nouveau).
#100814 record cumulative tx/rx, see also network_tray and rc.shutdown.
#101119 /sbin/pup_event_backend_modprobe has been rewritten, repercussions here.
#101210 new path /tmp/pup_event_backend for files logged by /sbin/pup_event_backend_*.
#110405 fix 'free' applet output format different in later versions of busybox.
#110426 move done/failed/backgrounded 2 places to right (also in init script).
#110502 fix creation of owner:group for device nodes. 110503 fix permission fsckme.flg.
#110511 2nd uevent replay: now using udevadm for usb, ssb and pcmcia.
#110513 rcrsn51: udevadm usb replay fix, properly detect scanners etc.
#110712 fixes for kernel with usb core (including usb-storage) drivers builtin.
#110814 kernel with inbuilt usb drivers, usbfs was not mounting on /proc/bus/usb.
#120217 improvement for full hd install, non-english.
#120301 need to load console font earlier.
#120301 a problem if initrd has kernel default font, switching here changes all o/p from initrd to partial garbage.
#120313 fix 120301 font garbage. 120331 clear requires redirection to /dev/console.
#120423 pemasu: /dev/mouse was missing in full install.
#120503 if kernel mounts a f.s. on /dev, removes my skeleton /dev
#120709 BOOT_UDEVDCHILDREN from /etc/rc.d/BOOTCONSTRAINED
#130311 use modinfo to test if fbcon builtin.
#130504 moved up, i think fbcon needs to be loaded before intel, nouveau modules load.
#160609 rerwin: Add wait for USB3 driver.
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin
. /etc/rc.d/functions_x
#================================================================
# functions used by the script
#================================================================
status_func() {
if [ $1 -eq 0 ];then
echo -n -e "\\033[74G\\033[1;32m" >/dev/console #green [done] msg. 110426: change 72 to 74.
echo -n "done" >/dev/console #done
echo -e "\\033[0;39m" >/dev/console
else
echo -n -e "\\033[72G\\033[1;31m" >/dev/console #red [failed]. 110426: change 70 to 72.
echo -n "failed" >/dev/console #failed
echo -e "\\033[0;39m" >/dev/console
STATUS=0
fi
return $1 #return with same status as entry param.
}
loadswap_func() { #w481 made into a function.
echo "LOAD SWAP"
#load a swap partition...
for i in `probepart -no-optical | grep '|swap|'`
do
ONESWAP=`echo "$i" | cut -f 1 -d '|'`
SWAPSIZEBYTES=`echo "$i" | cut -f 3 -d '|'`
SWAPSIZEBYTES=$((SWAPSIZEBYTES * 512 )) #bytes
[ $SWAPSIZEBYTES ] && EXTRAALLOCK=$(($EXTRAALLOCK + $SWAPSIZEBYTES))
echo -n "Loading swap partition $ONESWAP ("$(fx_format_bytes $SWAPSIZEBYTES)")..." >/dev/console #loading swap partition
chmod 0660 $ONESWAP
swapon $ONESWAP
status_func $?
[ $? -eq 0 ] && SWAPON="yes"
done
[ "$SWAPON" = "yes" ] && return
#if no go, try for a swap file...
if [ -f /initrd${PUP_HOME}/pupswap.swp ] ; then
pupswap validate /initrd${PUP_HOME}/pupswap.swp && SWAPFILE="/initrd${PUP_HOME}/pupswap.swp"
else
pupswap validate /pupswap.swp && SWAPFILE="/pupswap.swp"
fi
if [ "${SWAPFILE}" ] ; then
SWAPSIZEBYTES=`stat -c %s ${SWAPFILE}` #bytes
[ $SWAPSIZEBYTES ] && EXTRAALLOCK=$(($EXTRAALLOCK + $SWAPSIZEBYTES))
echo -n "Loading swap file ${SWAPFILE} ("$(fx_format_bytes $SWAPSIZEBYTES)")..." >/dev/console
chmod 0660 $SWAPFILE
swapon ${SWAPFILE}
status_func $?
[ $? -eq 0 ] && SWAPON="yes"
fi
}
#================================================================
# MAIN
#================================================================
# mount devtmpfs early
[ ! -e /etc/DISTRO_SPECS ] && cp /initrd/DISTRO_SPECS /etc/DISTRO_SPECS
mount -t devtmpfs devtmpfs /dev 2>/dev/null
#Coped removed code from: s243a: https://github.com/puppylinux-woof-CE/woof-CE/commit/54ef39153265bc8e032179f188c172d15b5f02f0
# if devtmpfs fails, we're probably dealing with old stuff...
#
if [ ! -e /dev/tty ] ; then
if [ "`mount | cut -f 1 -d ' ' | grep devtmpfs`" = "" ] ; then
tar -zxf /dev2.tar.gz #no devtmpfs
( cd / ; tar -zxf /initrd/dev2.tar.gz ; ) #no devtmpfs
echo "Failed to mount devtmpfs" > /dev/console
fi
fi
. /etc/rc.d/PUPSTATE
. /etc/DISTRO_SPECS
. /etc/rc.d/BOOTCONSTRAINED # has BOOT_DISABLESWAP, BOOT_ATIME, BOOT_DIRTYWRITE.
. /etc/rc.d/MODULESCONFIG #modules loading configuration.
[ $loglevel ] && LOGLEVEL=$loglevel #boot param.
[ $pmedia ] && PMEDIA=$pmedia #boot parameter, broad category of boot media. ex: cd.
[ $pdev1 ] && PDEV1=$pdev1 #boot parameter, partition have booted off. ex: hda3
#if have just done a switch_root, output a 'done' message...
[ $PUPMODE -ne 2 ] && status_func 0
ORIGLANG="`grep '^LANG=' /etc/profile | cut -f 2 -d '=' | cut -f 1 -d ' '`" #120217
ORIGLANG1="${ORIGLANG%_*}" #ex: en
export LANG=C
#120301 a problem if initrd has kernel default font, switching here changes all o/p from initrd to partial garbage.
#workaround, clear the screen...
if [ $PUPMODE -ne 2 ] ; then #120313 fix...
PLANG1=`grep '^PLANG=' /etc/rc.d/PUPSTATE | cut -f 2 -d '=' | cut -f 1 -d '_'`
[ ! "$PLANG1" ] && PLANG1='en'
[ "$ORIGLANG1" != "$PLANG1" ] && clear > /dev/console #120331 redirection is required.
fi
load_consolefont #120301 if this was done in initrd then it would carry through, and this would not be needed.
#...this is done in rc.country, but needs to be move above all the o/p to /dev/console.
STATUS=0
##############MAKE FILESYSTEM USABLE################
echo -n "Making the filesystem usable..." >/dev/console
# mount /proc before remounting / as rw (full install)
mount -t proc none /proc 2>/dev/null; STATUS=$((STATUS+$?))
FREERAM=`free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 4 -d ' '` #w481 110405
QTRFREERAM=`expr $FREERAM \/ 4`
#=============== full-hd-install
if [ $PUPMODE -eq 2 ] ; then
#no longer deleting /tmp/* in rc.shutdown... (note, init script in initrd.gz wipes it)
rm -rf /tmp/*
rm -rf /tmp/.[0-9a-zA-Z]*
mount -t tmpfs -o size=${QTRFREERAM}k tmpfs /tmp ;STATUS=$((STATUS+$?))
chmod 1777 /tmp 2>/dev/null
dmesg | grep -o 'EXT[2,3,4]-fs.*running e2fsck is recommended' > /tmp/dmesg_e2fsck_warnings1
if grep -G "(${PDEV1})" /tmp/dmesg_e2fsck_warnings1 ; then
#EXT3-fs (sda9): warning: mounting fs with errors, running e2fsck is recommended
#EXT3-fs (sda10): warning: maximal mount count reached, running e2fsck is recommended
echo > /tmp/bootsysinit_must_fsck
fi
fi
[ -f /xwin_xorgwizard_cli ] && mv /xwin_xorgwizard_cli /tmp/
[ -f /bootcnt.txt ] && mv /bootcnt.txt /tmp/
#===============
if [ "$BOOT_DIRTYWRITE" ];then #120704 see /etc/rc.d/BOOTCONSTRAINED, variable set in 3builddistro.
#i have set this as 1500 which is 15 seconds (default is 5 seconds).
echo $BOOT_DIRTYWRITE > /proc/sys/vm/dirty_writeback_centisecs #refer: http://www.lesswatts.org/tips/disks.php
fi
#redirect all output to a log file (must do after remount rw)...
if [ ! "$LOGLEVEL" ] ; then
exec 1>/tmp/bootsysinit.log 2>&1
fi
#mount/umount scripts no longer write to /etc/mtab, as gparted failed to create a
#gparted create ext3 part. failed, fixed by making /etc/mtab a symlink.
rm -f /etc/mtab
ln -sv /proc/mounts /etc/mtab
#120503 if kernel mounts a f.s. on /dev, removes my skeleton /dev
mkdir -p /dev/pts
mount -t devpts -o dev,suid,gid=2,mode=620 none /dev/pts ;STATUS=$((STATUS+$?))
mkdir /sys 2>/dev/null
mount -t sysfs none /sys ;STATUS=$((STATUS+$?))
##v2.20 some apps need shm (shared memory) (ex: xfdiff)... 100319 do this always...
mkdir -p /dev/shm #120503 if kernel mounts a f.s. on /dev, removes my skeleton /dev
mount -t tmpfs -o size=${QTRFREERAM}k shmfs /dev/shm ;STATUS=$((STATUS+$?))
# kernel modules.builtin/order can also be found in /etc/modules
# if somehow they're missing from /lib/modules, they will be copied back
KERNVER="`uname -r`"
[ ! -f /lib/modules/${KERNVER}/modules.builtin ] && \
cp -v /etc/modules/modules.builtin-${KERNVER} /lib/modules/${KERNVER}/modules.builtin
[ ! -f /lib/modules/${KERNVER}/modules.order ] && \
cp -v /etc/modules/modules.order-${KERNVER} /lib/modules/${KERNVER}/modules.order
#may need to run 'depmod'...
#live-cd may have been built without the modules.* files.
if [ ! -f /lib/modules/${KERNVER}/modules.dep ];then
NEEDDEPMOD="yes" #files may not be there to save space.
fi
if [ -f /var/local/rc_sysinit_force_depmod ] ; then
NEEDDEPMOD="yes"
rm -f /var/local/rc_sysinit_force_depmod
fi
if [ "$NEEDDEPMOD" = "yes" ];then
echo -n ' depmod' >/dev/console
depmod
fi
status_func $STATUS
mount -a #Load fstab entries
## process some specific kernel params here
for i in $(cat /proc/cmdline) ; do
case $i in
inteluxa|intel_uxa|uxa) xorg_intel_uxa.sh ;;
esac
done
######################LOAD SWAP#####################
[ "$BOOT_DISABLESWAP" ] && SWAPON="$BOOT_DISABLESWAP" #120704 now ask in 3builddistro if want use swap file/partition. anything not "yes" means no.
EXTRAALLOCK=0
[ "$SWAPON" != "yes" ] && loadswap_func
if [ "$SWAPON" = "yes" ];then
# resize tmpfs
# this code is meant to increase the size of the tmpfs
# taking into account swap space and sfs_ram_sizek[might be removed]
EXTRAALLOCK=$(($EXTRAALLOCK / 2048)) #use half in KiB
RAMSIZE=$(free | grep -o 'Mem: .*' | tr -s ' ' | cut -f 2 -d ' ')
FREEK=$(($RAMSIZE / 2)) #half of physical.
ALLOCK=$(($FREEK + $EXTRAALLOCK))
if [ "$(grep '/initrd/mnt/tmpfs' /proc/mounts)" != "" ];then #mounted
[ -s /initrd/tmp/sfs_ram_sizek ] && ALLOCK=$(($ALLOCK + $(cat /initrd/tmp/sfs_ram_sizek))) #proper size
mount -t tmpfs -o remount,size=${ALLOCK}k tmpfs /initrd/mnt/tmpfs
elif [ $PUPMODE -eq 2 ];then #full-install
mount -t tmpfs -o remount,size=${ALLOCK}k tmpfs /tmp
fi
fi
# Setup /mnt/home symlink before sfs_load
rm -f /mnt/home 2>/dev/null
if [ $PUPMODE -eq 2 -o $PUPMODE -eq 77 ] ; then
PUP_HOME='/'
ln -sv / /mnt/home
else
if [ "$PUP_HOME" ];then #see /etc/rc.d/PUPSTATE
[ ! -d "/initrd${PUP_HOME}" ] && echo "ERROR: $PUP_HOME does not exist"
ln -sv /initrd${PUP_HOME} /mnt/home
fi
fi
#------ load extra sfs's if any ------
[ "$PUNIONFS" = "aufs" ] && sfs_load --cli start
#-------------------------------------
#######################VERSION UPDATE##########################
echo "VERSION UPDATE"
# rc.update determines what is to be updated according to $PUMODE
/etc/rc.d/rc.update $PUPMODE
status_func $STATUS
#ensure unique hostname: http://www.murga-linux.com/puppy/viewtopic.php?p=550932#550932
if [ "`cat /etc/hostname`" = "puppypc" ];then
echo -n "Updating unique hostname..." >/dev/console #hostname
echo "puppypc${RANDOM}" > /etc/hostname
PUPHOSTNAME="`cat /etc/hostname`"
HOSTSFILEFIRST="`grep -w 'puppypc' /etc/hosts|sed 's% puppypc%%'`"
HOSTSFILEREST="`grep -v 'puppypc' /etc/hosts`"
echo "$HOSTSFILEFIRST $PUPHOSTNAME" > /etc/hosts
echo "$HOSTSFILEREST" >> /etc/hosts
status_func 0
fi
#################LOAD KERNEL MODULES################
echo "LOAD KERNEL MODULES"
echo -n "Loading kernel modules..." >/dev/console
MODALIASES="`ls /sys/bus/*/devices/*/modalias`"
#101119 new /sbin/pup_event_backend_modprobe, these must be deleted every boot...
rm -f /etc/modprobe.d/alsa_card*.conf 2>/dev/null
rm -f /dev/ttyUSB* 2>/dev/null #101210 may have been left there if modem plugged in at shutdown.
rm -f /dev/mixer 2>/dev/null #see test in /etc/init.d/10alsa.
rm -f /dev/snd/* #after a reboot, some of these may be wrong.
mkdir /tmp/pup_event_backend #101210 for logging into, see /sbin/pup_event_backend_modprobe.
#101119 no longer using /tmp/pup_event_modprobe.conf, put blacklist into /etc/modprobe.d/...
rm -f /etc/modprobe.d/blacklist*.conf
BLACKLISTVARS="`echo "$SKIPLIST" | tr '\-' '_' | tr ' ' '\n' | sed -e 's/^/blacklist /' | grep -v ' $'`"
echo "$BLACKLISTVARS" > /etc/modprobe.d/blacklist.conf
if [ $PUPMODE -eq 2 ] ; then #full hd install.
#one config of 2.6.33 has base floppy and ps/2 mouse support not builtin. have this in 'init' also...
[ "`modinfo floppy 2>/dev/null`" != "" ] && modprobe floppy > /dev/null 2>&1
[ "`modinfo psmouse 2>/dev/null`" != "" ] && modprobe psmouse
#have this in 'init', probably need here too...
if [ "`echo "$MODALIASES" | grep 'bc0Csc03i10'`" != "" ];then
modprobe yenta-socket #101119
[ $? -eq 0 ] && sleep 2
fi
# k2.6.29.6 dmesg has warning that ehci-hcd should load before uhci-hcd and ohci-hid
# this is contrary to my understanding all these years, but oh well, let's do it...
[ "`lspci -n | grep ' 0c03: '`" != "" ] && modprobe ehci-hcd > /dev/null 2>&1 #110712 maybe builtin to kernel.
#...perhaps a udev rule could have done this?
fi
#130504 moved up, i think fbcon needs to be loaded before intel, nouveau modules load...
#101119 i really only want to load this for a kms-enabled video...
KMS=no
[ "`cat /proc/cmdline | grep 'modeset=1'`" != "" ] && KMS=yes
[ "`cat /etc/modprobe.d/* | grep '^options .* modeset=1'`" != "" ] && KMS=yes
[ "$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.
#130618 devtmpfs-enabled kernel, initrd may have loaded it on /dev
#device nodes created by kernel in initrd are all 'root' group.
#fix (before starting udevd)...
chmod 666 /dev/* 2>/dev/null
chmod 666 /dev/pts/* 2>/dev/null
chown -R root:tty /dev/pts/
chmod 666 /dev/null
chmod 666 /dev/zero
chmod 666 /dev/[pt]ty*
chmod 666 /dev/ptmx
chmod 777 /dev/pts/
chgrp tty /dev/[pt]ty*
chown -R root:tty /dev/pts/
chown root:tty /dev/tty1
chown root:tty /dev/ptmx
chgrp tty /dev/console #bugfix 140617
chgrp video /dev/fb0
chgrp floppy /dev/fd[0-9] 2>/dev/null
chgrp disk /dev/[hs]d[a-z]* 2>/dev/null
chgrp disk /dev/fuse
chgrp disk /dev/mmcblk* 2>/dev/null
chgrp disk /dev/nvme* 2>/dev/null
chgrp cdrom /dev/sr[0-9] 2>/dev/null
chmod 666 /dev/usb/* #rcrsn51 finally added 140618
chmod -R 1777 /dev/shm #SFR .. ditto
chmod 666 /dev/urandom #and again
rm -f /etc/init.d/udev #just in case
# UDEV_LOG=2 to prevent non-critical o/p to screen at bootup and shutdown...
#110502 change 'never' to 'early', fixes device nodes created with correct owner:group...
if [ "$BOOT_UDEVDCHILDREN" ];then #120709
UDEV_LOG=2 udevd --daemon --resolve-names=early --children-max=${BOOT_UDEVDCHILDREN} #BOOT_UDEVDCHILDREN=1 good idea?
else
UDEV_LOG=2 udevd --daemon --resolve-names=early
fi
sleep 0.1
#replay uevents from /sys...
for ONEMODALIAS in $MODALIASES
do
ONEPATH="`dirname $ONEMODALIAS`"
if [ -e ${ONEPATH}/uevent ];then
echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
sleep 0.02
fi
done
if [ $PUPMODE -eq 2 ] ; then #full hd installation.
modprobe nls_cp437 > /dev/null 2>&1 #these needed by vfat/ntfs/ext2 f.s.'s. 110712 maybe builtin.
modprobe nls_iso8859-1 > /dev/null 2>&1 # "
modprobe fuse 2>/dev/null
modprobe aufs 2>/dev/null
modprobe squashfs 2>/dev/null
if ! grep -q 'ATADRIVES=' /etc/rc.d/PUPSTATE ; then
# legacy stuff - should not be used in scripts
ALLDRVS0="`find /sys/block -maxdepth 1 -name 'mmc*' -o -name 'sd*' -o -name 'sr*' -o -name 'nvme*' | xargs -l readlink 2>/dev/null | grep -v '/usb[0-9]' | rev | cut -f 1 -d '/' | rev`" #all *except* usb!
ATADRIVES="`echo "$ALLDRVS0" | grep -v '^sr' | tr '\n' ' '`"
ATAOPTICALDRIVES="`echo "$ALLDRVS0" | grep '^sr' | tr '\n' ' '`"
ATADRIVES=$(echo $ATADRIVES)
ATAOPTICALDRIVES=$(echo $ATAOPTICALDRIVES)
(
echo '#ATADRIVES is all internal ide/pata/sata drives, excluding optical, excluding usb...'
echo "ATADRIVES='${ATADRIVES}'"
echo '#ATAOPTICALDRIVES is list of non-usb optical drives...'
echo "ATAOPTICALDRIVES='$ATAOPTICALDRIVES'"
) >> /etc/rc.d/PUPSTATE
fi
fi
[ ! -d /proc/acpi ] && modprobe apm #load apm.ko if no acpi.
zcat /proc/config.gz | grep -q '^CONFIG_INPUT_LEDS=m' && modprobe input-leds #for >= k4.2x
### /var/local/xorg_udev is created when:
### - a touchscreen has been detected
### - missing xorg input-kbd and input-mouse drivers [ex: ubuntu xenial]
TOUCHMOD=`lsmod|grep touch`
#mavrothal: Check if it is an OLPC XO and add the devices...
ISITANXO=`cat /sys/class/dmi/id/product_name`
ISITAMAC=`grep -i '^Apple' /sys/class/dmi/id/board_vendor`
[ "$DISTRO_BINARY_COMPAT" = 'slackware64' ] && lsuffix=64 || lsuffix=
if [ ! -f /usr/lib${lsuffix}/xorg/modules/input/kbd_drv.so -a ! -f /usr/lib${lsuffix}/xorg/modules/input/mouse_drv.so ] ; then
echo "Warning: Xorg kbd_drv.so and mouse_drv.so are missing"
XORG_UDEV=1
fi
# this might cause side effects.. only use with xorg udev stuff
# see http://murga-linux.com/puppy/viewtopic.php?t=108017&start=345
if [ -n "$TOUCHMOD" -o -n "$ISITAMAC" -o "$ISITANXO" = "XO" -o "$XORG_UDEV" = '1' ] ; then
udevadm trigger --action=add --subsystem-match="input" --subsystem-match="sound"
udevadm settle
fi
TOUCHSCREEN="$(udevadm info --export-db | grep ID_INPUT_TOUCHSCREEN=1)"
if [ -n "$TOUCHSCREEN" ] ; then
echo "Touchscreen detected: $TOUCHSCREEN"
XORG_UDEV=1
else
echo "No touchscreens detected"
fi
if [ -n "$ISITAMAC" ] ; then
echo "MAC detected: $ISITAMAC"
udevadm trigger --action=add --subsystem-match="power_supply"
udevadm settle
XORG_UDEV=1
fi
[ "$DISTRO_BINARY_COMPAT" = 'raspbian' ] && XORG_UDEV=1
if [ "$XORG_UDEV" = '1' ] ; then
echo "Activating Xorg Evdev"
[ ! -f /var/local/xorg_udev ] && rm -fv /etc/X11/xorg.conf #force xorgwizard-automatic
touch /var/local/xorg_udev
else
echo "Deactivating Xorg Evdev"
[ -f /var/local/xorg_udev ] && rm -fv /etc/X11/xorg.conf #force xorgwizard-automatic
rm -fv /var/local/xorg_udev
fi
status_func 0
#################MISC. SYSTEM SETUP#################
echo "MISC. SYSTEM SETUP"
echo -e "${DISTRO_NAME} Linux\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue
# see https://www.frozentux.net/iptables-tutorial/other/ip_dynaddr.txt
# turn on special handling of dynamic addresses - quiet mode
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
hostname -F /etc/hostname
# /mnt/+... are mountpoints created by filemnt
# but the dirs can remain after being unmounted or after an improper shutdown..
for i in $(ls -d /mnt/+* 2>/dev/null) ; do
rmdir $i 2>/dev/null
done
mkdir -p /var/local/shared
chmod 777 /var/local/shared
################WAIT MODULES LOADED##################
echo "WAIT MODULES LOADED"
#previous module loading may not have completed...
echo -n "Waiting for modules to complete loading..." >/dev/console
PCMCIABUILTIN='no'
if [ "`modinfo yenta_socket 2>/dev/null`" = "" ];then #Marvmod shut this up.
#kernel has PCMCIA core drivers builtin.
PCMCIABUILTIN='yes'
else
WAITCNT=0
PCIPCMCIA="`lspci -n | grep -o ' 0607: '`"
if [ "$PCIPCMCIA" != "" ];then #this may be slow to respond.
echo -n " pcmcia" >/dev/console
while [ $WAITCNT -lt 10 ];do
[ "`lsmod | grep -E '^yenta_socket |^tcic |^i82092 |^i82365 |^pd6729 '`" != "" ] && break
WAITCNT=`expr $WAITCNT + 1`
sleep 1
echo -n " $WAITCNT" >/dev/console
done
fi
fi
#note, if initrd then usb-storage will have already loaded...
USBBUILTIN='no'
if [ "`modinfo ehci_hcd 2>/dev/null`" = "" ];then #110712 shut this up.
#kernel has usb core drivers (and usb-storage) builtin.
USBBUILTIN='yes'
else
PCIUSB="`lspci -n | grep -o -E ' 0c03: '`" #160609
if [ "$PCIUSB" != "" ];then #this may be slow to respond.
echo -n " usb" >/dev/console
PCIUSBNUM=`echo "$PCIUSB" | sort -u | wc -l`
while [ $WAITCNT -lt 10 ];do
[ `lsmod | grep -o -E '^uhci_hcd|^ohci_hcd|^ehci_hcd|^xhci_hcd' | wc -l` -ge $PCIUSBNUM ] && break #160609
WAITCNT=`expr $WAITCNT + 1`
sleep 1
echo -n " $WAITCNT" >/dev/console
done
fi
fi
#110511 now using udevadm for usb, ssb and pcmcia... 110513 keep ssb as before...
#v424 try it a different way, this also fixes ssb devices (such as b43.ko)...
[ -e /sys/bus/ssb/devices ] && NEWSSB="`ls /sys/bus/ssb/devices/*/uevent 2>/dev/null | tr '\n' ' '`"
for ONEUEVENT in ${NEWSSB} #${NEWPCMCIA}${NEWUSB}${NEWSSB} #110511
do
ONEPATH="`dirname $ONEUEVENT`"
#the check for 'modalias' file is maybe needed for old kernel?...
[ ! -e ${ONEPATH}/modalias ] && [ "`grep 'MODALIAS' $ONEUEVENT`" = "" ] && continue
echo add > $ONEUEVENT
sleep 0.02
done
#wasn't getting the right uevents for my 3g modem... i think need this:
udevadm trigger --action=add --subsystem-match="pcmcia*" --subsystem-match="usb*"
if [ "$USBBUILTIN" = "no" ];then #110712
#wait for usb-storage drives to become available...(already done if initrd)
#note, udevd logs to this file when load modules
# (the latter via udev handler script /sbin/pup_event_backend_modprobe)...
#101119 /tmp/pup_event_backend/pup_event_module_devpath_log* now multiple files (see /sbin/pup_event_backend_modprobe)
if [ "`cat /tmp/pup_event_backend/pup_event_module_devpath_log* | grep 'usb_storage'`" != "" ];then #see pup_event_backend_modprobe
echo -n " usb-storage" >/dev/console
while [ $WAITCNT -lt 15 ];do
[ "`dmesg | grep 'usb-storage: device scan complete'`" != "" ] && break
sleep 1
WAITCNT=`expr $WAITCNT + 1`
echo -n " $WAITCNT" >/dev/console
done
#precaution, make sure have got them all... need sort -u...
USBSTORAGES=`dmesg | grep "usb-storage: device found at" | sort -u | wc -l`
while [ $WAITCNT -lt 15 ];do
AVAILABLEUSBSTORAGES=`dmesg | grep "usb-storage: device scan complete" | wc -l`
[ $AVAILABLEUSBSTORAGES -ge $USBSTORAGES ] && break
sleep 1
WAITCNT=`expr $WAITCNT + 1`
echo -n " $WAITCNT" >/dev/console
done
fi
sleep 1 #v411 a bit extra. rerwin reports usb mouse detection problem some hardware.
#(delay before usb mouse info appears in /proc/bus/input/devices)
fi
status_func 0
# -- from slackware's /etc/rc.d/rc.udev -- modded
# echo "Creating static nodes in /dev."
kmod_ver=$(kmod --version | cut -f 3 -d ' ' | head -n 1)
if [ "$kmod_ver" ] && [ $kmod_ver -ge 14 ] ; then #since v14
kmod static-nodes -f tmpfiles | \
while read F1 F2 F3 F4 F5 F6 F7 F8 ETC
do
[ -z "$F7" ] && continue #precaution
# mknod: /dev/net/tun: No such file or directory
[ ! -d ${F2%/*} ] && mkdir -p -m $F3 ${F2%/*}
# c! /dev/cuse 0600 - - - 10:203
mknod -m $F3 $F2 ${F1:0:1} ${F7%:*} ${F7#*:} 2>/dev/null #mknod -m 0600 /dev/cuse c 10 203
done
fi
# Add any system/locally defined additional device nodes:
cp --preserve=all --recursive --update /lib/udev/devices/* /dev 2> /dev/null
cp --preserve=all --recursive --update /etc/udev/devices/* /dev 2> /dev/null
# --
##############USER SELECTED MODULES##################
echo "USER SELECTED MODULES"
#the user can select extra modules to load in the BootManager...
if [ "$ADDLIST" != "" ];then #variable is in /etc/rc.d/MODULESCONFIG
echo -n "Loading user-selected modules..." >/dev/console
for MODULE in $ADDLIST
do
MPARAMS=""
if [ `echo -n "$MODULE" | tr ':' ' ' | wc -w` -gt 1 ];then
MPARAMS="`echo -n "$MODULE" | cut -f 2-9 -d ':' | tr ':' ' '`"
MODULE="`echo -n "$MODULE" | cut -f 1 -d ':'`"
fi
echo -n " $MODULE" >/dev/console
echo "Loading module $MODULE $MPARAMS"
done
status_func 0
fi
##############platform adjustments################## see fd64's #rc.platform
### - do it before we configure network and services
# detect if it's MacBookPro (mavrothal)
is_mbp="`dmesg | grep -qi macbookpro`"
if [ "$is_mbp" ] ; then
# enable gpe suppression and mbpfan
chmod 755 /etc/init.d/z-disable-spurious-gpe
if [ -f /etc/init.d/15-mbpfan ] ; then
chmod 755 /etc/init.d/15-mbpfan
fi
fi
###################SETUP SERVICES################
echo "SETUP SERVICES"
echo -n "Setting up services (network" >/dev/console
if [ -h /dev/modem ];then
DEVM="`readlink /dev/modem`"
case $DEVM in
modem) #error, circular link.
rm -f /dev/modem
DEVM=""
;;
/dev/*) #wrong format.
DEVM="`echo -n "$DEVM" | cut -f 3,4 -d '/'`"
ln -svnf $DEVM /dev/modem
;;
esac
case $DEVM in
ttyS[0-9]) #apparently setserial can crash with other modems.
setserial -v -b /dev/modem auto_irq skip_test autoconfig
;;
esac
fi
#had hoped to retire this, but HardInfo, Pupscan need it... 110814 fix test...
[ -e /proc/bus/usb ] && busybox mount -t usbfs none /proc/bus/usb
#only needed for 2.6.21.7, as 2.6.25.x loads these automatically...
#explicitly load battery, ac, thermal, fan modules.
modprobe battery
if [ -z "$ISITAMAC" ];then #don't run this block on mac
if [ -d /proc/acpi/battery ]; then
results="`find /proc/acpi/battery -mindepth 1 -type d`"
if [ ! -z "$results" ]; then
modprobe ac
modprobe thermal
modprobe fan
else
rmmod battery
fi
fi
fi
#----------------------
sleep 5 # in some cases network modules take some time to load
#100814 100903 record cumulative tx/rx, see also network_tray and rc.shutdown.
#181209 tx/rx logic now included in network_default_connect...
# Connect "current" or default network through eth0, frisbee, sns, network wizard, pgprs-connect, etc.
network_default_connect --sysinit #181209
#----------------------
echo -n ", printing, etc.)..." >/dev/console
# dbus
if which dbus-uuidgen &>/dev/null ; then
mkdir -p /var/lib/dbus /var/run/dbus
rm -f /var/lib/dbus/machine-id /etc/machine-id
chown messagebus /var/run/dbus
chgrp messagebus /var/run/dbus
dbus-uuidgen > /var/lib/dbus/machine-id
ln -snf /var/lib/dbus/machine-id /etc/machine-id
ln -snf /var/run/dbus /run/dbus
fi
#----------------------
/etc/rc.d/rc.services & #run scripts in /etc/rc.d/init.d
#----------------------
echo -e "\\033[64G\\033[1;33m[backgrounded]\\033[0;39m" >/dev/console #column 62, yellow. 110426: 64
# Try to make the font a reasonable size on high dpi displays. #rc.platform
/usr/bin/set-hidpi-font-size
############RECOGNISE MEDIA DEVICES################
echo "RECOGNISE MEDIA DEVICES"
STATUS=0
echo -n "Recognising media devices..." >/dev/console
echo -n ' optical' >/dev/console #optical drives
CDTYPE="" ; DVDTYPE=""
rm -f /dev/cdrom /dev/dvd /etc/cdburnerdevice 2>/dev/null
if [ -e /dev/sr0 ] ; then
ln -snfv /dev/sr0 /dev/cdrom
ln -snfv /dev/sr0 /dev/dvd
fi
echo -n ' input' >/dev/console #input
echo -n "input/mice" > /etc/mousedevice
ln -snfv input/mice /dev/mouse
#---- rc.country
/etc/rc.d/rc.country
###################PERSONAL BOOT SCRIPT######################
echo "PERSONAL BOOT SCRIPT"
#personal boot script here...
if [ ! -f /etc/rc.d/rc.local ];then
echo '#this file called from rc.sysinit' > /etc/rc.d/rc.local
echo '#you can edit this file' >> /etc/rc.d/rc.local
echo '#When firewall is installed, will append lines to this file...' >> /etc/rc.d/rc.local
fi
. /etc/rc.d/rc.local
#improper shutdown check. see above, also rc.shutdown and /sbin/init...
if [ $PUPMODE -eq 2 ];then #full hd install.
if [ "`mount | grep '^/dev/root ' | grep ' / '`" ] ; then
ln -sfnv /dev/${PDEV1} /dev/root 2>/dev/null
fi
#this file gets removed by rc.shutdown if a proper shutdown...
echo -n "${PDEV1},${DEV1FS}," > /fsckme.flg #ex: sda7,ext3,
busybox chmod 666 /fsckme.flg #110503 so non-root can delete it.
else
if [ "$PUPSAVE" -a $PUPMODE -ne 77 ];then # don't do this in a multi-session DVD (77)
echo -n "$PUPSAVE" > /initrd${PUP_HOME}/fsckme.flg #ex: sda7,ext3,/pupsave-10MAR2010.2fs
busybox chmod 666 /initrd${PUP_HOME}/fsckme.flg #110503 so non-root can delete it.
fi
fi
if [ "$BOOT_SCHEDULER" ];then #120704 see /etc/rc.d/BOOTCONSTRAINED, variable set in 3builddistro.
#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/
if [ "$PDEV1" ];then
PDEV="`echo -n "$PDEV1" | sed -e 's%[0-9]*$%%' -e 's%p$%%'`" #mmcblk0p2 becomes mmcblk0
if [ "`cat /sys/block/${PDEV}/queue/scheduler | grep "$BOOT_SCHEDULER"`" != "" ];then #check available.
if [ "`cat /sys/block/${PDEV}/queue/scheduler | cut -f 2 -d '[' | cut -f 1 -d ']' | grep "$BOOT_SCHEDULER"`" = "" ];then #check not already chosen.
echo $BOOT_SCHEDULER > /sys/block/${PDEV}/queue/scheduler
echo 1 > /sys/block/${PDEV}/queue/iosched/fifo_batch
fi
fi
fi
fi
# peebee work around for rfkill in some HP laptops
rfkill list | grep -q "yes" && rfkill unblock wlan
# SFR hack for IO bug http://murga-linux.com/puppy/viewtopic.php?p=681383#681383
KERNVER=${KERNVER%%-*} # just for appending "-4g","-PAE" or whatever
if [ ! "$PUPMODE" = 5 ];then
if vercmp $KERNVER ge 3.2 ;then
if vercmp $KERNVER lt 3.8 ;then
case "$DEV1FS" in ntfs|vfat|ext2|exfat) # changed 130210, SFR
mount -o remount,sync /dev/loop1 ;;
esac
fi
fi
fi
#that's it. next stop is /etc/profile...
###END###