Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.55 KB | None | 0 0
  1. cat /etc/rc.d/rc.sysinit
  2. #!/bin/bash
  3. #
  4. # /etc/rc.d/rc.sysinit - run once at boot time
  5. #
  6. # Taken in part from Miquel van Smoorenburg's bcheckrc.
  7. #
  8.  
  9. HOSTNAME=$(/bin/hostname)
  10.  
  11. . /etc/init.d/functions
  12.  
  13. set -m
  14.  
  15. if [ -f /etc/sysconfig/network ]; then
  16. . /etc/sysconfig/network
  17. fi
  18.  
  19. # Read in config data.
  20. if [ -f /etc/sysconfig/system ]; then
  21. . /etc/sysconfig/system
  22. fi
  23.  
  24. if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
  25. HOSTNAME=localhost
  26. fi
  27.  
  28. if [ ! -e /proc/mounts ]; then
  29. mount -n -t proc /proc /proc
  30. mount -n -t sysfs /sys /sys >/dev/null 2>&1
  31. fi
  32.  
  33. PLYMOUTH=
  34. [ -x /bin/plymouth ] && PLYMOUTH=yes
  35.  
  36.  
  37. # Only read this once.
  38. cmdline=$(cat /proc/cmdline)
  39.  
  40. for t in $cmdline; do
  41. case $t in
  42. -s|single|S|s) REQUESTED_RUNLEVEL="S" ;;
  43. [1-9]) REQUESTED_RUNLEVEL="$t" ;;
  44. esac
  45. done
  46. [ -z "$REQUESTED_RUNLEVEL" ] && REQUESTED_RUNLEVEL=$(/bin/awk -F ':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' /etc/inittab)
  47. [ -z "$REQUESTED_RUNLEVEL" ] && REQUESTED_RUNLEVEL="3"
  48.  
  49. # killing splash when using single-user mode
  50. if [ "$REQUESTED_RUNLEVEL" == "S" ]; then
  51. [ -n "$PLYMOUTH" ] && /bin/plymouth quit 2>/dev/null
  52. fi
  53.  
  54. uname_r=`uname -r`
  55.  
  56. # Read in config data.
  57. if [ -f /etc/sysconfig/speedboot ]; then
  58. . /etc/sysconfig/speedboot
  59. fi
  60.  
  61. if strstr "$cmdline" speedboot= ; then
  62. for arg in $cmdline ; do
  63. if [ "${arg##speedboot=}" != "${arg}" ]; then
  64. SPEEDBOOT=${arg##speedboot=}
  65. fi
  66. done
  67. fi
  68.  
  69. if [ "$REQUESTED_RUNLEVEL" != 5 -o -f /etc/rc.d/rc5.d/S*network-auth -o -f /etc/crypttab ]; then
  70. SPEEDBOOT=no
  71. fi
  72.  
  73. # disable speedboot if more than one profile is found (and not selected in cmdline)
  74. if echo /etc/netprofile/profiles/* | grep -q ' ' ; then
  75. if ! strstr "$cmdline" PROFILE= ; then
  76. SPEEDBOOT=no
  77. fi
  78. fi
  79.  
  80. if strstr "$cmdline" failsafe ; then
  81. SPEEDBOOT=no
  82. fi
  83.  
  84. # Check if a possible DKMS display driver is queued to be built on this boot
  85. # or an interfering driver was loaded by initrd.
  86. if [ "$SPEEDBOOT" != "no" ] && [ -x /sbin/display_driver_helper ] && ! /sbin/display_driver_helper --check-speedboot; then
  87. SPEEDBOOT=no
  88. fi
  89.  
  90. if [ "$SPEEDBOOT" = "probe" ]; then
  91. SPEEDBOOT_PROBE=yes
  92. fi
  93.  
  94. if [ "x$SPEEDBOOT" = "xauto" ]; then
  95. STATUS=`grep -m 1 "$uname_r" /var/lib/speedboot/status 2>/dev/null`
  96. case "$STATUS" in
  97. *first\ time*) SPEEDBOOT=yes ;;
  98. *FAILED*) SPEEDBOOT=no ;;
  99. *OK*) SPEEDBOOT=yes ;;
  100. *STANDARD\ BOOT*) SPEEDBOOT=yes ;;
  101. *) SPEEDBOOT=no ;;
  102. esac
  103. fi
  104.  
  105. if [ "$SPEEDBOOT" = "yes" ]; then
  106. export SPEEDBOOT
  107. PROMPT=no
  108. else
  109. unset SPEEDBOOT
  110. fi
  111.  
  112. if [ "x$SPEEDBOOT" != "xyes" ]; then
  113. if [ ! -d /proc/bus/usb ]; then
  114. modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs -o devmode=0664,devgid=43 /proc/bus/usb /proc/bus/usb
  115. else
  116. mount -n -t usbfs -o devmode=0664,devgid=43 /proc/bus/usb /proc/bus/usb
  117. fi
  118. fi #SPEEDBOOT
  119.  
  120. if [ -f /.readahead_collect -a -r /etc/sysconfig/readahead ]; then
  121. . /etc/sysconfig/readahead
  122. if [ "x$READAHEAD_COLLECT" == "xyes" -a ! -f /forcefsck -a -x /sbin/readahead-collector ]; then
  123. /sbin/readahead-collector
  124. fi
  125. elif [ -x /sbin/readahead_early ]; then
  126. /sbin/readahead_early > /dev/null 2>&1
  127. fi
  128.  
  129. if [ -x /etc/rc.early.local ]; then
  130. . /etc/rc.early.local
  131. fi
  132.  
  133. # Unmount the initrd, if necessary
  134. # (pixel) do not unmount if /initrd/loopfs is mounted (happens for root loopback)
  135. # (bluca) handle udev /dev tmpfs here since kernel will happily umount /dev after initrd end
  136. # (blino) do it before the udev service is started so that it uses the /dev tmpfs from initrd
  137. if LC_ALL=C grep -q /initrd /proc/mounts && ! LC_ALL=C grep -q /initrd/loopfs /proc/mounts ; then
  138. if LC_ALL=C grep -q /initrd/dev /proc/mounts; then
  139. mount --move /initrd/dev /dev
  140. fi
  141. action "Unmounting initrd: " umount -l /initrd
  142. /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
  143. fi
  144.  
  145. if [ "x$SPEEDBOOT" = "xyes" ]; then
  146. /sbin/start_udev
  147. udevadm trigger --action=add --subsystem-match=pci --attr-match=class="0x0c03*"
  148. udevadm trigger --action=add --subsystem-match=block
  149. udevadm settle &
  150. UDEV_DISK_PID=$!
  151. udevadm trigger --action=add --subsystem-match=mem --subsystem-match=input --subsystem-match=tty --subsystem-match=acpi --subsystem-match=rtc --subsystem-match=hid
  152. udevadm trigger --action=add --subsystem-match=pci --attr-match=class="0x060000*"
  153. udevadm trigger --action=add --subsystem-match=pci --attr-match=class="0x03*"
  154. udevadm settle &
  155. UDEV_PID=$!
  156. fi
  157.  
  158. # Check SELinux status
  159. SELINUX_STATE=
  160. if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
  161. if [ -r "/selinux/enforce" ] ; then
  162. SELINUX_STATE=$(cat "/selinux/enforce")
  163. else
  164. # assume enforcing if you can't read it
  165. SELINUX_STATE=1
  166. fi
  167. fi
  168.  
  169. if [ -n "$SELINUX_STATE" ] && [ -x /sbin/restorecon ] && __fgrep " /dev " /proc/mounts >/dev/null 2>&1 ; then
  170. /sbin/restorecon -R /dev 2>/dev/null
  171. fi
  172.  
  173. disable_selinux() {
  174. gprintf "*** Warning -- SELinux is active\n"
  175. gprintf "*** Disabling security enforcement for system recovery.\n"
  176. gprintf "*** Run 'setenforce 1' to reenable.\n"
  177. echo "0" > "/selinux/enforce"
  178. }
  179.  
  180. relabel_selinux() {
  181. # if /sbin/init is not labeled correctly this process is running in the
  182. # wrong context, so a reboot will be required after relabel
  183. AUTORELABEL=
  184. . /etc/selinux/config
  185. echo "0" > /selinux/enforce
  186. [ -n "$PLYMOUTH" ] && plymouth --hide-splash
  187.  
  188. if [ "$AUTORELABEL" = "0" ]; then
  189. echo
  190. gprintf "*** Warning -- SELinux %s policy relabel is required. \n" ${SELINUXTYPE}
  191. gprintf "*** /etc/selinux/config indicates you want to manually fix labeling\n"
  192. gprintf "*** problems. Dropping you to a shell; the system will reboot\n"
  193. gprintf "*** when you leave the shell.\n"
  194. sulogin
  195.  
  196. else
  197. echo
  198. gprintf "*** Warning -- SELinux %s policy relabel is required.\n" ${SELINUXTYPE}
  199. gprintf "*** Relabeling could take a very long time, depending on file\n"
  200. gprintf "*** system size and speed of hard drives.\n"
  201.  
  202. /sbin/fixfiles -F restore > /dev/null 2>&1
  203. fi
  204. rm -f /.autorelabel
  205. gprintf "Unmounting file systems\n"
  206. umount -a
  207. mount -n -o remount,ro /
  208. gprintf "Automatic reboot in progress.\n"
  209. reboot -f
  210. }
  211.  
  212. # Print a text banner.
  213. # C-like escape sequences don't work as 2nd and up parameters of gprintf,
  214. # so real escap chars were written
  215. PRODUCT=`sed "s/.*release \([0-9.]*\).*/\1/g" /etc/mandriva-release 2> /dev/null`
  216. SYSTEM=${SYSTEM="Unity Linux"}
  217.  
  218. if [ -r /etc/sysconfig/oem ]; then
  219. . /etc/sysconfig/oem
  220. fi
  221.  
  222. if [ "$BOOTUP" != "serial" ]; then
  223. gprintf "\t\t\tWelcome to %s" "`echo -en '\\033[1;36m'`$SYSTEM`echo -en '\\033[0;39m'` $PRODUCT"
  224. else
  225. gprintf "\t\t\tWelcome to %s" "$SYSTEM $PRODUCT"
  226. fi
  227. echo -en "\r"
  228. echo
  229. if [ "$PROMPT" != "no" ]; then
  230. gprintf "\t\tPress 'I' to enter interactive startup."
  231. echo
  232. fi
  233.  
  234. # Fix console loglevel
  235. if [ -n "$LOGLEVEL" ]; then
  236. /bin/dmesg -n $LOGLEVEL
  237. fi
  238.  
  239. initsplash 5
  240. rc_splash start 1
  241.  
  242. # Initialize hardware
  243. if [ -f /proc/sys/kernel/modprobe ]; then
  244. if ! strstr "$cmdline" nomodules && [ -f /proc/modules ] ; then
  245. sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
  246. else
  247. # We used to set this to NULL, but that causes 'failed to exec' messages"
  248. sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
  249. fi
  250. fi
  251.  
  252. touch /dev/.in_sysinit >/dev/null 2>&1
  253.  
  254. # Set default affinity
  255. if [ -x /bin/taskset ]; then
  256. if strstr "$cmdline" default_affinity= ; then
  257. for arg in $cmdline ; do
  258. if [ "${arg##default_affinity=}" != "${arg}" ]; then
  259. /bin/taskset -p ${arg##default_affinity=} 1
  260. fi
  261. done
  262. fi
  263. fi
  264.  
  265. nashpid=$(pidof nash 2>/dev/null)
  266. [ -n "$nashpid" ] && kill $nashpid >/dev/null 2>&1
  267. unset nashpid
  268. if [ "x$SPEEDBOOT" != "xyes" ]; then
  269. /sbin/start_udev
  270. fi #SPEEDBOOT
  271.  
  272. # Load other user-defined modules
  273. for file in /etc/sysconfig/modules/*.modules ; do
  274. [ -x $file ] && $file
  275. done
  276.  
  277. # Load modules (for backward compatibility with VARs)
  278. if [ -f /etc/rc.modules ]; then
  279. if [ "x$SPEEDBOOT" != "xyes" ]; then
  280. /etc/rc.modules
  281. else
  282. ionice -c 3 /etc/rc.modules &
  283. MODULES_PID=$!
  284. fi
  285. fi
  286.  
  287. mount -n -t devpts -o mode=620 none /dev/pts >/dev/null 2>&1
  288. [ -n "$SELINUX_STATE" ] && restorecon /dev/pts >/dev/null 2>&1
  289.  
  290. mount -n -t tmpfs none /dev/shm >/dev/null 2>&1
  291.  
  292. # Configure kernel parameters
  293. update_boot_stage RCkernelparam
  294. sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
  295. for file in /etc/sysctl.d/* ; do
  296. is_ignored_file "$file" && continue
  297. test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1
  298. done
  299.  
  300. if [ "x$SPEEDBOOT" != "xyes" ]; then
  301.  
  302. # If brltty exist start it (after udev so that vcsa device nodes are created)
  303. [ -x /bin/brltty -a "$BRLTTY" != "no" ] && action "Starting braille terminal" /bin/brltty && SPEEDBOOT="DISABLED reason: braille"
  304.  
  305. fi #SPEEDBOOT
  306.  
  307. # Set the hostname.
  308. update_boot_stage RChostname
  309. action "Setting hostname %s: " ${HOSTNAME} hostname ${HOSTNAME}
  310.  
  311. # Set the NIS domain name
  312. if [ -n "$NISDOMAIN" ]; then
  313. action "Setting NIS domain name %s: " $NISDOMAIN nisdomainname $NISDOMAIN
  314. fi
  315.  
  316. if [ "x$SPEEDBOOT" != "xyes" ]; then
  317. # Now that we load only one scsi_hostadapter in the initrd, we
  318. # need to load the others here
  319. modprobe scsi_hostadapter >/dev/null 2>&1
  320. # Now that we use modular IDE, we need to do the same for IDE controllers
  321. modprobe ide-controller >/dev/null 2>&1
  322. # Sync waiting for storage.
  323. { rmmod scsi_wait_scan ; modprobe scsi_wait_scan ; rmmod scsi_wait_scan ; } >/dev/null 2>&1
  324.  
  325. # Start any MD RAID arrays that haven't been started yet
  326. if [ -f /etc/mdadm.conf -a -x /sbin/mdadm ]; then
  327. MDADM_RETURN=`/sbin/mdadm -As --auto=yes --run 2>&1`
  328. RETVAL=$?
  329. if [ $RETVAL -gt 0 ]; then
  330. echo $MDADM_RETURN | grep -q 'No arrays found in config file'
  331. RETVAL=$?
  332. # only enable speedboot if no array is configured
  333. if [ $RETVAL -gt 0 ]; then
  334. SPEEDBOOT="DISABLED: reason:MD RAID"
  335. fi
  336. else # MD RAID arrays detected, better to disable speedboot
  337. SPEEDBOOT="DISABLED: reason:MD RAID"
  338.  
  339. fi
  340. fi
  341. fi #SPEEDBOOT
  342.  
  343. # Device mapper & related initialization
  344. if ! __fgrep "device-mapper" /proc/devices >/dev/null 2>&1 ; then
  345. modprobe dm-mod >/dev/null 2>&1
  346. fi
  347.  
  348. if [ "x$SPEEDBOOT" != "xyes" ]; then
  349. if [ -f /etc/crypttab ]; then
  350. init_crypto 0
  351. fi
  352.  
  353. if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf ] && \
  354. [ -x /sbin/multipath ]; then
  355. modprobe dm-multipath > /dev/null 2>&1
  356. /sbin/multipath -v 0
  357. if [ -x /sbin/kpartx ]; then
  358. /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p" >/dev/null
  359. fi
  360. fi
  361.  
  362. if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid ]; then
  363. modprobe dm-mirror >/dev/null 2>&1
  364. dmraidsets=$(LC_ALL=C /sbin/dmraid -s -c -i)
  365. if [ "$dmraidsets" != "no raid disks" -a "$dmraidsets" != "no block devices found" ]; then
  366. for dmname in $dmraidsets; do
  367. if [[ "$dmname" =~ '^isw_.*' ]] && \
  368. ! strstr "$cmdline" noiswmd; then
  369. continue
  370. fi
  371.  
  372. /sbin/dmraid -ay -i --rm_partitions -p "$dmname" >/dev/null 2>&1
  373. /sbin/kpartx -a -p p "/dev/mapper/$dmname"
  374. SPEEDBOOT="DISABLED reason:dmraid"
  375. done
  376. fi
  377. fi
  378. fi #SPEEDBOOT
  379.  
  380. if [ -x /sbin/lvm ]; then
  381. action "Setting up Logical Volume Management:" /sbin/lvm vgchange -a y --ignorelockingfailure
  382. fi
  383.  
  384. if [ "x$SPEEDBOOT" != "xyes" ]; then
  385. if [ -f /etc/crypttab ]; then
  386. init_crypto 0
  387. fi
  388. fi #SPEEDBOOT
  389.  
  390. if [ -f /fastboot ] || strstr "$cmdline" fastboot ; then
  391. fastboot=yes
  392. fi
  393.  
  394. if [ -f /fsckoptions ]; then
  395. fsckoptions=$(cat /fsckoptions)
  396. fi
  397.  
  398. # (blino) always source autofsck settings, for AUTOFSCK_CRYPTO_TIMEOUT (#16029)
  399. [ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck
  400.  
  401. if [ -f /forcefsck ] || strstr "$cmdline" forcefsck ; then
  402. fsckoptions="-f $fsckoptions"
  403. elif [ -f /.autofsck ]; then
  404. if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
  405. AUTOFSCK_OPT="$AUTOFSCK_OPT -f"
  406. fi
  407. if [ -n "$AUTOFSCK_SINGLEUSER" ]; then
  408. [ -n "$PLYMOUTH" ] && plymouth --hide-splash
  409. rc_splash verbose
  410. echo
  411. gprintf "*** Warning -- the system did not shut down cleanly. \n"
  412. gprintf "*** Dropping you to a shell; the system will continue\n"
  413. gprintf "*** when you leave the shell.\n"
  414. [ -n "$SELINUX_STATE" ] && echo "0" > /selinux/enforce
  415. sulogin
  416. [ -n "$SELINUX_STATE" ] && echo "1" > /selinux/enforce
  417. [ -n "$PLYMOUTH" ] && plymouth --show-splash
  418. fi
  419. fsckoptions="$AUTOFSCK_OPT $fsckoptions"
  420. fi
  421.  
  422. if [ "$BOOTUP" = "color" ]; then
  423. fsckoptions="-C $fsckoptions"
  424. else
  425. fsckoptions="-V $fsckoptions"
  426. fi
  427.  
  428. READONLY=
  429. if [ -f /etc/sysconfig/readonly-root ]; then
  430. . /etc/sysconfig/readonly-root
  431. fi
  432. if strstr "$cmdline" readonlyroot ; then
  433. READONLY=yes
  434. [ -z "$RW_MOUNT" ] && RW_MOUNT=/var/lib/stateless/writable
  435. [ -z "$STATE_MOUNT" ] && STATE_MOUNT=/var/lib/stateless/state
  436. fi
  437. if strstr "$cmdline" noreadonlyroot ; then
  438. READONLY=no
  439. fi
  440.  
  441. if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then
  442.  
  443. mount_empty() {
  444. if [ -e "$1" ]; then
  445. echo "$1" | cpio -p -vd "$RW_MOUNT" &>/dev/null
  446. mount -n --bind "$RW_MOUNT$1" "$1"
  447. fi
  448. }
  449.  
  450. mount_dirs() {
  451. if [ -e "$1" ]; then
  452. mkdir -p "$RW_MOUNT$1"
  453. find "$1" -type d -print0 | cpio -p -0vd "$RW_MOUNT" &>/dev/null
  454. mount -n --bind "$RW_MOUNT$1" "$1"
  455. fi
  456. }
  457.  
  458. mount_files() {
  459. if [ -e "$1" ]; then
  460. cp -a --parents "$1" "$RW_MOUNT"
  461. mount -n --bind "$RW_MOUNT$1" "$1"
  462. fi
  463. }
  464.  
  465. # Common mount options for scratch space regardless of
  466. # type of backing store
  467. mountopts=
  468.  
  469. # Scan partitions for local scratch storage
  470. rw_mount_dev=$(blkid -t LABEL="$RW_LABEL" -l -o device)
  471.  
  472. # First try to mount scratch storage from /etc/fstab, then any
  473. # partition with the proper label. If either succeeds, be sure
  474. # to wipe the scratch storage clean. If both fail, then mount
  475. # scratch storage via tmpfs.
  476. if mount $mountopts "$RW_MOUNT" > /dev/null 2>&1 ; then
  477. rm -rf "$RW_MOUNT" > /dev/null 2>&1
  478. elif [ x$rw_mount_dev != x ] && mount $rw_mount_dev $mountopts "$RW_MOUNT" > /dev/null 2>&1; then
  479. rm -rf "$RW_MOUNT" > /dev/null 2>&1
  480. else
  481. mount -n -t tmpfs $RW_OPTIONS $mountopts none "$RW_MOUNT"
  482. fi
  483.  
  484. for file in /etc/rwtab /etc/rwtab.d/* /dev/.initramfs/rwtab ; do
  485. is_ignored_file "$file" && continue
  486. [ -f $file ] && cat $file | while read type path ; do
  487. case "$type" in
  488. empty)
  489. mount_empty $path
  490. ;;
  491. files)
  492. mount_files $path
  493. ;;
  494. dirs)
  495. mount_dirs $path
  496. ;;
  497. *)
  498. ;;
  499. esac
  500. [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path"
  501. done
  502. done
  503.  
  504. # Use any state passed by initramfs
  505. [ -d /dev/.initramfs/state ] && cp -a /dev/.initramfs/state/* $RW_MOUNT
  506.  
  507. # In theory there should be no more than one network interface active
  508. # this early in the boot process -- the one we're booting from.
  509. # Use the network address to set the hostname of the client. This
  510. # must be done even if we have local storage.
  511. ipaddr=
  512. if [ "$HOSTNAME" = "localhost" -o "$HOSTNAME" = "localhost.localdomain" ]; then
  513. ipaddr=$(ip addr show to 0.0.0.0/0 scope global | awk '/[[:space:]]inet / { print gensub("/.*","","g",$2) }')
  514. for ip in $ipaddr ; do
  515. HOSTNAME=
  516. eval $(ipcalc -h $ipaddr 2>/dev/null)
  517. [ -n "$HOSTNAME" ] && { hostname ${HOSTNAME} ; break; }
  518. done
  519. fi
  520.  
  521. # Clients with read-only root filesystems may be provided with a
  522. # place where they can place minimal amounts of persistent
  523. # state. SSH keys or puppet certificates for example.
  524. #
  525. # Ideally we'll use puppet to manage the state directory and to
  526. # create the bind mounts. However, until that's all ready this
  527. # is sufficient to build a working system.
  528.  
  529. # First try to mount persistent data from /etc/fstab, then any
  530. # partition with the proper label, then fallback to NFS
  531. state_mount_dev=$(blkid -t LABEL="$STATE_LABEL" -l -o device)
  532. if mount $mountopts $STATE_OPTIONS "$STATE_MOUNT" > /dev/null 2>&1 ; then
  533. /bin/true
  534. elif [ x$state_mount_dev != x ] && mount $state_mount_dev $mountopts "$STATE_MOUNT" > /dev/null 2>&1; then
  535. /bin/true
  536. elif [ ! -z "$CLIENTSTATE" ]; then
  537. # No local storage was found. Make a final attempt to find
  538. # state on an NFS server.
  539.  
  540. mount -t nfs $CLIENTSTATE/$HOSTNAME $STATE_MOUNT -o rw,nolock
  541. fi
  542.  
  543. if [ -w "$STATE_MOUNT" ]; then
  544.  
  545. mount_state() {
  546. if [ -e "$1" ]; then
  547. [ ! -e "$STATE_MOUNT$1" ] && cp -a --parents "$1" "$STATE_MOUNT"
  548. mount -n --bind "$STATE_MOUNT$1" "$1"
  549. fi
  550. }
  551.  
  552. for file in /etc/statetab /etc/statetab.d/* ; do
  553. is_ignored_file "$file" && continue
  554. [ ! -f "$file" ] && continue
  555.  
  556. if [ -f "$STATE_MOUNT/$file" ] ; then
  557. mount -n --bind "$STATE_MOUNT/$file" "$file"
  558. fi
  559.  
  560. for path in $(grep -v "^#" "$file" 2>/dev/null); do
  561. mount_state "$path"
  562. [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path"
  563. done
  564. done
  565.  
  566. if [ -f "$STATE_MOUNT/files" ] ; then
  567. for path in $(grep -v "^#" "$STATE_MOUNT/files" 2>/dev/null); do
  568. mount_state "$path"
  569. [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path"
  570. done
  571. fi
  572. fi
  573. fi
  574.  
  575. if [[ " $fsckoptions" != *" -y"* ]]; then
  576. fsckoptions="-a $fsckoptions"
  577. fi
  578.  
  579. _RUN_QUOTACHECK=0
  580. if strstr "$cmdline" forcequotacheck || [ -f /forcequotacheck ] ; then
  581. _RUN_QUOTACHECK=1
  582. fi
  583. Fsck()
  584. {
  585. fsck $*
  586. rc=$?
  587.  
  588. if [ "$rc" -eq "0" ]; then
  589. echo_success
  590. echo
  591. elif [ "$rc" -eq "1" ]; then
  592. echo_passed
  593. echo
  594. _RUN_QUOTACHECK=1
  595. elif [ "$rc" -eq "2" -o "$rc" -eq "3" ]; then
  596. gprintf "Unmounting file systems\n"
  597. umount -a
  598. mount -n -o remount,ro /
  599. gprintf "Automatic reboot in progress.\n"
  600. reboot -f
  601. elif [ $((rc & 4)) = 4 ]; then
  602. # Return code is a or between return codes for the filesystems
  603. # 4 means that a filesystem remains corrupted
  604. rc_splash verbose
  605. echo_failure
  606. echo
  607. echo
  608. gprintf "*** An error occurred during the file system check.\n"
  609. gprintf "*** Dropping you to a shell; the system will reboot\n"
  610. gprintf "*** when you leave the shell.\n"
  611.  
  612. str=`gprintf "(Repair filesystem)"`
  613. PS1="$str \# # "; export PS1
  614. [ "$SELINUX_STATE" = "1" ] && disable_selinux
  615. sulogin
  616.  
  617. gprintf "Unmounting file systems\n"
  618. umount -a
  619. mount -n -o remount,ro /
  620. gprintf "Automatic reboot in progress.\n"
  621. reboot -f
  622. else
  623. echo_failure
  624. echo
  625. gprintf "*** A non fatal error occurred during the file system check.\n"
  626. fi
  627. }
  628.  
  629. remount_needed() {
  630. local state oldifs
  631. [ "$READONLY" = "yes" ] && return 1
  632. state=$(LC_ALL=C awk '/ \/ / && ($3 !~ /rootfs/) { print $4 }' /proc/mounts)
  633. oldifs=$IFS
  634. IFS=","
  635. for opt in $state ; do
  636. if [ "$opt" = "rw" ]; then
  637. IFS=$oldifs
  638. return 1
  639. fi
  640. done
  641. IFS=$oldifs
  642. return 0
  643. }
  644.  
  645. if [ "x$SPEEDBOOT" = "xyes" ]; then
  646. wait $UDEV_DISK_PID
  647. fi
  648. # do not check / if already rw (for example with unionfs)
  649. if [ -z "$fastboot" -a "$READONLY" != "yes" ] && remount_needed; then
  650. gprintf "Checking root filesystem\n"
  651. Fsck -T -a $fsckoptions /
  652. fi
  653. _RUN_QUOTACHECK=0
  654.  
  655. # Remount the root filesystem read-write.
  656. update_boot_stage RCmountfs
  657. if remount_needed ; then
  658. action "Remounting root filesystem in read-write mode: " mount -n -o remount,rw /
  659. fi
  660.  
  661. # wait for usb storage scanning processes to finish
  662. if ! strstr "$cmdline" nousb; then
  663. LC_ALL=C grep '08' /sys/bus/usb/devices/*/bInterfaceClass >/dev/null 2>&1
  664. RETVAL=$?
  665. if [ $RETVAL -eq 0 ]; then
  666. countdown=20
  667. until [ -d /sys/module/usb_storage -o $countdown -eq 0 ]; do
  668. usleep 100000; let countdown=$countdown-1;
  669. done
  670. while ps -eocomm | grep -q usb-stor-scan; do
  671. sleep 1;
  672. done
  673. fi
  674. fi
  675.  
  676. if [ "x$SPEEDBOOT" != "xyes" ]; then
  677. # Clean up SELinux labels
  678. if [ -n "$SELINUX_STATE" ]; then
  679. restorecon /etc/mtab /etc/ld.so.cache /etc/blkid/blkid.tab /etc/resolv.conf >/dev/null 2>&1
  680. SPEEDBOOT="DISABLED reason: SELinux"
  681. fi
  682.  
  683. [ -x /sbin/hibernate-cleanup.sh ] && /sbin/hibernate-cleanup.sh start
  684.  
  685. # If relabeling, relabel mount points.
  686. if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then
  687. if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then
  688. restorecon $(awk '!/^#/ && $4 !~ /noauto/ && $2 ~ /^\// { print $2 }' /etc/fstab) >/dev/null 2>&1
  689. fi
  690. fi
  691. fi
  692.  
  693. if [ "$READONLY" != "yes" ] ; then
  694. # Clear mtab
  695. (> /etc/mtab) &> /dev/null
  696.  
  697. # Remove stale backups
  698. rm -f /etc/mtab~ /etc/mtab~~
  699.  
  700. # Enter mounted filesystems into /etc/mtab
  701. mount -f /
  702. mount -f /proc >/dev/null 2>&1
  703. mount -f /sys >/dev/null 2>&1
  704. mount -f /dev/pts >/dev/null 2>&1
  705. mount -f /dev/shm >/dev/null 2>&1
  706. mount -f /proc/bus/usb >/dev/null 2>&1
  707. fi
  708. # (pixel) also added /initrd/loopfs for loopback root
  709. mount -f /initrd/loopfs 2>/dev/null
  710.  
  711. if [ -x /sbin/isapnp -a -f /etc/isapnp.conf -a ! -f /proc/isapnp ]; then
  712. # check for arguments passed from kernel
  713. if ! strstr "$cmdline" nopnp ; then
  714. PNP=yes
  715. fi
  716. if [ -n "$PNP" ]; then
  717. action "Setting up ISA PNP devices: " /sbin/isapnp /etc/isapnp.conf
  718. else
  719. action "Skipping ISA PNP configuration at users request: " /bin/true
  720. fi
  721. fi
  722.  
  723. # tweak isapnp settings if needed.
  724. if [ -n "$PNP" -a -f /proc/isapnp -a -x /sbin/sndconfig ]; then
  725. /sbin/sndconfig --mungepnp >/dev/null 2>&1
  726. fi
  727.  
  728. # Check filesystems
  729. # (pixel) do not check loopback files, will be done later (aren't available yet)
  730. if [ -z "$fastboot" ]; then
  731. gprintf "Checking filesystems\n"
  732. Fsck -T -R -A -a -t noopts=loop $fsckoptions
  733. fi
  734.  
  735. # Mount all other filesystems (except for network bases filesystems and /proc, which is already
  736. # mounted). Contrary to standard usage,
  737. # filesystems are NOT unmounted in single user mode.
  738. # (pixel) also do not mount loopback and encrypted filesystems
  739. # will be done later
  740. (
  741. # export locales (needed by mount.ntfs-3g)
  742. export LC_ALL
  743. export LANG
  744. if [ "$READONLY" != "yes" ] ; then
  745. action "Mounting local filesystems: " mount -a -t nodevpts,nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev,noloop,noencrypted
  746. else
  747. action "Mounting local filesystems: " mount -a -n -t nodevpts,nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev,noloop,noencrypted
  748. fi
  749. )
  750.  
  751. if [ "x$SPEEDBOOT" != "xyes" ]; then
  752. [[ -z $AUTOFSCK_CRYPTO_TIMEOUT ]] && AUTOFSCK_CRYPTO_TIMEOUT=15
  753.  
  754. #Mounting Encrypted filesystem
  755. encrypted_swap=
  756. if [[ ! -f /fastboot ]];then
  757. encrypted=
  758. while read -a entry;do
  759. device=${entry[0]}
  760. mountpoint=${entry[1]}
  761. options=${entry[3]}
  762. type=${entry[2]}
  763. if [[ $options == *encryption=* || $options == *encrypted* ]];then
  764. [[ $options == *noauto* ]] && continue
  765. if [[ $type == *swap* ]];then
  766. encrypted_swap="$encrypted_swap $device"
  767. continue
  768. fi
  769. encrypted="$encrypted $mountpoint"
  770. fi
  771. done < /etc/fstab
  772. if [[ -n $encrypted ]];then
  773. modprobe cryptoloop
  774. rc_splash verbose
  775. echo "We have discovered Encrypted filesystems, do you want to mount them now ?"
  776. MSG=`gprintf "Press Y within %%d seconds to mount your encrypted filesystems..."`
  777. KEYS=`gprintf "yY"`
  778. if /sbin/getkey -c $AUTOFSCK_CRYPTO_TIMEOUT -m "$MSG" "$KEYS"; then
  779. echo -e '\n'
  780. for i in ${encrypted};do
  781. echo -n "${i} "; mount ${i}
  782. done
  783. else
  784. echo -e '\n'
  785. fi
  786. fi
  787. fi
  788.  
  789. # (pixel) Check loopback filesystems
  790. if [ ! -f /fastboot ]; then
  791. modprobe loop
  792. gprintf "Checking loopback filesystems"
  793. Fsck -T -R -A -a -t opts=loop $fsckoptions
  794. fi
  795.  
  796. fi #SPEEDBOOT
  797.  
  798. # Mount loopback
  799. action "Mounting loopback filesystems: " mount -a -O loop
  800.  
  801. # Update quotas if necessary
  802. if [ X"$_RUN_QUOTACHECK" = X1 ] && [ -x /sbin/quotacheck ]; then
  803. action "Checking local filesystem quotas: " /sbin/quotacheck -anug
  804. fi
  805.  
  806. if [ -x /sbin/quotaon ]; then
  807. action "Turning on user and group quotas for local filesystems: " /sbin/quotaon -aug
  808. fi
  809.  
  810. if [ "x$SPEEDBOOT" != "xyes" ]; then
  811. # Check to see if a full relabel is needed
  812. if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then
  813. if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then
  814. relabel_selinux
  815. fi
  816. else
  817. if [ "$READONLY" != "yes" ] && [ -d /etc/selinux ]; then
  818. [ -f /.autorelabel ] || touch /.autorelabel
  819. fi
  820. fi
  821. fi #SPEEDBOOT
  822.  
  823. # Initialize pseudo-random number generator
  824. if [ -f "/var/lib/random-seed" ]; then
  825. cat /var/lib/random-seed > /dev/urandom
  826. else
  827. [ "$READONLY" != "yes" ] && touch /var/lib/random-seed
  828. fi
  829. if [ "$READONLY" != "yes" ]; then
  830. chmod 600 /var/lib/random-seed
  831. dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null
  832. fi
  833. if [ "x$SPEEDBOOT" != "xyes" ]; then
  834. if [ -f /etc/crypttab ]; then
  835. init_crypto 1
  836. SPEEDBOOT="DISABLED reason: crypto FS"
  837. fi
  838.  
  839. # Configure machine if necessary.
  840. if [ -f /.unconfigured ]; then
  841.  
  842. if [ -x /usr/bin/plymouth ]; then
  843. /usr/bin/plymouth quit
  844. fi
  845.  
  846. if [ -x /usr/bin/system-config-keyboard ]; then
  847. /usr/bin/system-config-keyboard
  848. fi
  849. if [ -x /usr/bin/passwd ]; then
  850. /usr/bin/passwd root
  851. fi
  852. if [ -x /usr/sbin/system-config-network-tui ]; then
  853. /usr/sbin/system-config-network-tui
  854. fi
  855. if [ -x /usr/sbin/timeconfig ]; then
  856. /usr/sbin/timeconfig
  857. fi
  858. if [ -x /usr/sbin/authconfig-tui ]; then
  859. /usr/sbin/authconfig-tui --nostart
  860. fi
  861. if [ -x /usr/sbin/ntsysv ]; then
  862. /usr/sbin/ntsysv --level 35
  863. fi
  864.  
  865. # Reread in network configuration data.
  866. if [ -f /etc/sysconfig/network ]; then
  867. . /etc/sysconfig/network
  868.  
  869. # Reset the hostname.
  870. action "Resetting hostname %s: " ${HOSTNAME} hostname ${HOSTNAME}
  871.  
  872. # Reset the NIS domain name.
  873. if [ -n "$NISDOMAIN" ]; then
  874. action "Resetting NIS domain name %s: " $NISDOMAIN nisdomainname $NISDOMAIN
  875. fi
  876. fi
  877.  
  878. rm -f /.unconfigured
  879. fi
  880. fi
  881.  
  882. # Clean out /.
  883. rm -f /fastboot /fsckoptions /forcefsck /.autofsck /forcequotacheck /halt \
  884. /poweroff /.suspended /etc/killpower &> /dev/null
  885.  
  886. # Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might...
  887. _NEED_XFILES=
  888. [ -f /var/run/utmpx ] || [ -f /var/log/wtmpx ] && _NEED_XFILES=1
  889.  
  890. # Clean up /var.
  891. rm -rf /var/lock/cvs/* /var/run/screen/*
  892. find /var/lock /var/run ! -type d ! -path '/var/lock/TMP_1ST' -exec rm -f {} \;
  893.  
  894. if [ "x$SPEEDBOOT" = "xyes" ]; then
  895. wait $MODULES_PID
  896. wait $UDEV_PID
  897. /etc/rc.d/rc S &
  898. RC_PID=$!
  899. fi
  900. {
  901. # Clean up utmp/wtmp
  902. > /var/run/utmp
  903. touch /var/log/wtmp /var/log/btmp
  904. chgrp utmp /var/run/utmp /var/log/wtmp /var/log/btmp
  905. chmod 0664 /var/run/utmp /var/log/wtmp
  906. chmod 0600 /var/log/btmp
  907. if [ -n "$_NEED_XFILES" ]; then
  908. > /var/run/utmpx
  909. touch /var/log/wtmpx
  910. chgrp utmp /var/run/utmpx /var/log/wtmpx
  911. chmod 0664 /var/run/utmpx /var/log/wtmpx
  912. fi
  913. [ -n "$SELINUX_STATE" ] && restorecon /var/run/utmp* /var/log/wtmp* /var/log/btmp >/dev/null 2>&1
  914.  
  915. # Clean up various /tmp bits
  916. [ -n "$SELINUX_STATE" ] && restorecon /tmp
  917. rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.s.PGSQL.*
  918. rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
  919. /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
  920. /tmp/ssh-* /tmp/.fam_socket /tmp/.esd /tmp/.esd-* \
  921. /tmp/pulse-* /tmp/.sawfish-* /tmp/esrv* /tmp/kio* \
  922. /var/lib/gdm/core.*
  923.  
  924. # Make ICE directory
  925. mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1
  926. chown root:root /tmp/.ICE-unix
  927. [ -n "$SELINUX_STATE" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
  928.  
  929. # Start up swapping.
  930. update_boot_stage RCswap
  931. action "Enabling /etc/fstab swaps: " swapon -a -e 2>/dev/null
  932. if [ "$AUTOSWAP" = "yes" ]; then
  933. curswap=$(awk '/^\/dev/ { print $1 }' /proc/swaps | while read x; do get_numeric_dev dec $x ; echo -n " "; done)
  934. swappartitions=$(blkid -t TYPE=swap -o device)
  935. if [ x"$swappartitions" != x ]; then
  936. for partition in $swappartitions ; do
  937. [ ! -e $partition ] && continue
  938. majmin=$(get_numeric_dev dec $partition)
  939. echo $curswap | grep -qw "$majmin" || action "Enabling local swap partitions: " swapon $partition
  940. done
  941. fi
  942. fi
  943.  
  944. # Set up binfmt_misc
  945. /bin/mount -t binfmt_misc none /proc/sys/fs/binfmt_misc > /dev/null 2>&1
  946.  
  947. # Boot time profiles. Yes, this should be somewhere else.
  948. if [ -x /usr/sbin/system-config-network-cmd ]; then
  949. if strstr "$cmdline" netprofile= ; then
  950. for arg in $cmdline ; do
  951. if [ "${arg##netprofile=}" != "${arg}" ]; then
  952. /usr/sbin/system-config-network-cmd --profile ${arg##netprofile=}
  953. fi
  954. done
  955. fi
  956. fi
  957.  
  958. (
  959. # Now turn on swap in case we swap to files.
  960. action "Enabling swap space: " swapon -a -e
  961.  
  962. if [ "x$SPEEDBOOT" != "xyes" ]; then
  963. # If a SCSI tape has been detected, load the st module unconditionally
  964. # since many SCSI tapes don't deal well with st being loaded and unloaded
  965. if [ -n "$USEMODULES" -a -f /proc/scsi/scsi ] && LC_ALL=C grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
  966. LC_ALL=C fgrep -q ' 9 st' /proc/devices || modprobe st >/dev/null 2>&1
  967. SPEEDBOOT="DISABLED reason: SCSI tape"
  968. fi
  969. fi #SPEEDBOOT
  970.  
  971. (
  972. # Turn on harddisk optimization
  973. # There is only one file /etc/sysconfig/harddisks for all disks
  974. # after installing the hdparm-RPM. If you need different hdparm parameters
  975. # for each of your disks, copy /etc/sysconfig/harddisks to
  976. # /etc/sysconfig/harddiskhda (hdb, hdc...) and modify it.
  977. # Each disk which has no special parameters will use the defaults.
  978. # Each non-disk which has no special parameters will be ignored.
  979. #
  980.  
  981. disk[0]=s;
  982. disk[1]=hda; disk[2]=hdb; disk[3]=hdc; disk[4]=hdd;
  983. disk[5]=hde; disk[6]=hdf; disk[7]=hdg; disk[8]=hdh;
  984. disk[9]=hdi; disk[10]=hdj; disk[11]=hdk; disk[12]=hdl;
  985. disk[13]=hdm; disk[14]=hdn; disk[15]=hdo; disk[16]=hdp;
  986. disk[17]=hdq; disk[18]=hdr; disk[19]=hds; disk[20]=hdt;
  987. disk[21]=sda; disk[22]=sdb; disk[23]=sdc; disk[24]=sdd;
  988. disk[25]=sde; disk[26]=sdf; disk[27]=sdg; disk[28]=sdh;
  989. disk[29]=sr0; disk[30]=sr1; disk[31]=sr2; disk[32]=sr3;
  990. disk[33]=scd0; disk[34]=scd1; disk[35]=scd2; disk[36]=scd3;
  991. disk[37]=sg0; disk[38]=sg1; disk[39]=sg2; disk[40]=sg3;
  992.  
  993.  
  994. # Skip hard disks optimization if software RAID arrays are currently
  995. # resyncing and disks heavily active, because hdparm might hang and
  996. # lock system startup in such situation
  997.  
  998. if [ ! -f /proc/mdstat ] || ! /bin/egrep -qi "re(cover|sync)|syncing" /proc/mdstat; then
  999. if [ -x /sbin/hdparm ]; then
  1000. for device in {0..40}; do
  1001. unset MULTIPLE_IO USE_DMA EIDE_32BIT LOOKAHEAD EXTRA_PARAMS
  1002. if [ -f /etc/sysconfig/harddisk${disk[$device]} ]; then
  1003. . /etc/sysconfig/harddisk${disk[$device]}
  1004. HDFLAGS[$device]=
  1005. if [ -n "$MULTIPLE_IO" ]; then
  1006. HDFLAGS[$device]="-q -m$MULTIPLE_IO"
  1007. fi
  1008. if [ -n "$USE_DMA" ]; then
  1009. HDFLAGS[$device]="${HDFLAGS[$device]} -q -d$USE_DMA"
  1010. fi
  1011. if [ -n "$EIDE_32BIT" ]; then
  1012. HDFLAGS[$device]="${HDFLAGS[$device]} -q -c$EIDE_32BIT"
  1013. fi
  1014. if [ -n "$LOOKAHEAD" ]; then
  1015. HDFLAGS[$device]="${HDFLAGS[$device]} -q -A$LOOKAHEAD"
  1016. fi
  1017. if [ -n "$EXTRA_PARAMS" ]; then
  1018. HDFLAGS[$device]="${HDFLAGS[$device]} $EXTRA_PARAMS"
  1019. fi
  1020. else
  1021. HDFLAGS[$device]="${HDFLAGS[0]}"
  1022. fi
  1023. if [ -e "/proc/ide/${disk[$device]}/media" -o -e "/sys/block/${disk[$device]}/device/vendor" ]; then
  1024. if [ -e "/proc/ide/${disk[$device]}/media" ]; then
  1025. hdmedia=`cat /proc/ide/${disk[$device]}/media`
  1026. else
  1027. hdmedia=`cat /sys/block/${disk[$device]}/device/vendor`
  1028. fi
  1029. if [ "$hdmedia" = "disk" -o "$vendor" = "ATA" -o -f "/etc/sysconfig/harddisk${disk[$device]}" ]; then
  1030. if [ -n "${HDFLAGS[$device]}" ]; then
  1031. sleep 2
  1032. action "Setting hard drive parameters for %s: " ${disk[$device]} /sbin/hdparm ${HDFLAGS[$device]} /dev/${disk[$device]}
  1033. fi
  1034. fi
  1035. fi
  1036. done
  1037. fi
  1038. else
  1039. action "RAID Arrays are resyncing. Skipping hard drive parameters section." /bin/true
  1040. fi
  1041. ) &
  1042.  
  1043.  
  1044. # Adjust symlinks as necessary in /boot to keep system services from
  1045. # spewing messages about mismatched System maps and so on.
  1046. if [ -L /boot/System.map -a -r /boot/System.map-$uname_r -a \
  1047. ! /boot/System.map -ef /boot/System.map-$uname_r ] ; then
  1048. ln -s -f System.map-$uname_r /boot/System.map 2>/dev/null
  1049. fi
  1050. if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
  1051. ln -s -f System.map-$uname_r /boot/System.map 2>/dev/null
  1052. fi
  1053.  
  1054. # Adjust symlinks as necessary in /boot to have the default config
  1055. if [ -L /boot/config -a -r /boot/config-$uname_r ] ; then
  1056. ln -sf config-$uname_r /boot/config 2>/dev/null
  1057. fi
  1058. if [ ! -e /boot/config -a -r /boot/config-$uname_r ] ; then
  1059. ln -sf config-$uname_r /boot/config 2>/dev/null
  1060. fi
  1061.  
  1062. # Now that we have all of our basic modules loaded and the kernel going,
  1063. # let's dump the syslog ring somewhere so we can find it later
  1064. [ -f /var/log/dmesg ] && mv -f /var/log/dmesg /var/log/dmesg.old
  1065. dmesg -s 131072 > /var/log/dmesg
  1066. ) &
  1067.  
  1068. # create the crash indicator flag to warn on crashes, offer fsck with timeout
  1069. touch /.autofsck &> /dev/null
  1070.  
  1071. if [ "$PROMPT" != no ]; then
  1072. while :; do
  1073. pid=$(/sbin/pidof getkey)
  1074. [ -n "$pid" -o -e /var/run/getkey_done ] && break
  1075. usleep 100000
  1076. done
  1077. [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
  1078. fi
  1079. } &
  1080. if strstr "$cmdline" confirm ; then
  1081. touch /var/run/confirm
  1082. fi
  1083. if [ "x$SPEEDBOOT" != "xyes" ]; then
  1084. if [ "$PROMPT" != "no" ]; then
  1085. /sbin/getkey i && touch /var/run/confirm
  1086. touch /var/run/getkey_done
  1087. fi
  1088. wait
  1089. [ "$PROMPT" != no ] && rm -f /var/run/getkey_done
  1090. fi
  1091.  
  1092. if strstr "$cmdline" failsafe; then
  1093. touch /var/run/failsafe
  1094. fi
  1095.  
  1096. if [ -f /var/lock/TMP_1ST ];then
  1097. if [ -f /etc/init.d/mandrake_firstime ];then
  1098. /bin/sh /etc/init.d/mandrake_firstime
  1099. fi
  1100. fi
  1101.  
  1102. if [ -f /etc/delete-guest-account ]; then
  1103. action "Removing Guest Account on first boot" /usr/sbin/userdel -r guest
  1104. rm -f /etc/delete-guest-account
  1105. # Remove Livecd file
  1106. rm -f /etc/LIVECD
  1107. # reset on first boot dpms to true so screensavers will kick in
  1108. # perl -pi -e "s|"DPMS\"" "\"false"|"DPMS"|" /etc/X11/xorg.conf
  1109. mv /usr/share/gdm/themes/Unity/background2.jpg /usr/share/gdm/themes/Unity/background.jpg
  1110. mv /usr/share/apps/kdm/themes/Unity/background2.jpg /usr/share/apps/kdm/themes/Unity/background.jpg
  1111. rm -rf /var/lib/rpm/__db.*
  1112. fi
  1113.  
  1114. if [ "x$SPEEDBOOT" = "xyes" ]; then
  1115. if [ ! -f /.readahead_collect -a -x /sbin/readahead_later ]; then
  1116. /sbin/readahead_later > /dev/null 2>&1
  1117. fi
  1118. # wait $RC_PID
  1119. # countdown=10
  1120. # until [ -e /tmp/.X11-unix/X0 -o $countdown -eq 0 ]; do
  1121. # sleep 1; let countdown=$countdown-1;
  1122. # done
  1123.  
  1124.  
  1125.  
  1126. /sbin/udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=block --subsystem-nomatch=mem --subsystem-nomatch=input --subsystem-nomatch=acpi --subsystem-nomatch=rtc --subsystem-nomatch=hid
  1127. /sbin/udevadm settle --timeout=5 > /dev/null 2>&1
  1128. /sbin/udevadm control --env=STARTUP=
  1129. mount -n -t usbfs -o devmode=0664,devgid=43 /proc/bus/usb /proc/bus/usb
  1130.  
  1131. # (anssi) at this point plymouth should have quit, reopen descriptors to
  1132. # ensure that the output of the rest of this script is seen if the user is
  1133. # not in X11
  1134. exec 0<>/proc/self/fd/0 1<>/proc/self/fd/1 2<>/proc/self/fd/2
  1135. fi
  1136.  
  1137. if [ -f /etc/init.d/mandrake_everytime ]; then
  1138. /bin/sh /etc/init.d/mandrake_everytime
  1139. fi
  1140.  
  1141. if [ "x$SPEEDBOOT_PROBE" = "xyes" ]; then
  1142. sed -i -e "/$uname_r .*/d" /var/lib/speedboot/status 2>/dev/null
  1143. unset SPEEDBOOT_PROBE
  1144. fi
  1145.  
  1146. if [ "x$SPEEDBOOT" = "xyes" -a ! -e /tmp/.X11-unix/X0 ]; then
  1147. /etc/init.d/dm stop
  1148. grep -q "$uname_r" /var/lib/speedboot/status 2> /dev/null
  1149. RETVAL=$?
  1150. if [ $RETVAL -eq 0 ]; then
  1151. sed -i -e "s/^$uname_r FAILED (first time)/$uname_r FAILED/g" -e "/FAILED/!s/^$uname_r .*/$uname_r FAILED (first time)/g" /var/lib/speedboot/status
  1152. else
  1153. echo "$uname_r FAILED (first time)" >> /var/lib/speedboot/status
  1154. fi
  1155. fi
  1156.  
  1157. # system configuration doesn't permit speedboot or speedboot failed, disable it
  1158. if strstr "$SPEEDBOOT" DISABLED ; then
  1159. grep -q $uname_r /var/lib/speedboot/status 2> /dev/null
  1160. RETVAL=$?
  1161. if [ $RETVAL -eq 0 ]; then
  1162. sed -i -e "s/^$uname_r .*/$uname_r $SPEEDBOOT/g" /var/lib/speedboot/status
  1163. else
  1164. echo "$uname_r $SPEEDBOOT" >> /var/lib/speedboot/status
  1165. fi
  1166. fi
  1167.  
  1168. unset SPEEDBOOT
  1169.  
  1170. # (pixel) a kind of profile for XF86Config
  1171. # if no XFree=XXX given on kernel command-line, restore XF86Config.standard
  1172. for i in XF86Config XF86Config-4; do
  1173. if [ -L "/etc/X11/$i" ]; then
  1174. XFree=`sed -n 's/.*XFree=\(\w*\).*/\1/p' /proc/cmdline`
  1175. [ -n "$XFree" ] || XFree=standard
  1176. [ -r "/etc/X11/$i.$XFree" ] && ln -sf "$i.$XFree" "/etc/X11/$i"
  1177. fi
  1178. done
  1179.  
  1180. # Let rhgb know that we're leaving rc.sysinit
  1181. if [ -x /usr/bin/plymouth ]; then
  1182. /usr/bin/plymouth --sysinit
  1183. fi
  1184.  
  1185. # remove this file at the very end, for speedboot
  1186. rm -f /dev/.in_sysinit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement