mount /proc
[rrq/subhost.git] / startup
1 #!/bin/bash
2 #
3 # This is a script to run at startup of a bespoke sub-host
4
5 NOW=$(date +"%Y%m%d-%H%M%S")
6
7 {
8     echo "Startup at $NOW"
9     set -x
10     
11     mkdir -p /dev/pts /dev/shm /run
12     [ -f /proc/mounts ] || mount -t proc proc /proc
13     if ! grep "^none /run tmpfs" /proc/mounts ; then
14         mount -t tmpfs -osize=80M none /run
15         mount -t tmpfs -osize=20M none /dev/shm
16         mount -t devpts none /dev/pts
17         mount -t sysfs none /sys
18         mkdir -p /run/lock /run/user
19     fi
20     
21     {
22         # Restart auto interfaces
23         for IF in $(grep "^auto" /etc/network/interfaces) ; do
24             [ -e "/sys/class/net/$IF" ] || continue
25             ifdown $IF
26             ifup $IF
27         done
28     
29         # Restart services
30         SERVICES=( )
31         for S in ${SERVICES[@]} ; do
32             service $S restart
33         done
34     } &
35     NETPID=$!
36
37 } |& tee /var/log/startup-$NOW.log
38
39 exec /bin/bash