]> Pileus Git - mkinit/blobdiff - services.mk
Update services.
[mkinit] / services.mk
index 4b767631676d351f0d1752721229b67e0b4e16ef..e7f29ba503c48a027ce1ba2bd3ab7275c01ca8c0 100644 (file)
@@ -1,18 +1,18 @@
 MKSHELL=/opt/plan9/bin/rc
 
 # Example
-#test-start:VQPservice -u: foo-start
-#      echo starting test
-#      service -U $target
-#
-#test-stop:VQPservice -d: /
-#      echo stopping test
-#      service -D $target
+test-start:VQPservice -u: foo-start
+       echo starting test
+       service -U $target
+
+test-stop:VQPservice -d: /
+       echo stopping test
+       service -D $target
 
 # Core commands
 # -------------
 # Reboot commands
-poweroff:V: halt 
+poweroff:V: halt
        $P poweroff -ndf
 reboot:V: halt
        $P reboot -ndf
@@ -23,21 +23,21 @@ kexec:V: halt
 boot:VEPservice -u: /
        echo Starting init
        $P mount -o remount,rw /
+       $P mount -t tmpfs tmpfs /lib/mkinit/state
        # mount proc here to make bootchart happier
        $P mount -t proc proc /proc
-       service -F
        service -U $target
 
 # Kill all process, then remount and sync
 halt:QVE: utmp-stop hwclock-stop alsa-stop
        echo TERMinating all processes
-       $P pkill -15 -vg0 >/dev/null >[2=1]
+       $P pkill -15 --inverse -g0 >/dev/null >[2=1]
        for (i in 1 2 3 4 5)
-               $P pgrep -vg0 >/dev/null >[2=1] && $P sleep 1
+               { $P pgrep -vg0 && $P sleep 1 }
        echo KILLing all processes
-       $P pkill  -9 -vg0 >/dev/null >[2=1]
+       $P pkill  -9 --inverse -g0 >/dev/null >[2=1]
        for (i in 1 2 3)
-               $P pgrep -vg0 >/dev/null >[2=1] && $P sleep 1
+               { $P pgrep -vg0 && $P sleep 1 }
        service -F
        echo Remounting read-only
        $P mount -o remount,ro /
