]> Pileus Git - mkinit/blob - services.mk
Add munged/diod/mdadm, fix bitlbee/exim
[mkinit] / services.mk
1 MKSHELL=/opt/plan9/bin/rc
2
3 # Example
4 #test-start:VQPservice -u: foo-start
5 #       echo starting test
6 #       service -U $target
7 #
8 #test-stop:VQPservice -d: /
9 #       echo stopping test
10 #       service -D $target
11
12 # Core commands
13 # -------------
14 # Reboot commands
15 poweroff:V: halt 
16         $P poweroff -ndf
17 reboot:V: halt
18         $P reboot -ndf
19 kexec:V: halt
20         $P reboot -ndfk
21
22 # Initial setup/shutdown for mkinit
23 boot:VEPservice -u: /
24         echo Starting init
25         $P mount -o remount,rw /
26         # mount proc here to make bootchart happier
27         $P mount -t proc proc /proc
28         service -F
29         service -U $target
30
31 # Kill all process, then remount and sync
32 halt:QVE: utmp-stop hwclock-stop alsa-stop
33         echo TERMinating all processes
34         $P pkill -15 -vg0 >/dev/null >[2=1]
35         for (i in 1 2 3 4 5)
36                 $P pgrep -vg0 >/dev/null >[2=1] && $P sleep 1
37         echo KILLing all processes
38         $P pkill  -9 -vg0 >/dev/null >[2=1]
39         for (i in 1 2 3)
40                 $P pgrep -vg0 >/dev/null >[2=1] && $P sleep 1
41         service -F
42         echo Remounting read-only
43         $P mount -o remount,ro /
44         $P sync
45
46 # Bare
47 # ----
48 # Listener for /dev/initctl, for shutdown(8)
49 initctl-start:VPservice -u: boot
50         fifo=/dev/initctl
51         if (! test -e $fifo)
52                 $P mkfifo $fifo
53         { exec $P initctld $fifo |
54           while(line=`{line})
55                 $P mkinit $line >/dev/console >[2=1] 
56         } &
57         service -U $target
58 initctl-stop_cmd=fuser -k /dev/initctl
59
60 # Proc, mtab, fstab
61 mounts-start:VPservice -u: boot
62         $P cp /proc/mounts /etc/mtab
63         $P mdadm -A /dev/md4 /dev/sd[abc]4
64         $P mount -a
65         service -U $target
66
67 # Mount devtmpfs and shm/pts subfolders
68 devtmpfs-start:VEPservice -u: boot
69         $P mount /dev
70         $P mkdir /dev/shm
71         $P mkdir /dev/pts
72         service -U $target
73
74 # Start mdev as initial/daemon
75 mdev-start:VEPservice -u: mounts-start udev-stop
76         $P echo /sbin/mdev > /proc/sys/kernel/hotplug
77         $P mdev -s
78         service -U $target
79
80 # Start udev and trigger events
81 udev-start:VEPservice -u:  mounts-start
82         $P udevd --daemon
83         $P udevadm trigger
84         $P udevadm settle '--timeout=10'
85         service -U $target
86 udev-stop_cmd=pkill udevd
87
88 # Load kernel modules
89 modules-start:VEPservice -u: boot
90         $P modprobe uvesafb
91         $P modprobe evdev
92         service -U $target
93
94 # Clean out /tmp and /var/run directories
95 fsclean-start:VPservice -u: boot
96         dirs=(/var/run /tmp)
97         $P mkdir -p /.old
98         $P mv $dirs /.old || true
99         $P mkdir -p $dirs
100         $P chmod 1777 /tmp
101         $P install -m 777 -d /var/run/screen # Fuck you Screen
102         $P exec rm -rf /.old &
103         service -U $target
104
105 # Spawn gettys for tty[3456]
106 getty-start:VEPservice -u: hostname-start utmp-start
107         $P respawn /sbin/agetty 38400 tty3 linux
108         $P respawn /sbin/agetty 38400 tty4 linux
109         $P respawn /sbin/agetty 38400 tty5 linux
110         $P respawn /sbin/agetty 38400 tty6 linux
111         service -U $target
112 getty-stop_cmd=fuser -k /dev/tty3 /dev/tty4 /dev/tty5 /dev/tty6
113
114 # Spawn qingys for tty[2]
115 qingy-start:VEPservice -u: hostname-start utmp-start modules-start
116         $P respawn /sbin/qingy tty2
117         $P chvt 2
118         service -U $target
119 qingy-stop_cmd=fuser -k /dev/tty2
120
121 # Login records
122 utmp-start:VPservice -u: fsclean-start
123         for (i in /var/run/utmp /var/log/wtmp) {
124                 $P eval 'echo -n > $i'
125                 $P chgrp utmp $i
126                 $P chmod 0664 $i
127         }
128         service -U $target
129 utmp-stop_cmd=halt -w
130
131 # CPU freq
132 cpufreq-start:VPservice -u: mounts-start
133         $P cpufreq-set -g ondemand
134         service -U $target
135
136 # Localhost
137 localhost-start_cmd=ifconfig lo 127.0.0.1
138 localhost-stop_cmd=ifconfig lo down
139
140 # Set hostname
141 hostname-start_cmd=hostname
142
143 # Kernel parameters
144 sysctl-start_cmd=sysctl -p
145
146
147 # System
148 # -------
149 at-start_cmd=atd
150 at-stop_cmd=pkill atd
151
152 cron-start_cmd=cron
153 cron-stop_cmd=pkill cron
154
155 hddtemp-start:VPservice -u: localhost-start
156         $P hddtemp -d -l 127.0.0.1 /dev/sda
157         service -U $target
158 hddtemp-stop_cmd=pkill hddtemp
159
160 hwclock-start_cmd=hwclock --hctosys --utc
161 hwclock-stop_cmd=hwclock --systohc --utc
162
163 sshd-start_cmd=/usr/sbin/sshd
164 sshd-stop_cmd=pkill sshd
165
166 swap-start_cmd=swapon -a
167 swap-stop_cmd=swapoff -a
168
169 syslog-start:VPservice -u: mounts-start
170         $P syslog-ng
171         service -U $target
172 syslog-stop_cmd=pkill syslog
173
174
175 # Desktop
176 # -------
177 alsa-start_cmd=alsactl restore
178 alsa-stop_cmd=alsactl store
179
180 cups-start_cmd=cupsd
181 cups-stop_cmd=pkill cupsd
182
183 dbus-start:VPservice -u: fsclean-start localhost-start
184         $P mkdir -p /var/run/dbus
185         $P /usr/bin/dbus-daemon --system
186         service -U $target
187 dbus-stop_cmd=pkill dbus-daemon
188
189 gpm-start_cmd=gpm -m /dev/input/mice -t ps2
190 gpm-stop_cmd=pkill gpm
191
192 keymap-start_cmd=loadkeys -u us-cc
193
194 polipo-start:VPservice -u: localhost-start
195         $P polipo
196         service -U $target
197 polipo-stop_cmd=pkill polipo
198
199
200 # Server
201 # ------
202 apache2-start_cmd=apache2
203 apache2-stop_cmd=pkill apache2
204
205 #bitlbee-start_cmd=sudo -u bitlbee bitlbeed /usr/sbin/bitlbee
206 bitlbee-start_cmd=bitlbee -D -u bitlbee
207 bitlbee-stop_cmd=pkill bitlbee
208
209 courier-start:VPservice -u: fsclean-start
210         $P install -o mail -g mail -d /var/run/courier
211         $P authdaemond       start
212         $P courier           start
213         $P courierfilter     start
214         $P courier-imapd-ssl start
215         service -U $target
216 courier-stop_cmd=pkill '(courier|authdaemon)'
217
218 dhcp-start_cmd=dhcpcd eth0
219 dhcp-stop_cmd=dhcpcd eth0 -k
220
221 diod-start:VPservice -u: munged-start
222         $P diod --export-all
223         service -U $target
224 diod-stop_cmd=pkill diod
225
226 dovecot-start_cmd=dovecot
227 dovecot-stop_cmd=pkill dovecot
228
229 exim-start_cmd=exim -bd -q5m
230 exim-stop_cmd=pkill exim
231
232 gitd-start:VPservice -u: boot
233         $P exec /usr/libexec/git-core/git-daemon \
234                 '--syslog' \
235                 '--export-all' \
236                 '--user-path=git' \
237                 '--base-path=/home/server/git' \
238                 '--listen=0.0.0.0' \
239                 '--user=nobody' \
240                 '--group=nobody' &
241         service -U $target
242 gitd-stop_cmd=pkill git-daemon
243
244 munged-start_cmd=sudo -u munge -g munge munged
245 munged-stop_cmd=pkill munged
246
247 mysql-start:VPservice -u: fsclean-start
248         $P install -o mysql -g mysql -d /var/run/mysqld
249         $P exec mysqld &
250         service -U $target
251 mysql-stop_cmd=pkill mysqld
252
253 ntpd-start_cmd=ntpd
254 ntpd-stop_cmd=pkill ntpd
255
256 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
257 privoxy-stop_cmd=pkill privoxy
258
259 spamd-start_cmd=spamd -u spamd -d
260 spamd-stop_cmd=pkill spamd
261
262 tor-start:VPservice -u: boot
263         $P exec tor &
264         service -U $target
265 tor-stop_cmd=pkill tor
266
267 # Library 
268 # -------
269 %-start:QVPservice -u: boot
270         if (~ $#($stem^-start_cmd) 0)
271                 echo No such service $stem && exit 0
272         $P $($stem^-start_cmd) $($stem^-opts)
273         service -U $target
274
275 %-stop:QVPservice -d: /
276         if (~ $#($stem^-stop_cmd) 0)
277                 echo No such service $stem && exit 0
278         $P $($stem^-stop_cmd)
279         service -D $target
280
281 %-zap:QVPservice -d: /
282         service -D $target
283
284 %-status:QV:
285         service -q $target