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