@@ -52,32 +52,43 @@ initctl-start:VPservice -u: boot
                $P mkfifo $fifo
        { exec $P initctld $fifo |
          while(line=`{line})
-               $P mkinit $line >/dev/console >[2=1] 
+               $P mkinit $line >/dev/console >[2=1]
        } &
        service -U $target
 initctl-stop_cmd=fuser -k /dev/initctl
 
 # Proc, mtab, fstab
-mounts-start:VPservice -u: boot
-       $P cp /proc/mounts /etc/mtab
-       $P mdadm -A /dev/md4 /dev/sd[abc]4
+mounts-start:VPservice -u: $devnodes-start
+       $P mdadm -A /dev/md2 /dev/sd[bcd]2 || true
+       $P ln -snf /proc/self/fd /dev/fd
        $P mount -a
        service -U $target
 
-# Mount devtmpfs and shm/pts subfolders
+# Set console font
+font-start_cmd=setfont
+
+# Setup device nodes
 devtmpfs-start:VEPservice -u: boot
        $P mount /dev
        $P mkdir /dev/shm
        $P mkdir /dev/pts
        service -U $target
 
-# Start mdev as initial/daemon
-mdev-start:VEPservice -u: mounts-start udev-stop
+devawk-start:VEPservice -u: devtmpfs-start
+       $P echo /root/bin/dev.awk > /proc/sys/kernel/hotplug
+       $P /root/bin/dev.awk
+       service -U $target
+
+devsh-start:VEPservice -u: devtmpfs-start
+       $P echo /root/bin/dev.sh > /proc/sys/kernel/hotplug
+       $P /root/bin/dev.sh -a
+       service -U $target
+
+mdev-start:VEPservice -u: devtmpfs-start
        $P echo /sbin/mdev > /proc/sys/kernel/hotplug
        $P mdev -s
        service -U $target
 
-# Start udev and trigger events
 udev-start:VEPservice -u:  mounts-start
        $P udevd --daemon
        $P udevadm trigger
@@ -86,37 +97,90 @@ udev-start:VEPservice -u:  mounts-start
 udev-stop_cmd=pkill udevd
 
 # Load kernel modules
-modules-start:VEPservice -u: boot
-       $P modprobe uvesafb
-       $P modprobe evdev
+modules-start:VEPservice -u: mounts-start
+       for (i in `{find /sys/devices -name wakeup -not -path '*PWRBN*'})
+               { $P echo disabled > $i }
+       service -U $target
+
+# Intel graphics card
+intel-start:VEPservice -u: mounts-start
+       $P modprobe i915    'modeset=1'
+       $P modprobe nouveau 'modeset=1'
+       $P echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
+       service -U $target
+
+# Nvidia graphics card
+nvidia-start:VEPservice -u: mounts-start
+       $P modprobe i915    'modeset=1'
+       $P modprobe nouveau 'modeset=1'
+       $P echo DDIS > /sys/kernel/debug/vgaswitcheroo/switch
+       $P echo 0    > /sys/class/vtconsole/vtcon1/bind
+       $P modprobe -r nouveau
+       $P modprobe    nvidia
+       $P setpci -v -H1 -s '00:01.00' 'BRIDGE_CONTROL=0'
+       service -U $target
+
+# Nouveau graphics card
+nouveau-start:VEPservice -u: mounts-start
+       $P modprobe    i915    'modeset=1'
+       $P modprobe    nouveau 'modeset=1'
+       $P echo DDIS > /sys/kernel/debug/vgaswitcheroo/switch
+       $P echo 0    > /sys/class/vtconsole/vtcon1/bind
+       $P modprobe -r nouveau
+       $P modprobe    nouveau 'modeset=1'
        service -U $target
 
 # Clean out /tmp and /var/run directories
 fsclean-start:VPservice -u: boot
-       dirs=(/var/run /tmp)
+       dirs=(/run /var/run /tmp)
        $P mkdir -p /.old
        $P mv $dirs /.old || true
        $P mkdir -p $dirs
        $P chmod 1777 /tmp
-       $P install -m 777 -d /var/run/screen # Fuck you Screen
+       $P install -m 1777 -d /var/run/screen # Fuck you Screen
        $P exec rm -rf /.old &
        service -U $target
 
-# Spawn gettys for tty[3456]
-getty-start:VEPservice -u: hostname-start utmp-start
-       $P respawn /sbin/agetty 38400 tty3 linux
-       $P respawn /sbin/agetty 38400 tty4 linux
-       $P respawn /sbin/agetty 38400 tty5 linux
-       $P respawn /sbin/agetty 38400 tty6 linux
+# Hardware keys
+hwkeys-start:VEPservice -u: mounts-start
+       $P /root/bin/touchpad.sh
+       $P exec hwkeys &
        service -U $target
-getty-stop_cmd=fuser -k /dev/tty3 /dev/tty4 /dev/tty5 /dev/tty6
+hwkeys-stop_cmd=pkill hwkeys
 
-# Spawn qingys for tty[2]
-qingy-start:VEPservice -u: hostname-start utmp-start modules-start
-       $P respawn /sbin/qingy tty2
-       $P chvt 2
+# Spawn gettyd for tty[23456]
+gettyd-start:VEPservice -u: hostname-start utmp-start
+       $P exec gettyd tty2 tty3 tty4 tty5 tty6 &
+       service -U $target
+gettyd-stop_cmd=fuser -k /dev/tty2 /dev/tty3 /dev/tty4 /dev/tty5 /dev/tty6
+
+# Spawn agettys for tty[23456]
+agetty-start:VEPservice -u: hostname-start utmp-start
+       $P respawn setsid agetty 38400 tty2 linux
+       $P respawn setsid agetty 38400 tty3 linux
+       $P respawn setsid agetty 38400 tty4 linux
+       $P respawn setsid agetty 38400 tty5 linux
+       $P respawn setsid agetty 38400 tty6 linux
        service -U $target
-qingy-stop_cmd=fuser -k /dev/tty2
+agetty-stop_cmd=fuser -k /dev/tty2 /dev/tty3 /dev/tty4 /dev/tty5 /dev/tty6
+
+# Spawn qingys for tty[7]
+qingy-start:VEPservice -u: hostname-start utmp-start modules-start $devnodes-start
+       $P /root/bin/touchpad.sh
+       $P exec setsid /sbin/qingy tty7 &
+       $P chvt 7
+       service -U $target
+qingy-stop_cmd=fuser -k /dev/tty7
+
+# Spawn xorg on tty[7]
+xinit-start:VEPservice -u: mounts-start
+       $P /root/bin/gpu $graphics | tee /root/gpu.log
+       $P /root/bin/touchpad.sh
+       $p chown andy:tty /dev/tty7
+       $p rm -f /usr/libexec/xf86-video-intel-backlight-helper
+       $p exec su -l andy -c /home/andy/bin/xsession &
+       service -U $target
+xinit-stop_cmd=fuser -k /dev/tty7
 
 # Login records
 utmp-start:VPservice -u: fsclean-start
@@ -130,7 +194,7 @@ utmp-stop_cmd=halt -w
 
 # CPU freq
 cpufreq-start:VPservice -u: mounts-start
-       $P cpufreq-set -g ondemand
+       $P cpupower frequency-set -g ondemand
        service -U $target
 
 # Localhost
@@ -140,26 +204,49 @@ localhost-stop_cmd=ifconfig lo down
 # Set hostname
 hostname-start_cmd=hostname
 
+# Power management
+power-start:VPservice -u: mounts-start
+       echo 1         | $P tee /sys/module/snd_hda_intel/parameters/power_save
+       echo min_power | $P tee /sys/class/scsi_host/*/link_power_management_policy
+       echo auto      | $P tee /sys/bus/usb/devices/*/power/control
+       echo auto      | $P tee /sys/bus/pci/devices/*/power/control
+       echo 1500      | $P tee /proc/sys/vm/dirty_writeback_centisecs
+       service -U $target
+
 # Kernel parameters
-sysctl-start_cmd=sysctl -p
+sysctl-start:VPservice -u: mounts-start
+       $P sysctl -p
+       $P chmod a+w /sys/class/leds/smc::kbd_backlight/brightness
+       $P chmod a+w /sys/class/backlight/gmux_backlight/brightness
+       $P chmod a+w /sys/devices/platform/applesmc.768/fan[12]_manual
+       $P chmod a+w /sys/devices/platform/applesmc.768/fan[12]_output
+       service -U $target
 
 
 # System
 # -------
-at-start_cmd=atd
+at-start:VPservice -u: fsclean-start
+       $P atd
+       service -U $target
 at-stop_cmd=pkill atd
 
-cron-start_cmd=cron
+cron-start:VPservice -u: localhost-start fsclean-start
+       $P crond
+       service -U $target
 cron-stop_cmd=pkill cron
 
-hddtemp-start:VPservice -u: localhost-start
-       $P hddtemp -d -l 127.0.0.1 /dev/sda
-       service -U $target
+hddtemp-start_cmd=hddtemp -d
 hddtemp-stop_cmd=pkill hddtemp
 
 hwclock-start_cmd=hwclock --hctosys --utc
 hwclock-stop_cmd=hwclock --systohc --utc
 
+mdadm-start_cmd=mdadm --monitor --scan --daemonize
+mdadm-stop_cmd=pkill mdadm
+
+smartd-start_cmd=smartd
+smartd-stop_cmd=pkill smartd
+
 sshd-start_cmd=/usr/sbin/sshd
 sshd-stop_cmd=pkill sshd
 
@@ -174,14 +261,27 @@ syslog-stop_cmd=pkill syslog
 
 # Desktop
 # -------
-alsa-start_cmd=alsactl restore
+alsa-start:VPservice -u: boot
+       $P modprobe snd-hda-intel
+       $P modprobe snd-usb-audio
+       $P sleep 0.1
+       $P alsactl restore
+       service -U $target
 alsa-stop_cmd=alsactl store
 
+bluez-start:VPservice -u: dbus-start
+       $P modprobe btusb
+       $P modprobe hidp
+       $P hciconfig hci0 up
+       $P exec /usr/libexec/bluetooth/bluetoothd &
+       service -U $target
+bluez-stop_cmd=pkill bluetoothd
+
 cups-start_cmd=cupsd
 cups-stop_cmd=pkill cupsd
 
 dbus-start:VPservice -u: fsclean-start localhost-start
-       $P mkdir -p /var/run/dbus
+       $P install -m 1777 -d /var/run/dbus
        $P /usr/bin/dbus-daemon --system
        service -U $target
 dbus-stop_cmd=pkill dbus-daemon
@@ -189,6 +289,9 @@ dbus-stop_cmd=pkill dbus-daemon
 gpm-start_cmd=gpm -m /dev/input/mice -t ps2
 gpm-stop_cmd=pkill gpm
 
+gpsd-start_cmd=gpsd tcp://localhost:2222
+gpsd-stop_cmd=pkill gpsd
+
 keymap-start_cmd=loadkeys -u us-cc
 
 polipo-start:VPservice -u: localhost-start
@@ -199,13 +302,22 @@ polipo-stop_cmd=pkill polipo
 
 # Server
 # ------
-apache2-start_cmd=apache2
+apache2-start:VPservice -u: fsclean-start
+       $P install -o apache -g apache -d /var/run/session
+       $P install -o apache -g apache -d /run/apache_ssl_mutex
+       $P apache2 $(apache2-opts)
+       service -U $target
 apache2-stop_cmd=pkill apache2
 
-#bitlbee-start_cmd=sudo -u bitlbee bitlbeed /usr/sbin/bitlbee
 bitlbee-start_cmd=bitlbee -D -u bitlbee
 bitlbee-stop_cmd=pkill bitlbee
 
+cups-start_cmd=cupsd
+cups-stop_cmd=pkill cupsd
+
+denyhosts-start_cmd=denyhosts.py --daemon
+denyhosts-stop_cmd=pkill denyhosts.py
+
 courier-start:VPservice -u: fsclean-start
        $P install -o mail -g mail -d /var/run/courier
        $P authdaemond       start
@@ -215,33 +327,75 @@ courier-start:VPservice -u: fsclean-start
        service -U $target
 courier-stop_cmd=pkill '(courier|authdaemon)'
 
-dhcp-start_cmd=dhcpcd eth0
-dhcp-stop_cmd=dhcpcd eth0 -k
+dioc-start:VPservice -u: munged-start
+       $P mount -n /mnt/c
+       $P mount -n /mnt/c/mnt/x
+       service -U $target
+dioc-stop:EVPservice -d:
+       $P umount /mnt/c/mnt/x
+       $P umount /mnt/c
+       service -D $target
 
 diod-start:VPservice -u: munged-start
        $P diod --export-all
        service -U $target
 diod-stop_cmd=pkill diod
 
+docker-start_cmd=docker
+docker-stop_cmd=pkill docker
+
 dovecot-start_cmd=dovecot
 dovecot-stop_cmd=pkill dovecot
 
+eth0-start_cmd=dhcpcd eth0 -4 -A
+eth0-stop_cmd=dhcpcd eth0 -k
+
 exim-start_cmd=exim -bd -q5m
 exim-stop_cmd=pkill exim
 
-gitd-start:VPservice -u: boot
-       $P exec /usr/libexec/git-core/git-daemon \
-               '--syslog' \
-               '--export-all' \
-               '--user-path=git' \
-               '--base-path=/home/server/git' \
-               '--listen=0.0.0.0' \
-               '--user=nobody' \
-               '--group=nobody' &
+fail2ban-start:VPservice -u: boot
+       $P mkdir -p /run/fail2ban
+       $P fail2ban-client start
        service -U $target
+fail2ban-stop_cmd=fail2ban-client stop
+
+gitd-start_cmd=git daemon \
+       '--detach' \
+       '--syslog' \
+       '--export-all' \
+       '--user-path=git' \
+       '--interpolated-path=/etc/git/%H%D' \
+       '--listen=0.0.0.0' \
+       '--user=nobody' \
+       '--group=nobody'
 gitd-stop_cmd=pkill git-daemon
 
-munged-start_cmd=sudo -u munge -g munge munged
+iptables-start:VPservice -u: boot
+       $P iptables-restore < /var/lib/iptables/rules-save
+       service -U $target
+iptables-stop:EVPservice -d:
+       $P iptables-save > /var/lib/iptables/rules-save
+       service -D $target
+
+jabberd-start_cmd=sudo -u jabber -g jabber jabberd-andy -b
+jabberd-stop_cmd=pkill --uid jabber
+
+mailman-start_cmd=sudo -u mailman -g mailman \
+       /usr/lib64/mailman/bin/mailmanctl -s start
+mailman-stop_cmd=sudo -u mailman -g mailman \
+       /usr/lib64/mailman/bin/mailmanctl stop
+
+minidlna-start:VPservice -u: mounts-start
+       $P install -o minidlna -g minidlna -d /var/run/minidlna
+       $P install -o minidlna -g minidlna -d /var/cache/minidlna
+       $P sudo    -u minidlna -g minidlna minidlnad
+       service -U $target
+minidlna-stop_cmd=pkill minidlnad
+
+munged-start:VPservice -u: localhost-start mounts-start
+       $P install -o munge -g munge -d /var/run/munge
+       $P sudo -u munge -g munge munged
+       service -U $target
 munged-stop_cmd=pkill munged
 
 mysql-start:VPservice -u: fsclean-start
@@ -256,15 +410,58 @@ ntpd-stop_cmd=pkill ntpd
 privoxy-start_cmd=privoxy --user privoxy.privoxy /etc/privoxy/config
 privoxy-stop_cmd=pkill privoxy
 
+rngd-start_cmd=rngd -b -s64 -W2048
+rngd-stop_cmd=pkill rngd
+
+sasl-start_cmd=saslauthd -n0 -ashadow
+sasl-stop_cmd=pkill saslauthd
+
 spamd-start_cmd=spamd -u spamd -d
 spamd-stop_cmd=pkill spamd
 
+tftpd-start_cmd=in.tftpd -s -l /img/boot
+tftpd-stop_cmd=
+
 tor-start:VPservice -u: boot
        $P exec tor &
        service -U $target
 tor-stop_cmd=pkill tor
 
-# Library 
+unifi-start:VPservice -u: wpa-start
+       cd /usr/lib/unifi
+       exec java -jar lib/ace.jar start &
+unifi-stop:EVPservice -d:
+       cd /usr/lib/unifi
+       java -jar lib/ace.jar stop
+       service -D $target
+
+ventrilo-opts=-f/opt/ventrilo-server/ventrilo_srv -d
+ventrilo-start_cmd=sudo -u ventrilo -g ventrilo /opt/ventrilo-server/ventrilo_srv
+ventrilo-stop_cmd=pkill -u ventrilo
+
+vpn-start:VPservice -u: localhost-start
+       $P ipsec start
+       $P exec /usr/sbin/rp-l2tpd &
+       $P exec /usr/sbin/pptpd &
+       service -U $target
+vpn-stop:VQPservice -d: /
+       $P pkill rp-l2tpd
+       $P pkill pptpd
+       $P ipsec stop
+       service -D $target
+
+wlan0-start:VPservice -u: wpa-start
+       $P dhcpcd -4 wlan0
+       service -U $target
+wlan0-stop_cmd=dhcpcd wlan0 -k
+
+wpa-start:VPservice -u: $devnodes-start
+       $P modprobe brcmfmac && sleep 1
+       $P exec wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf &
+       service -U $target
+wpa-stop_cmd=pkill wpa
+
+# Library
 # -------
 %-start:QVPservice -u: boot
        if (~ $#($stem^-start_cmd) 0)
@@ -274,8 +471,9 @@ tor-stop_cmd=pkill tor
 
 %-stop:QVPservice -d: /
        if (~ $#($stem^-stop_cmd) 0)
-               echo No such service $stem && exit 0
-       $P $($stem^-stop_cmd)
+               echo No such service $stem
+       if not
+               $P $($stem^-stop_cmd)
        service -D $target
 
 %-zap:QVPservice -d: /