]> Pileus Git - mkinit/blob - services.mk
Add gpsd/tftp, update qingy/getty
[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[456]
106 getty-start:VEPservice -u: hostname-start utmp-start
107         $P respawn /sbin/agetty 38400 tty4 linux
108         $P respawn /sbin/agetty 38400 tty5 linux
109         $P respawn /sbin/agetty 38400 tty6 linux
110         service -U $target
111 getty-stop_cmd=fuser -k /dev/tty3 /dev/tty4 /dev/tty5 /dev/tty6
112
113 # Spawn qingys for tty[23]
114 qingy-start:VEPservice -u: hostname-start utmp-start modules-start
115         $P respawn /sbin/qingy tty2
116         $P respawn /sbin/qingy tty3 -t
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 gpsd-start_cmd=gpsd tcp://localhost:2222
193 gpsd-stop_cmd=pkill gpsd
194
195 keymap-start_cmd=loadkeys -u us-cc
196
197 polipo-start:VPservice -u: localhost-start
198         $P polipo
199         service -U $target
200 polipo-stop_cmd=pkill polipo
201
202
203 # Server
204 # ------
205 apache2-start_cmd=apache2
206 apache2-stop_cmd=pkill apache2
207
208 #bitlbee-start_cmd=sudo -u bitlbee bitlbeed /usr/sbin/bitlbee
209 bitlbee-start_cmd=bitlbee -D -u bitlbee
210 bitlbee-stop_cmd=pkill bitlbee
211
212 courier-start:VPservice -u: fsclean-start
213         $P install -o mail -g mail -d /var/run/courier
214         $P authdaemond       start
215         $P courier           start
216         $P courierfilter     start
217         $P courier-imapd-ssl start
218         service -U $target
219 courier-stop_cmd=pkill '(courier|authdaemon)'
220
221 dhcp-start_cmd=dhcpcd eth0
222 dhcp-stop_cmd=dhcpcd eth0 -k
223
224 diod-start:VPservice -u: munged-start
225         $P diod --export-all
226         service -U $target
227 diod-stop_cmd=pkill diod
228
229 dovecot-start_cmd=dovecot
230 dovecot-stop_cmd=pkill dovecot
231
232 exim-start_cmd=exim -bd -q5m
233 exim-stop_cmd=pkill exim
234
235 gitd-start:VPservice -u: boot
236         $P exec /usr/libexec/git-core/git-daemon \
237                 '--syslog' \
238                 '--export-all' \
239                 '--user-path=git' \
240                 '--base-path=/home/server/git' \
241                 '--listen=0.0.0.0' \
242                 '--user=nobody' \
243                 '--group=nobody' &
244         service -U $target
245 gitd-stop_cmd=pkill git-daemon
246
247 munged-start_cmd=sudo -u munge -g munge munged
248 munged-stop_cmd=pkill munged
249
250 mysql-start:VPservice -u: fsclean-start
251         $P install -o mysql -g mysql -d /var/run/mysqld
252         $P exec mysqld &
253         service -U $target
254 mysql-stop_cmd=pkill mysqld
255
256 ntpd-start_cmd=ntpd
257 ntpd-stop_cmd=pkill ntpd
258
259 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
260 privoxy-stop_cmd=pkill privoxy
261
262 spamd-start_cmd=spamd -u spamd -d
263 spamd-stop_cmd=pkill spamd
264
265 tftpd-start_cmd=in.tftpd -s -l /img/boot
266 tftpd-stop_cmd=
267
268 tor-start:VPservice -u: boot
269         $P exec tor &
270         service -U $target
271 tor-stop_cmd=pkill tor
272
273 # Library 
274 # -------
275 %-start:QVPservice -u: boot
276         if (~ $#($stem^-start_cmd) 0)
277                 echo No such service $stem && exit 0
278         $P $($stem^-start_cmd) $($stem^-opts)
279         service -U $target
280
281 %-stop:QVPservice -d: /
282         if (~ $#($stem^-stop_cmd) 0)
283                 echo No such service $stem && exit 0
284         $P $($stem^-stop_cmd)
285         service -D $target
286
287 %-zap:QVPservice -d: /
288         service -D $target
289
290 %-status:QV:
291         service -q $target