]> Pileus Git - mkinit/blob - services.mk
Misc updates
[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 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 udev-stop
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 777 -d /var/run/screen # Fuck you Screen
101         $P exec rm -rf /.old &
102         service -U $target
103
104 # Spawn gettys for tty[3456]
105 getty-start:VEPservice -u: hostname-start utmp-start
106         $P respawn /sbin/agetty 38400 tty3 linux
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[2]
114 qingy-start:VEPservice -u: hostname-start utmp-start modules-start
115         $P respawn /sbin/qingy tty2
116         $P chvt 2
117         service -U $target
118 qingy-stop_cmd=fuser -k /dev/tty2
119
120 # Login records
121 utmp-start:VPservice -u: fsclean-start
122         for (i in /var/run/utmp /var/log/wtmp) {
123                 $P eval 'echo -n > $i'
124                 $P chgrp utmp $i
125                 $P chmod 0664 $i
126         }
127         service -U $target
128 utmp-stop_cmd=halt -w
129
130 # CPU freq
131 cpufreq-start:VPservice -u: mounts-start
132         $P cpufreq-set -g ondemand
133         service -U $target
134
135 # Localhost
136 localhost-start_cmd=ifconfig lo 127.0.0.1
137 localhost-stop_cmd=ifconfig lo down
138
139 # Set hostname
140 hostname-start_cmd=hostname
141
142 # Kernel parameters
143 sysctl-start_cmd=sysctl -p
144
145
146 # System
147 # -------
148 at-start_cmd=atd
149 at-stop_cmd=pkill atd
150
151 cron-start_cmd=cron
152 cron-stop_cmd=pkill cron
153
154 hddtemp-start:VPservice -u: localhost-start
155         $P hddtemp -d -l 127.0.0.1 /dev/sda
156         service -U $target
157 hddtemp-stop_cmd=pkill hddtemp
158
159 hwclock-start_cmd=hwclock --hctosys --utc
160 hwclock-stop_cmd=hwclock --systohc --utc
161
162 sshd-start_cmd=/usr/sbin/sshd
163 sshd-stop_cmd=pkill sshd
164
165 swap-start_cmd=swapon -a
166 swap-stop_cmd=swapoff -a
167
168 syslog-start:VPservice -u: mounts-start
169         $P syslog-ng
170         service -U $target
171 syslog-stop_cmd=pkill syslog
172
173
174 # Desktop
175 # -------
176 alsa-start_cmd=alsactl restore
177 alsa-stop_cmd=alsactl store
178
179 cups-start_cmd=cupsd
180 cups-stop_cmd=pkill cupsd
181
182 dbus-start:VPservice -u: fsclean-start localhost-start
183         $P mkdir -p /var/run/dbus
184         $P /usr/bin/dbus-daemon --system
185         service -U $target
186 dbus-stop_cmd=pkill dbus-daemon
187
188 gpm-start_cmd=gpm -m /dev/input/mice -t ps2
189 gpm-stop_cmd=pkill gpm
190
191 keymap-start_cmd=loadkeys -u us-cc
192
193 polipo-start:VPservice -u: localhost-start
194         $P polipo
195         service -U $target
196 polipo-stop_cmd=pkill polipo
197
198
199 # Server
200 # ------
201 apache2-start_cmd=apache2
202 apache2-stop_cmd=pkill apache2
203
204 #bitlbee-start_cmd=sudo -u bitlbee bitlbeed /usr/sbin/bitlbee
205 bitlbee-start_cmd=bitlbee -D -u bitlbee
206 bitlbee-stop_cmd=pkill bitlbeed
207
208 courier-start:VPservice -u: fsclean-start
209         $P install -o mail -g mail -d /var/run/courier
210         $P authdaemond       start
211         $P courier           start
212         $P courierfilter     start
213         $P courier-imapd-ssl start
214         service -U $target
215 courier-stop_cmd=pkill '(courier|authdaemon)'
216
217 dhcp-start_cmd=dhcpcd eth0
218 dhcp-stop_cmd=dhcpcd eth0 -k
219
220 dovecot-start_cmd=dovecot
221 dovecot-stop_cmd=pkill dovecot
222
223 exim-start_cmd=exim -q5m
224 exim-stop_cmd=pkill exim
225
226 gitd-start:VPservice -u: boot
227         $P exec /usr/libexec/git-core/git-daemon \
228                 '--syslog' \
229                 '--export-all' \
230                 '--user-path=git' \
231                 '--base-path=/home/server/git' \
232                 '--listen=0.0.0.0' \
233                 '--user=nobody' \
234                 '--group=nobody' &
235         service -U $target
236 gitd-stop_cmd=pkill git-daemon
237
238 mysql-start:VPservice -u: fsclean-start
239         $P install -o mysql -g mysql -d /var/run/mysqld
240         $P exec mysqld &
241         service -U $target
242 mysql-stop_cmd=pkill mysqld
243
244 ntpd-start_cmd=ntpd
245 ntpd-stop_cmd=pkill ntpd
246
247 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
248 privoxy-stop_cmd=pkill privoxy
249
250 spamd-start_cmd=spamd -u spamd -d
251 spamd-stop_cmd=pkill spamd
252
253 tor-start:VPservice -u: boot
254         $P exec tor &
255         service -U $target
256 tor-stop_cmd=pkill tor
257
258 # Library 
259 # -------
260 %-start:QVPservice -u: boot
261         if (~ $#($stem^-start_cmd) 0)
262                 echo No such service $stem && exit 0
263         $P $($stem^-start_cmd) $($stem^-opts)
264         service -U $target
265
266 %-stop:QVPservice -d: /
267         if (~ $#($stem^-stop_cmd) 0)
268                 echo No such service $stem && exit 0
269         $P $($stem^-stop_cmd)
270         service -D $target
271
272 %-zap:QVPservice -d: /
273         service -D $target
274
275 %-status:QV:
276         service -q $target