]> Pileus Git - mkinit/blob - init.mk
Adding initial import of mkinit
[mkinit] / init.mk
1 # Copyright (C) 2009 Andy Spencer
2 # See COPYING for terms
3
4 # Config
5 PATH=/lib/mkinit/bin:/bin:/sbin:/usr/bin:/usr/sbin
6 MKSHELL=/usr/lib/plan9/bin/rc
7 NPROC=8
8
9 # Example
10 #start-test:VQPservice -u: start-foo
11 #       echo starting test
12 #       service -U $target
13 #
14 #stop-test:VQPservice -d: /
15 #       echo stopping test
16 #       service -D $target
17
18 # Runlevels
19 default:V: bare
20
21 desktop:V: console `{echo start-^(alsa polipo spam sshd)}
22 console:V: bare    `{echo start-^(at cron syslog hddtemp i8k hwclock swap)}
23 bare:V:            `{echo start-^(mounts uevents hostname fsclean getty qingy localhost keymap)}
24
25 # Initial setup/shutdown for mkinit
26 boot:QVEPservice -u: /
27         echo Starting init
28         $P mount -o remount,rw /
29         rm -f /lib/mkinit/state/*
30         service -U $target
31
32 # Kill all process, then remount and sync
33 halt:QVE: stop-hwclock stop-alsa
34         echo Stopping init
35         rm -f /lib/mkinit/state/*
36         
37         echo TERMinating all processes
38         $P pkill -15 -vg0
39         for (i in 1 2 3 4 5)
40                 $P pgrep -vg0 >/dev/null && $P sleep 1
41         
42         echo KILLing all processes
43         $P pkill  -9 -vg0
44         for (i in 1 2 3)
45                 $P pgrep -vg0 >/dev/null && $P sleep 1
46         
47         $P mount -o remount,ro /
48         $P sync
49
50 # Proc, mtab, udev, fstab
51 start-mounts:QVPservice -u: boot
52         echo Starting mounts
53         $P mount -t proc proc /proc
54         $P cat /proc/mounts > /etc/mtab
55         $P udevd --daemon
56         $P mount -a 
57         service -U $target
58
59 # Load kernel modules
60 start-modules:QVEPservice -u: boot
61         echo Starting modules
62         $P modprobe uvesafb
63         service -U $target
64
65 # Trigger udev uevents
66 start-uevents:QVEPservice -u:  start-mounts
67         echo Starting uevents
68         $P udevadm trigger
69         $P udevadm settle '--timeout=10'
70         service -U $target
71
72 # Clean out /tmp and /var/run directories
73 start-fsclean:QVPservice -u: boot
74         echo Starting fsclean
75         $P rm -rf /tmp/* 
76         $P rm -rf /var/run/*
77         service -U $target
78
79 # Spawn gettys for tty[456]
80 start-getty:QVPservice -u: start-hostname
81         echo Starting getty
82         $P respawn /sbin/agetty 38400 tty4 linux &
83         $P respawn /sbin/agetty 38400 tty5 linux &
84         $P respawn /sbin/agetty 38400 tty6 linux &
85         service -U $target
86
87 # Spawn qingys for tty[23]
88 start-qingy:QVPservice -u: start-hostname start-modules start-uevents
89         echo Starting qingy
90         $P respawn /sbin/qingy tty2 &
91         $P respawn /sbin/qingy tty3 &
92         service -U $target
93
94 # Keymap (us-cc = us with ctrl-capslock switched)
95 keymap_start_cmd=loadkeys -u us-cc
96
97 # Localhost
98 localhost_start_cmd=ifconfig lo 127.0.0.1
99 localhost_stop_cmd=ifconfig lo down
100
101 # Set hostname
102 hostname_start_cmd=hostname b
103
104 # Kernel parameters
105 sysctl_start_cmd=sysctl -p
106
107
108 # Console
109 # -------
110 at_start_cmd=atd
111 cron_start_cmd=cron
112 hwclock_start_cmd=hwclock --hctosys --utc
113 hwclock_stop_cmd=hwclock --systohc --utc
114 swap_start_cmd=swapon -a
115 swap_stop_cmd=swapoff -a
116 start-syslog:QVPservice -u: start-mounts
117         echo Starting syslog;
118         $P syslog-ng
119         service -U $target
120 start-hddtemp:QVPservice -u: start-localhost
121         echo Starting hddtemp
122         $P hddtemp -d -l 127.0.0.1 /dev/sda
123         service -U $target
124 hddtemp_stop_cmd=pkill hddtemp
125
126
127 # Desktop
128 # -------
129 alsa_start_cmd=alsactl restore
130 alsa_stop_cmd=alsactl store
131 sshd_start_cmd=/usr/sbin/sshd
132 start-spam:QVPservice -u: start-localhost
133         echo Starting spam
134         $P spamd -d
135         service -U $target
136 start-polipo:QVPservice -u: start-localhost
137         echo Starting poliop
138         $P polipo
139         service -U $target
140 polipo_stop_cmd=pkill polipo
141
142
143 # Library 
144 # -------
145 start-%:QVPservice -u: boot
146         if (~ $#($stem^_start_cmd) 0)
147                 exit 0
148         echo Starting $stem
149         $P $($stem^_start_cmd)
150         service -U $target
151
152 stop-%:QVPservice -d: /
153         if (~ $#($stem^_stop_cmd) 0)
154                 exit 0
155         echo Stopping $stem
156         $P $($stem^_stop_cmd)
157         service -D $target
158
159 zap-%:QVPservice -d: /
160         service -D $target
161
162 status-%:QV:
163         service -q $target