]> Pileus Git - mkinit/blob - services.mk
Misc mkinit updates, notably removing udev
[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 # Load kernel modules
67 modules-start:VEPservice -u: boot
68         $P modprobe uvesafb
69         $P modprobe evdev
70         service -U $target
71
72 # Start udev and trigger events
73 udev-start:VEPservice -u:  mounts-start
74         $P udevd --daemon
75         $P udevadm trigger
76         $P udevadm settle '--timeout=10'
77         service -U $target
78
79 # Clean out /tmp and /var/run directories
80 fsclean-start:VPservice -u: boot
81         dirs=(/var/run /tmp)
82         $P mkdir -p /.old
83         $P mv $dirs /.old || true
84         $P mkdir -p $dirs
85         $P chmod 1777 /tmp
86         $P install -m 755 -d /var/run/screen # Fuck you Screen
87         $P exec rm -rf /.old &
88         service -U $target
89
90 # Spawn gettys for tty[3456]
91 getty-start:VEPservice -u: hostname-start utmp-start
92         $P respawn /sbin/agetty 38400 tty3 linux
93         $P respawn /sbin/agetty 38400 tty4 linux
94         $P respawn /sbin/agetty 38400 tty5 linux
95         $P respawn /sbin/agetty 38400 tty6 linux
96         service -U $target
97 getty-stop_cmd=fuser -k /dev/tty4 /dev/tty5 /dev/tty6
98
99 # Spawn qingys for tty[2]
100 qingy-start:VEPservice -u: hostname-start utmp-start modules-start
101         $P respawn /sbin/qingy tty2
102         $P chvt 2
103         service -U $target
104 qingy-stop_cmd=fuser -k /dev/tty2 /dev/tty3
105
106 # Login records
107 utmp-start:VPservice -u: fsclean-start
108         for (i in /var/run/utmp /var/log/wtmp) {
109                 $P eval 'echo -n > $i'
110                 $P chgrp utmp $i
111                 $P chmod 0664 $i
112         }
113         service -U $target
114 utmp-stop_cmd=halt -w
115
116 # CPU freq
117 cpufreq-start:VPservice -u: boot
118         $P cpufreq-set -g ondemand
119         service -U $target
120
121 # Localhost
122 localhost-start_cmd=ifconfig lo 127.0.0.1
123 localhost-stop_cmd=ifconfig lo down
124
125 # Set hostname
126 hostname-start_cmd=hostname
127
128 # Kernel parameters
129 sysctl-start_cmd=sysctl -p
130
131
132 # System
133 # -------
134 at-start_cmd=atd
135 at-stop_cmd=pkill atd
136
137 cron-start_cmd=cron
138 cron-stop_cmd=pkill cron
139
140 hddtemp-start:VPservice -u: localhost-start
141         $P hddtemp -d -l 127.0.0.1 /dev/sda
142         service -U $target
143 hddtemp-stop_cmd=pkill hddtemp
144
145 hwclock-start_cmd=hwclock --hctosys --utc
146 hwclock-stop_cmd=hwclock --systohc --utc
147
148 sshd-start_cmd=/usr/sbin/sshd
149 sshd-stop_cmd=pkill sshd
150
151 swap-start_cmd=swapon -a
152 swap-stop_cmd=swapoff -a
153
154 syslog-start:VPservice -u: mounts-start
155         $P syslog-ng
156         service -U $target
157 syslog-stop_cmd=pkill syslog
158
159
160 # Desktop
161 # -------
162 alsa-start_cmd=alsactl restore
163 alsa-stop_cmd=alsactl store
164
165 cups-start_cmd=cupsd
166 cups-stop_cmd=pkill cupsd
167
168 dbus-start:VPservice -u: fsclean-start localhost-start
169         $P mkdir -p /var/run/dbus
170         $P /usr/bin/dbus-daemon --system
171         service -U $target
172 dbus-stop_cmd=pkill dbus-daemon
173
174 keymap-start_cmd=loadkeys -u us-cc
175
176 polipo-start:VPservice -u: localhost-start
177         $P polipo
178         service -U $target
179 polipo-stop_cmd=pkill polipo
180
181
182 # Server
183 # ------
184 apache2-start_cmd=apache2
185 apache2-stop_cmd=pkill apache2
186
187 #bitlbee-start_cmd=sudo -u bitlbee bitlbeed /usr/sbin/bitlbee
188 bitlbee-start_cmd=bitlbee -D -u bitlbee
189 bitlbee-stop_cmd=pkill bitlbeed
190
191 courier-start:VPservice -u: fsclean-start
192         $P install -o mail -g mail -d /var/run/courier
193         $P authdaemond       start
194         $P courier           start
195         $P courierfilter     start
196         $P courier-imapd-ssl start
197         service -U $target
198 courier-stop_cmd=pkill '(courier|authdaemon)'
199
200 dhcp-start_cmd=dhcpcd eth0
201 dhcp-stop_cmd=dhcpcd eth0 -k
202
203 mysql-start:VPservice -u: fsclean-start
204         $P install -o mysql -g mysql -d /var/run/mysqld
205         $P mysqld &
206         service -U $target
207 mysql-stop_cmd=pkill mysqld
208
209 spamd-start_cmd=spamd -u spamd -d
210 spamd-stop_cmd=pkill spamd
211
212 tor-start:VPservice -u: boot
213         $P exec tor &
214         service -U $target
215 tor-stop_cmd=pkill tor
216
217 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
218 privoxy-stop_cmd=pkill privoxy
219
220 # Library 
221 # -------
222 %-start:QVPservice -u: boot
223         if (~ $#($stem^-start_cmd) 0)
224                 echo No such service $stem && exit 0
225         $P $($stem^-start_cmd) $($stem^-opts)
226         service -U $target
227
228 %-stop:QVPservice -d: /
229         if (~ $#($stem^-stop_cmd) 0)
230                 echo No such service $stem && exit 0
231         $P $($stem^-stop_cmd)
232         service -D $target
233
234 %-zap:QVPservice -d: /
235         service -D $target
236
237 %-status:QV:
238         service -q $target