Revised pretend-boot description
[rrq/subhost.git] / subhost-init
1 #!/bin/bash
2 #
3 # This is a script to run at startup of a bespoke sub-host
4
5 date +"subhost startup at %Y%m%d-%H%M%S"
6     
7 mkdir -p /dev/pts /dev/shm /run
8 [ -f /proc/mounts ] || mount -t proc proc /proc
9 if ! grep "^none /run tmpfs" /proc/mounts ; then
10     mount -t tmpfs -osize=80M none /run
11     mount -t tmpfs -osize=20M none /dev/shm
12     mount -t devpts none /dev/pts
13     mount -t sysfs none /sys
14     mkdir -p /run/lock /run/user
15 fi
16
17 if grep -q ' / ext4 rw,' /proc/mounts ; then
18     ##
19     ## Here's the "pretend init"
20     ##
21
22     zombie() {
23         wait
24         true # echo "zombie return $?" >&2
25     }
26     trap "zombie" 17 # SIGCHILD 
27
28     /etc/init.d/rc S < /dev/null
29     /etc/init.d/rc 2 < /dev/null
30     SUBHOSTCTL=/run/initctl
31     mkfifo $SUBHOSTCTL
32     exec cat < $SUBHOSTCTL
33     #exec /bin/bash -i
34 else
35     echo "** The root filesystem is read-only; EXITING" >&2
36     exit 1
37 fi