1 # Copyright (C) 2009 Andy Spencer
2 # See COPYING for terms
5 MKSHELL=/usr/lib/plan9/bin/rc
9 #test-start:VQPservice -u: foo-start
13 #test-stop:VQPservice -d: /
18 # single─bare─system─┬─desktop─>
21 desktop = alsa cups dbus keymap polipo
22 system = at cron hddtemp hwclock sshd swap syslog
23 bare = cpufreq fsclean getty qingy hostname initctl localhost modules mounts uevents utmp
27 server:V: `{echo $server^-start $system^-start $bare^-start}
28 desktop:V: `{echo $desktop^-start $system^-start $bare^-start}
29 system:V: `{echo $server^-stop $desktop^-stop $system^-start $bare^-start}
30 bare:V: `{echo $server^-stop $desktop^-stop $system^-stop $bare^-start}
31 single:V: `{echo $server^-stop $desktop^-stop $system^-stop $bare^-stop }
40 # Initial setup/shutdown for mkinit
43 $P mount -o remount,rw /
44 # mount proc here to make bootchart happier
45 $P mount -t proc proc /proc
49 # Kill all process, then remount and sync
50 halt:QVE: utmp-stop hwclock-stop alsa-stop
51 echo TERMinating all processes
52 $P pkill -15 -vg0 >/dev/null >[2=1]
54 $P pgrep -vg0 >/dev/null >[2=1] && $P sleep 1
55 echo KILLing all processes
56 $P pkill -9 -vg0 >/dev/null >[2=1]
58 $P pgrep -vg0 >/dev/null >[2=1] && $P sleep 1
60 echo Remounting read-only
61 $P mount -o remount,ro /
66 # Listener for /dev/initctl, for shutdown(8)
67 initctl-start:VPservice -u: boot
71 { exec $P initctld $fifo |
73 $P mkinit $line >/dev/console >[2=1]
76 initctl-stop_cmd=fuser -k /dev/initctl
78 # Proc, mtab, udev, fstab
79 mounts-start:VPservice -u: boot
80 $P cp /proc/mounts /etc/mtab
86 modules-start:VEPservice -u: boot
90 # Trigger udev uevents
91 uevents-start:VEPservice -u: mounts-start
93 $P udevadm settle '--timeout=10'
96 # Clean out /tmp and /var/run directories
97 fsclean-start:VPservice -u: boot
103 $P exec rm -rf /.old &
106 # Spawn gettys for tty[456]
107 getty-start:VEPservice -u: hostname-start utmp-start
108 $P respawn /sbin/agetty 38400 tty4 linux
109 $P respawn /sbin/agetty 38400 tty5 linux
110 $P respawn /sbin/agetty 38400 tty6 linux
112 getty-stop_cmd=fuser -k /dev/tty4 /dev/tty5 /dev/tty6
114 # Spawn qingys for tty[23]
115 qingy-start:VEPservice -u: hostname-start utmp-start modules-start uevents-start
116 $P respawn /sbin/qingy tty2
117 $P respawn /sbin/qingy tty3
119 qingy-stop_cmd=fuser -k /dev/tty2 /dev/tty3
122 utmp-start:VPservice -u: fsclean-start
123 for (i in /var/run/utmp /var/log/wtmp) {
124 $P eval 'echo -n > $i'
129 utmp-stop_cmd=halt -w
132 cpufreq-start:VPservice -u: uevents-start
133 $P cpufreq-set -g ondemand
137 localhost-start_cmd=ifconfig lo 127.0.0.1
138 localhost-stop_cmd=ifconfig lo down
141 hostname-start_cmd=hostname b
144 sysctl-start_cmd=sysctl -p
150 at-stop_cmd=pkill atd
153 cron-stop_cmd=pkill cron
155 hddtemp-start:VPservice -u: localhost-start
156 $P hddtemp -d -l 127.0.0.1 /dev/sda
158 hddtemp-stop_cmd=pkill hddtemp
160 hwclock-start_cmd=hwclock --hctosys --utc
161 hwclock-stop_cmd=hwclock --systohc --utc
163 sshd-start_cmd=/usr/sbin/sshd
164 sshd-stop_cmd=pkill sshd
166 swap-start_cmd=swapon -a
167 swap-stop_cmd=swapoff -a
169 syslog-start:VPservice -u: mounts-start
172 syslog-stop_cmd=pkill syslog
177 alsa-start_cmd=alsactl restore
178 alsa-stop_cmd=alsactl store
181 cups-stop_cmd=pkill cupsd
183 dbus-start:VPservice -u: fsclean-start localhost-start
184 $P mkdir -p /var/run/dbus
185 $P /usr/bin/dbus-daemon --system
187 dbus-stop_cmd=pkill dbus-daemon
189 keymap-start_cmd=loadkeys -u us-cc
191 polipo-start:VPservice -u: localhost-start
194 polipo-stop_cmd=pkill polipo
199 apache2-start_cmd=apache2 -DSSL -DPHP5
200 apache2-stop_cmd=pkill apache2
202 spam-start:VPservice -u: localhost-start
205 spam-stop_cmd=pkill spamd
209 %-start:VPservice -u: boot
210 if (~ $#($stem^-start_cmd) 0)
212 $P $($stem^-start_cmd)
215 %-stop:VPservice -d: /
216 if (~ $#($stem^-stop_cmd) 0)
218 $P $($stem^-stop_cmd)
221 %-zap:VPservice -d: /