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