# drbl-client-boot - Init DRBL client boot
#
# Initialize the DRBL client boot
# LinuxMint refer from Ubuntu

description	"Init DRBL client boot"
author          "Steven Shiau <steven _at_ clonezilla org>, Ceasar Sun <ceasar _at_nchc org tw>"

start on (startup 
          and started rpcbind
          and started udev)

task

console output
script
     echo "Starting drbl-client-boot..."
     # Prepare the virtual filesystems. Here we do the same things that "mountall" does in mountall.conf (It's actually in the source code of mountall).
     # none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
     # none on /dev/shm type tmpfs (rw,nosuid,nodev)
     # none on /var/run type tmpfs (rw,nosuid,mode=0755)
     # none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
     # none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
     #
     # Without sleep 1, it seems every 4-5 times of booting, an error
     # "Can't lock lock /etc/mtab~: timed out" message will shown, and the rest of tasks in this drbl-client-boot service is aborted. Then the DRBL client will fail to finish normal diskless booting.
     #mkdir -p /dev/pts /dev/shm
     #mount -t devpts -o rw,noexec,nosuid,gid=tty,mode=0620 none /dev/pts
     #mount -t tmpfs -o rw,nosuid,nodev none /dev/shm
     #mount -a
     # 2012/05/01 Let mountall to deal with all instead of "mount -a", now mountall is better. However, do not use "mountall --daemon" otherwise some mounting will fail.
     sleep 1
     mountall
     # A workaround to avoid mountall issue
     # Ref: https://bugs.launchpad.net/ubuntu/+source/mountall/+bug/470776
     sleep 1
     mount -a -t nfs

     # Commented the following, and start mounted-var since from Ubuntu 11.10, the /var/run is linked to tmpfs /run, and mounted-var will clearn the stale files in /run.
     # ===Begin====
     # After "mount -a", we mount /var/{run,lock} to overwrite the one in NFS since we do not want the stale files
     #mkdir -p /var/run /var/lock
     #mount -t tmpfs -o rw,nosuid,mode=0755 none /var/run
     #mount -t tmpfs -o rw,noexec,nosuid,nodev none /var/lock
     # Once we have /var/run, we have to run mounted-var, but mounted-tmp and mounted-dev are not required.
     # 2012/05/01 Let now mountall will handle these, so forget these mounted-*.
     #start mounted-proc
     #start mounted-run
     #mkdir /run/lock
     #start mounted-var
     #start mounted-tmp
     #start mounted-debugfs
     # ===End====

     # Start dbus. No more hal since it's moved to Dbus.
     start dbus

     # Put a tag file for rcS to start
     touch /var/run/drbl-client-boot

     # Now we really let mountall service up, it will finish all the rest of signal...
     service mountall start

     # 2012/05/01 Let now mountall will handle these, so forget these initctl
     # Emit the events
     #initctl emit virtual-filesystems
     #initctl emit local-filesystems
     #initctl emit remote-filesystems
     #initctl emit all-swaps
     #initctl emit all-filesystems
     #initctl emit filesystem
     #initctl emit net-device-up IFACE=lo
     #initctl emit mounting
     #initctl emit mounted
end script
