]> Pileus Git - mkinit/blob - services.mk
Add jabberd service
[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:VPservice -u: localhost-start fsclean-start
157         $P cron
158         service -U $target
159 cron-stop_cmd=pkill cron
160
161 hddtemp-start_cmd=hddtemp -d
162 hddtemp-stop_cmd=pkill hddtemp
163
164 hwclock-start_cmd=hwclock --hctosys --utc
165 hwclock-stop_cmd=hwclock --systohc --utc
166
167 sshd-start_cmd=/usr/sbin/sshd
168 sshd-stop_cmd=pkill sshd
169
170 swap-start_cmd=swapon -a
171 swap-stop_cmd=swapoff -a
172
173 syslog-start:VPservice -u: mounts-start
174         $P syslog-ng
175         service -U $target
176 syslog-stop_cmd=pkill syslog
177
178
179 # Desktop
180 # -------
181 alsa-start_cmd=alsactl restore
182 alsa-stop_cmd=alsactl store
183
184 cups-start_cmd=cupsd
185 cups-stop_cmd=pkill cupsd
186
187 dbus-start:VPservice -u: fsclean-start localhost-start
188         $P install -m 1777 -d /var/run/dbus
189         $P /usr/bin/dbus-daemon --system
190         service -U $target
191 dbus-stop_cmd=pkill dbus-daemon
192
193 gpm-start_cmd=gpm -m /dev/input/mice -t ps2
194 gpm-stop_cmd=pkill gpm
195
196 gpsd-start_cmd=gpsd tcp://localhost:2222
197 gpsd-stop_cmd=pkill gpsd
198
199 keymap-start_cmd=loadkeys -u us-cc
200
201 polipo-start:VPservice -u: localhost-start
202         $P polipo
203         service -U $target
204 polipo-stop_cmd=pkill polipo
205
206
207 # Server
208 # ------
209 apache2-start:VPservice -u: fsclean-start
210         $P install -o apache -g apache -d /var/run/session
211         $P apache2 $(apache2-opts)
212         service -U $target
213 apache2-stop_cmd=pkill apache2
214
215 #bitlbee-start_cmd=sudo -u bitlbee bitlbeed /usr/sbin/bitlbee
216 bitlbee-start_cmd=bitlbee -D -u bitlbee
217 bitlbee-stop_cmd=pkill bitlbee
218
219 denyhosts-start_cmd=denyhosts.py --daemon
220 denyhosts-stop_cmd=pkill denyhosts.py
221
222 courier-start:VPservice -u: fsclean-start
223         $P install -o mail -g mail -d /var/run/courier
224         $P authdaemond       start
225         $P courier           start
226         $P courierfilter     start
227         $P courier-imapd-ssl start
228         service -U $target
229 courier-stop_cmd=pkill '(courier|authdaemon)'
230
231 dioc-start:VPservice -u: munged-start
232         $P mount -n /mnt/c
233         $P mount -n /mnt/c/mnt/x
234         service -U $target
235 dioc-stop:EVPservice -d:
236         $P umount /mnt/c/mnt/x
237         $P umount /mnt/c
238         service -D $target
239
240 diod-start:VPservice -u: munged-start
241         $P diod --export-all
242         service -U $target
243 diod-stop_cmd=pkill diod
244
245 dovecot-start_cmd=dovecot
246 dovecot-stop_cmd=pkill dovecot
247
248 eth0-start_cmd=dhcpcd eth0
249 eth0-stop_cmd=dhcpcd eth0 -k
250
251 exim-start_cmd=exim -bd -q5m
252 exim-stop_cmd=pkill exim
253
254 gitd-start:VPservice -u: boot
255         $P exec /usr/libexec/git-core/git-daemon \
256                 '--syslog' \
257                 '--export-all' \
258                 '--user-path=git' \
259                 '--interpolated-path=/etc/git/%H%D' \
260                 '--listen=0.0.0.0' \
261                 '--user=nobody' \
262                 '--group=nobody' &
263         service -U $target
264 gitd-stop_cmd=pkill git-daemon
265
266 jabberd-start_cmd=sudo -u jabber -g jabber jabberd -b
267 jabberd-stop_cmd=pkill --uid jabber
268
269 mailman-start_cmd=sudo -u mailman -g mailman \
270         /usr/lib64/mailman/bin/mailmanctl -s start
271 mailman-stop_cmd=sudo -u mailman -g mailman \
272         /usr/lib64/mailman/bin/mailmanctl stop
273
274 munged-start:VPservice -u: localhost-start mounts-start
275         $P install -o munge -g munge -d /var/run/munge
276         $P sudo -u munge -g munge munged
277         service -U $target
278 munged-stop_cmd=pkill munged
279
280 mysql-start:VPservice -u: fsclean-start
281         $P install -o mysql -g mysql -d /var/run/mysqld
282         $P exec mysqld &
283         service -U $target
284 mysql-stop_cmd=pkill mysqld
285
286 ntpd-start_cmd=ntpd
287 ntpd-stop_cmd=pkill ntpd
288
289 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
290 privoxy-stop_cmd=pkill privoxy
291
292 rngd-start_cmd=rngd -b -s64 -t60
293 rngd-stop_cmd=pkill rngd
294
295 spamd-start_cmd=spamd -u spamd -d
296 spamd-stop_cmd=pkill spamd
297
298 tftpd-start_cmd=in.tftpd -s -l /img/boot
299 tftpd-stop_cmd=
300
301 tor-start:VPservice -u: boot
302         $P exec tor &
303         service -U $target
304 tor-stop_cmd=pkill tor
305
306 wlan0-start:VPservice -u: wpa-start
307         $P dhcpcd wlan0
308         service -U $target
309 wlan0-stop_cmd=dhcpcd wlan0 -k
310
311 wpa-start:VPservice -u: mdev-start
312         $P modprobe b43
313         $P exec wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf &
314         service -U $target
315 wpa-stop_cmd=pkill wpa
316
317 # Library 
318 # -------
319 %-start:QVPservice -u: boot
320         if (~ $#($stem^-start_cmd) 0)
321                 echo No such service $stem && exit 0
322         $P $($stem^-start_cmd) $($stem^-opts)
323         service -U $target
324
325 %-stop:QVPservice -d: /
326         if (~ $#($stem^-stop_cmd) 0)
327                 echo No such service $stem
328         if not
329                 $P $($stem^-stop_cmd)
330         service -D $target
331
332 %-zap:QVPservice -d: /
333         service -D $target
334
335 %-status:QV:
336         service -q $target