fbs annotate examples/rcS.minimal @ rev 6

Add a minimal rcS boot script for example (from ARM version but usable on a desktop)
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 02 14:14:56 2014 +0200 (2014-05-02)
parents
children 74f94ca28f27
rev   line source
pankso@6 1 #!/bin/sh
pankso@6 2 #
pankso@6 3 # /etc/init.d/rcS : Initial boot script for SliTaz
pankso@6 4 # Config file is : /etc/rcS.conf
pankso@6 5 #
pankso@6 6 # rcS is the main initialization script used to check fs, mount, clean,
pankso@6 7 # run scripts and start daemons. This is a custom script for ARM to get
pankso@6 8 # a faster boot and skip things like handling cdrom.
pankso@6 9 #
pankso@6 10 # Copyright (C) 2012-2014 SliTaz - BSD License
pankso@6 11 #
pankso@6 12 . /lib/libtaz.sh
pankso@6 13 . /etc/rcS.conf
pankso@6 14 . /etc/fbs.conf
pankso@6 15
pankso@6 16 # Set default path
pankso@6 17 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
pankso@6 18
pankso@6 19 # Framebuffer Boot Splash
pankso@6 20 if [ "$FBSPLASH" == "on" ]; then
pankso@6 21 clear && usleep 250000
pankso@6 22 fifo="/fbs.fifo" && fbs start
pankso@6 23 echo "0" > ${fifo} && usleep 500000
pankso@6 24 fi
pankso@6 25
pankso@6 26 echo $(colorize 34 "Processing: /etc/init.d/rcS")
pankso@6 27
pankso@6 28 # Mount all from: /etc/fstab
pankso@6 29 echo "Mounting filesystems in fstab..."
pankso@6 30 mkdir -p /dev/pts /dev/shm
pankso@6 31 mount -a
pankso@6 32
pankso@6 33 [ "$fifo" ] && echo "10" > ${fifo} && usleep 500000
pankso@6 34
pankso@6 35 # Mount /run as tmpfs so runtime data are not written to disk
pankso@6 36 echo "Mounting tmpfs filesystem on: /run"
pankso@6 37 mount -t tmpfs tmpfs /run
pankso@6 38 mount --bind /run /var/run
pankso@6 39
pankso@6 40 # Store boot messages to log files
pankso@6 41 log="/var/log/boot.log"
pankso@6 42 dmesg > /var/log/dmesg.log &
pankso@6 43
pankso@6 44 # Be quiet at boot
pankso@6 45 echo "0 0 0 0" > /proc/sys/kernel/printk
pankso@6 46
pankso@6 47 [ "$fifo" ] && echo "20" > ${fifo}
pankso@6 48
pankso@6 49 # Use udev and disable hotplug helper (udevd listen to netlink)
pankso@6 50 if [ -x "/sbin/udevd" ]; then
pankso@6 51 echo "" > /proc/sys/kernel/hotplug
pankso@6 52 echo "Starting udev daemon..."
pankso@6 53 udevd --daemon 2>/dev/null
pankso@6 54 udevadm trigger
pankso@6 55 udevadm settle --timeout=120
pankso@6 56 else
pankso@6 57 # Fallback to Busybox mdev
pankso@6 58 echo -n "Creating device nodes: /sbin/mdev -s"
pankso@6 59 echo "/sbin/mdev" > /proc/sys/kernel/hotplug
pankso@6 60 mdev -s; status
pankso@6 61 fi
pankso@6 62
pankso@6 63 [ "$fifo" ] && echo "30" > ${fifo}
pankso@6 64
pankso@6 65 # Clean up /tmp
pankso@6 66 echo -n "Cleaning up temporary files: /tmp"
pankso@6 67 rm -rf /tmp && mkdir /tmp && chmod 1777 /tmp
pankso@6 68 status
pankso@6 69
pankso@6 70 [ "$fifo" ] && echo "40" > ${fifo}
pankso@6 71
pankso@6 72 # Start syslogd and klogd
pankso@6 73 echo -n "Starting system log daemons: syslogd/klogd..."
pankso@6 74 syslogd -s ${SYSLOGD_SIZE} && klogd
pankso@6 75 status
pankso@6 76
pankso@6 77 [ "$fifo" ] && echo "50" > ${fifo}
pankso@6 78
pankso@6 79 # Load all modules from config file
pankso@6 80 if [ "$LOAD_MODULES" ]; then
pankso@6 81 colorize 33 "Loading Kernel modules..."
pankso@6 82 for mod in ${LOAD_MODULES}; do
pankso@6 83 modprobe -v $mod | tee -a ${log}
pankso@6 84 done
pankso@6 85 fi
pankso@6 86
pankso@6 87 [ "$fifo" ] && echo "60" > ${fifo}
pankso@6 88
pankso@6 89 # Start all init scripts
pankso@6 90 for script in ${RUN_SCRIPTS}; do
pankso@6 91 colorize 34 "Processing: /etc/init.d/$script"
pankso@6 92 /etc/init.d/$script | tee -a ${log}
pankso@6 93 done
pankso@6 94
pankso@6 95 [ "$fifo" ] && echo "70" > ${fifo}
pankso@6 96
pankso@6 97 # Start all daemons
pankso@6 98 if [ "$RUN_DAEMONS" ]; then
pankso@6 99 colorize 33 "Starting all daemons..."
pankso@6 100 for daemon in ${RUN_DAEMONS}; do
pankso@6 101 /etc/init.d/$daemon start
pankso@6 102 done
pankso@6 103 fi
pankso@6 104
pankso@6 105 [ "$fifo" ] && echo "80" > ${fifo}
pankso@6 106
pankso@6 107 # Start X session
pankso@6 108 if [ -x "/etc/init.d/$LOGIN_MANAGER" ]; then
pankso@6 109 colorize 36 "Starting X environment..."
pankso@6 110 /etc/init.d/$LOGIN_MANAGER start >/dev/null &
pankso@6 111 fi
pankso@6 112
pankso@6 113 [ "$fifo" ] && echo "90" > ${fifo}
pankso@6 114
pankso@6 115 newline
pankso@6 116 colorize 32 "$MESSAGE"
pankso@6 117
pankso@6 118 # Exit fbs
pankso@6 119 if [ "$fifo" ]; then
pankso@6 120 echo "100" > ${fifo} && sleep 1
pankso@6 121 sleep 1 && echo "exit" > ${fifo} && rm -f ${fifo}
pankso@6 122 fi
pankso@6 123
pankso@6 124 # Back to a verbose mode but wait to finish with a clean boot
pankso@6 125 (sleep 4; echo "7 4 1 7" > /proc/sys/kernel/printk) &