]> Pileus Git - mkinit/blob - services.mk
Remove mtab line (use symlink instead)
[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 --inverse -g0 >/dev/null >[2=1]
35         for (i in 1 2 3 4 5)
36                 { $P pgrep -vg0 && $P sleep 1 }
37         echo KILLing all processes
38         $P pkill  -9 --inverse -g0 >/dev/null >[2=1]
39         for (i in 1 2 3)
40                 { $P pgrep -vg0 && $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 mdadm -A /dev/md4 /dev/sd[abc]4
63         $P mount -a
64         service -U $target
65
66 # Mount devtmpfs and shm/pts subfolders
67 devtmpfs-start:VEPservice -u: boot
68         $P mount /dev
69         $P mkdir /dev/shm
70         $P mkdir /dev/pts
71         service -U $target
72
73 # Start mdev as initial/daemon
74 mdev-start:VEPservice -u: mounts-start
75         $P echo /sbin/mdev > /proc/sys/kernel/hotplug
76         $P mdev -s
77         service -U $target
78
79 # Start udev and trigger events
80 udev-start:VEPservice -u:  mounts-start
81         $P udevd --daemon
82         $P udevadm trigger
83         $P udevadm settle '--timeout=10'
84         service -U $target
85 udev-stop_cmd=pkill udevd
86
87 # Load kernel modules
88 modules-start:VEPservice -u: boot
89         $P modprobe uvesafb
90         $P modprobe evdev
91         service -U $target
92
93 # Clean out /tmp and /var/run directories
94 fsclean-start:VPservice -u: boot
95         dirs=(/var/run /tmp)
96         $P mkdir -p /.old
97         $P mv $dirs /.old || true
98         $P mkdir -p $dirs
99         $P chmod 1777 /tmp
100         $P install -m 1777 -d /var/run/screen # Fuck you Screen
101         $P exec rm -rf /.old &
102         service -U $target
103
104 # Spawn gettys for tty[23456]
105 getty-start:VEPservice -u: hostname-start utmp-start
106         $P respawn setsid agetty 38400 tty2 linux
107         $P respawn setsid agetty 38400 tty3 linux
108         $P respawn setsid agetty 38400 tty4 linux
109         $P respawn setsid agetty 38400 tty5 linux
110         $P respawn setsid agetty 38400 tty6 linux
111         service -U $target
112 getty-stop_cmd=fuser -k /dev/tty2 /dev/tty3 /dev/tty4 /dev/tty5 /dev/tty6
113
114 # Spawn qingys for tty[7]
115 qingy-start:VEPservice -u: hostname-start utmp-start modules-start
116         $P respawn setsid /sbin/qingy-DirectFB tty7 &
117         $P chvt 7
118         service -U $target
119 qingy-stop_cmd=fuser -k /dev/tty7
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:VPservice -u: mounts-start
145         $P sysctl -p
146         $P chmod a+w /sys/class/leds/smc::kbd_backlight/brightness
147         $P chmod a+w /sys/class/backlight/gmux_backlight/brightness
148         service -U $target
149
150
151 # System
152 # -------
153 at-start_cmd=atd
154 at-stop_cmd=pkill atd
155
156 cron-start_cmd=cron
157 cron-stop_cmd=pkill cron
158
159 hddtemp-start_cmd=hddtemp -d
160 hddtemp-stop_cmd=pkill hddtemp
161
162 hwclock-start_cmd=hwclock --hctosys --utc
163 hwclock-stop_cmd=hwclock --systohc --utc
164
165 sshd-start_cmd=/usr/sbin/sshd
166 sshd-stop_cmd=pkill sshd
167
168 swap-start_cmd=swapon -a
169 swap-stop_cmd=swapoff -a
170
171 syslog-start:VPservice -u: mounts-start
172         $P syslog-ng
173         service -U $target
174 syslog-stop_cmd=pkill syslog
175
176
177 # Desktop
178 # -------
179 alsa-start_cmd=alsactl restore
180 alsa-stop_cmd=alsactl store
181
182 cups-start_cmd=cupsd
183 cups-stop_cmd=pkill cupsd
184
185 dbus-start:VPservice -u: fsclean-start localhost-start
186         $P install -m 1777 -d /var/run/dbus
187         $P /usr/bin/dbus-daemon --system
188         service -U $target
189 dbus-stop_cmd=pkill dbus-daemon
190
191 gpm-start_cmd=gpm -m /dev/input/mice -t ps2
192 gpm-stop_cmd=pkill gpm
193
194 gpsd-start_cmd=gpsd tcp://localhost:2222
195 gpsd-stop_cmd=pkill gpsd
196
197 keymap-start_cmd=loadkeys -u us-cc
198
199 polipo-start:VPservice -u: localhost-start
200         $P polipo
201         service -U $target
202 polipo-stop_cmd=pkill polipo
203
204
205 # Server
206 # ------
207 apache2-start:VPservice -u: fsclean-start
208         $P install -o apache -g apache -d /var/run/session
209         $P apache2 $apache2-opts
210 apache2-stop_cmd=pkill apache2
211
212 #bitlbee-start_cmd=sudo -u bitlbee bitlbeed /usr/sbin/bitlbee
213 bitlbee-start_cmd=bitlbee -D -u bitlbee
214 bitlbee-stop_cmd=pkill bitlbee
215
216 denyhosts-start_cmd=denyhosts.py --daemon
217 denyhosts-stop_cmd=pkill denyhosts.py
218
219 courier-start:VPservice -u: fsclean-start
220         $P install -o mail -g mail -d /var/run/courier
221         $P authdaemond       start
222         $P courier           start
223         $P courierfilter     start
224         $P courier-imapd-ssl start
225         service -U $target
226 courier-stop_cmd=pkill '(courier|authdaemon)'
227
228 dioc-start:VPservice -u: munged-start
229         $P mount -n /mnt/c
230         $P mount -n /mnt/c/mnt/x
231         service -U $target
232 dioc-stop:EVPservice -d:
233         $P umount /mnt/c/mnt/x
234         $P umount /mnt/c
235         service -D $target
236
237 diod-start:VPservice -u: munged-start
238         $P diod --export-all
239         service -U $target
240 diod-stop_cmd=pkill diod
241
242 dovecot-start_cmd=dovecot
243 dovecot-stop_cmd=pkill dovecot
244
245 eth0-start_cmd=dhcpcd eth0
246 eth0-stop_cmd=dhcpcd eth0 -k
247
248 exim-start_cmd=exim -bd -q5m
249 exim-stop_cmd=pkill exim
250
251 gitd-start:VPservice -u: boot
252         $P exec /usr/libexec/git-core/git-daemon \
253                 '--syslog' \
254                 '--export-all' \
255                 '--user-path=git' \
256                 '--interpolated-path=/etc/git/%H%D' \
257                 '--listen=0.0.0.0' \
258                 '--user=nobody' \
259                 '--group=nobody' &
260         service -U $target
261 gitd-stop_cmd=pkill git-daemon
262
263 mailman-start_cmd=sudo -u mailman -g mailman \
264         /usr/lib64/mailman/bin/mailmanctl -s start
265 mailman-stop_cmd=sudo -u mailman -g mailman \
266         /usr/lib64/mailman/bin/mailmanctl stop
267
268 munged-start:VPservice -u: boot
269         $P install -o munge -g munge -d /var/run/munge
270         $P sudo -u munge -g munge munged
271         service -U $target
272 munged-stop_cmd=pkill munged
273
274 mysql-start:VPservice -u: fsclean-start
275         $P install -o mysql -g mysql -d /var/run/mysqld
276         $P exec mysqld &
277         service -U $target
278 mysql-stop_cmd=pkill mysqld
279
280 ntpd-start_cmd=ntpd
281 ntpd-stop_cmd=pkill ntpd
282
283 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
284 privoxy-stop_cmd=pkill privoxy
285
286 rngd-start_cmd=rngd -b -s64 -t60
287 rngd-stop_cmd=pkill rngd
288
289 spamd-start_cmd=spamd -u spamd -d
290 spamd-stop_cmd=pkill spamd
291
292 tftpd-start_cmd=in.tftpd -s -l /img/boot
293 tftpd-stop_cmd=
294
295 tor-start:VPservice -u: boot
296         $P exec tor &
297         service -U $target
298 tor-stop_cmd=pkill tor
299
300 wlan0-start:VPservice -u: wpa-start
301         $P dhcpcd wlan0
302         service -U $target
303 wlan0-stop_cmd=dhcpcd wlan0 -k
304
305 wpa-start:VPservice -u: mdev-start
306         $P modprobe b43
307         $P exec wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf &
308         service -U $target
309 wpa-stop_cmd=pkill wpa
310
311 # Library 
312 # -------
313 %-start:QVPservice -u: boot
314         if (~ $#($stem^-start_cmd) 0)
315                 echo No such service $stem && exit 0
316         $P $($stem^-start_cmd) $($stem^-opts)
317         service -U $target
318
319 %-stop:QVPservice -d: /
320         if (~ $#($stem^-stop_cmd) 0)
321                 echo No such service $stem
322         if not
323                 $P $($stem^-stop_cmd)
324         service -D $target
325
326 %-zap:QVPservice -d: /
327         service -D $target
328
329 %-status:QV:
330         service -q $target