]> Pileus Git - mkinit/blob - init.mk
formatting
[mkinit] / init.mk
1 # Copyright (C) 2009 Andy Spencer
2 # See COPYING for terms
3
4 # Config
5 MKSHELL=/usr/lib/plan9/bin/rc
6 NPROC=10
7
8 # Example
9 #test-start:VQPservice -u: foo-start
10 #       echo starting test
11 #       service -U $target
12 #
13 #test-stop:VQPservice -d: /
14 #       echo stopping test
15 #       service -D $target
16
17 # Runlevels
18 user   = alsa keymap polipo spam dbus
19 system = at cron hddtemp hostname hwclock i8k sshd swap syslog
20 bare   = cpufreq fsclean getty qingy localhost modules mounts uevents utmp
21
22 default:V: user
23
24 user:V:   `{echo $user^-start $system^-start $bare^-start}
25 system:V: `{echo $user^-stop  $system^-start $bare^-start}
26 bare:V:   `{echo $user^-stop  $system^-stop  $bare^-start}
27 single:V: `{echo $user^-stop  $system^-stop  $bare^-stop }
28
29 poweroff:V: halt 
30         $P poweroff -ndf
31 reboot:V: halt
32         $P reboot -ndf
33 kexec:V: halt
34         $P reboot -ndfk
35
36 # Initial setup/shutdown for mkinit
37 boot:QVEPservice -u: /
38         echo Starting init
39         $P mount -o remount,rw /
40         # mount proc here to make bootchart happier
41         $P mount -t proc proc /proc
42         rm -f /lib/mkinit/state/*
43         service -U $target
44
45 # Kill all process, then remount and sync
46 halt:QVE: utmp-stop hwclock-stop alsa-stop
47         echo Stopping init
48         rm -f /lib/mkinit/state/*
49         
50         echo TERMinating all processes
51         $P pkill -15 -vg0
52         for (i in 1 2 3 4 5)
53                 $P pgrep -vg0 >/dev/null && $P sleep 1
54         
55         echo KILLing all processes
56         $P pkill  -9 -vg0
57         for (i in 1 2 3)
58                 $P pgrep -vg0 >/dev/null && $P sleep 1
59         
60         $P mount -o remount,ro /
61         $P sync
62
63 # Bare
64 # ----
65 # Proc, mtab, udev, fstab
66 mounts-start:QVPservice -u: boot
67         echo Starting mounts
68         $P cat /proc/mounts > /etc/mtab
69         $P udevd --daemon
70         $P mount -a 
71         service -U $target
72
73 # Load kernel modules
74 modules-start:QVEPservice -u: boot
75         echo Starting modules
76         $P modprobe uvesafb
77         service -U $target
78
79 # Trigger udev uevents
80 uevents-start:QVEPservice -u:  mounts-start
81         echo Starting uevents
82         $P udevadm trigger
83         $P udevadm settle '--timeout=10'
84         service -U $target
85
86 # Clean out /tmp and /var/run directories
87 fsclean-start:QVPservice -u: boot
88         echo Starting fsclean
89         $P rm -rf /tmp/* 
90         $P rm -rf /var/run/*
91         service -U $target
92
93 # Spawn gettys for tty[456]
94 getty-start:QVPservice -u: hostname-start utmp-start
95         echo Starting getty
96         $P respawn /sbin/agetty 38400 tty4 linux &
97         $P respawn /sbin/agetty 38400 tty5 linux &
98         $P respawn /sbin/agetty 38400 tty6 linux &
99         service -U $target
100 getty-stop_cmd=pkill agetty
101
102 # Spawn qingys for tty[23]
103 qingy-start:QVPservice -u: hostname-start utmp-start modules-start uevents-start
104         echo Starting qingy
105         $P respawn /sbin/qingy tty2 &
106         $P respawn /sbin/qingy tty3 &
107         service -U $target
108 getty-stop_cmd=pkill qingy
109
110 # Login records
111 utmp-start:QVPservice -u: fsclean-start
112         echo Starting utmp
113         for (i in /var/run/utmp /var/log/wtmp) {
114                 echo -n > $i
115                 chgrp utmp $i
116                 chmod 0664 $i
117         }
118         service -U $target
119 utmp-stop_cmd=halt -w
120
121 # CPU freq
122 cpufreq-start:QVPservice -u: uevents-start
123         echo Starting cpufreq
124         cpufreq-set -g ondemand
125         service -U $target
126
127 # Keymap (us-cc = us with ctrl-capslock switched)
128 keymap-start_cmd=loadkeys -u us-cc
129
130 # Localhost
131 localhost-start_cmd=ifconfig lo 127.0.0.1
132 localhost-stop_cmd=ifconfig lo down
133
134 # Set hostname
135 hostname-start_cmd=hostname b
136
137 # Kernel parameters
138 sysctl-start_cmd=sysctl -p
139
140
141 # Console
142 # -------
143 at-start_cmd=atd
144 at-stop_cmd=pkill atd
145
146 cron-start_cmd=cron
147 cron-stop_cmd=pkill cron
148
149 hwclock-start_cmd=hwclock --hctosys --utc
150 hwclock-stop_cmd=hwclock --systohc --utc
151
152 swap-start_cmd=swapon -a
153 swap-stop_cmd=swapoff -a
154
155 syslog-start:QVPservice -u: mounts-start
156         echo Starting syslog;
157         $P syslog-ng
158         service -U $target
159 syslog-stop_cmd=pkill syslog
160
161 hddtemp-start:QVPservice -u: localhost-start
162         echo Starting hddtemp
163         $P hddtemp -d -l 127.0.0.1 /dev/sda
164         service -U $target
165 hddtemp-stop_cmd=pkill hddtemp
166
167
168 # Desktop
169 # -------
170 alsa-start_cmd=alsactl restore
171 alsa-stop_cmd=alsactl store
172
173 sshd-start_cmd=/usr/sbin/sshd
174 sshd-stop_cmd=pkill sshd
175
176 dbus-start:QVPservice -u: localhost-start
177         echo Starting dbus
178         $P /usr/bin/dbus-daemon -- --system
179         service -U $target
180 dbus-stop_cmd=pkill dbus-daemon
181
182 spam-start:QVPservice -u: localhost-start
183         echo Starting spam
184         $P spamd -d
185         service -U $target
186 spam-stop_cmd=pkill spamd
187
188 polipo-start:QVPservice -u: localhost-start
189         echo Starting poliop
190         $P polipo
191         service -U $target
192 polipo-stop_cmd=pkill polipo
193
194
195 # Library 
196 # -------
197 %-start:QVPservice -u: boot
198         if (~ $#($stem^-start_cmd) 0)
199                 exit 0
200         echo Starting $stem
201         $P $($stem^-start_cmd)
202         service -U $target
203
204 %-stop:QVPservice -d: /
205         if (~ $#($stem^-stop_cmd) 0)
206                 exit 0
207         echo Stopping $stem
208         $P $($stem^-stop_cmd)
209         service -D $target
210
211 %-zap:QVPservice -d: /
212         service -D $target
213
214 %-status:QV:
215         service -q $target