]> Pileus Git - mkinit/blob - services.mk
Add cupsd 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 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 cups-start_cmd=cupsd
226 cups-stop_cmd=pkill cupsd
227
228 denyhosts-start_cmd=denyhosts.py --daemon
229 denyhosts-stop_cmd=pkill denyhosts.py
230
231 courier-start:VPservice -u: fsclean-start
232         $P install -o mail -g mail -d /var/run/courier
233         $P authdaemond       start
234         $P courier           start
235         $P courierfilter     start
236         $P courier-imapd-ssl start
237         service -U $target
238 courier-stop_cmd=pkill '(courier|authdaemon)'
239
240 dioc-start:VPservice -u: munged-start
241         $P mount -n /mnt/c
242         $P mount -n /mnt/c/mnt/x
243         service -U $target
244 dioc-stop:EVPservice -d:
245         $P umount /mnt/c/mnt/x
246         $P umount /mnt/c
247         service -D $target
248
249 diod-start:VPservice -u: munged-start
250         $P diod --export-all
251         service -U $target
252 diod-stop_cmd=pkill diod
253
254 dovecot-start_cmd=dovecot
255 dovecot-stop_cmd=pkill dovecot
256
257 eth0-start_cmd=dhcpcd eth0
258 eth0-stop_cmd=dhcpcd eth0 -k
259
260 exim-start_cmd=exim -bd -q5m
261 exim-stop_cmd=pkill exim
262
263 gitd-start:VPservice -u: boot
264         $P exec /usr/libexec/git-core/git-daemon \
265                 '--syslog' \
266                 '--export-all' \
267                 '--user-path=git' \
268                 '--interpolated-path=/etc/git/%H%D' \
269                 '--listen=0.0.0.0' \
270                 '--user=nobody' \
271                 '--group=nobody' &
272         service -U $target
273 gitd-stop_cmd=pkill git-daemon
274
275 jabberd-start_cmd=sudo -u jabber -g jabber jabberd -b
276 jabberd-stop_cmd=pkill --uid jabber
277
278 mailman-start_cmd=sudo -u mailman -g mailman \
279         /usr/lib64/mailman/bin/mailmanctl -s start
280 mailman-stop_cmd=sudo -u mailman -g mailman \
281         /usr/lib64/mailman/bin/mailmanctl stop
282
283 munged-start:VPservice -u: localhost-start mounts-start
284         $P install -o munge -g munge -d /var/run/munge
285         $P sudo -u munge -g munge munged
286         service -U $target
287 munged-stop_cmd=pkill munged
288
289 mysql-start:VPservice -u: fsclean-start
290         $P install -o mysql -g mysql -d /var/run/mysqld
291         $P exec mysqld &
292         service -U $target
293 mysql-stop_cmd=pkill mysqld
294
295 ntpd-start_cmd=ntpd
296 ntpd-stop_cmd=pkill ntpd
297
298 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
299 privoxy-stop_cmd=pkill privoxy
300
301 rngd-start_cmd=rngd -b -s64 -t60
302 rngd-stop_cmd=pkill rngd
303
304 spamd-start_cmd=spamd -u spamd -d
305 spamd-stop_cmd=pkill spamd
306
307 tftpd-start_cmd=in.tftpd -s -l /img/boot
308 tftpd-stop_cmd=
309
310 tor-start:VPservice -u: boot
311         $P exec tor &
312         service -U $target
313 tor-stop_cmd=pkill tor
314
315 wlan0-start:VPservice -u: wpa-start
316         $P dhcpcd wlan0
317         service -U $target
318 wlan0-stop_cmd=dhcpcd wlan0 -k
319
320 wpa-start:VPservice -u: mdev-start
321         $P modprobe b43
322         $P exec wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf &
323         service -U $target
324 wpa-stop_cmd=pkill wpa
325
326 # Library 
327 # -------
328 %-start:QVPservice -u: boot
329         if (~ $#($stem^-start_cmd) 0)
330                 echo No such service $stem && exit 0
331         $P $($stem^-start_cmd) $($stem^-opts)
332         service -U $target
333
334 %-stop:QVPservice -d: /
335         if (~ $#($stem^-stop_cmd) 0)
336                 echo No such service $stem
337         if not
338                 $P $($stem^-stop_cmd)
339         service -D $target
340
341 %-zap:QVPservice -d: /
342         service -D $target
343
344 %-status:QV:
345         service -q $target