diff --git a/init.d/agetty b/init.d/agetty new file mode 100755 index 0000000..e43449d --- /dev/null +++ b/init.d/agetty @@ -0,0 +1,4 @@ +#!/usr/bin/env watchman + +service_command='/bin/agetty' +service_args="38400 ${service_name##*-} linux" diff --git a/init.d/agetty-tty2 b/init.d/agetty-tty2 new file mode 120000 index 0000000..a1abdb2 --- /dev/null +++ b/init.d/agetty-tty2 @@ -0,0 +1 @@ +agetty \ No newline at end of file diff --git a/init.d/agetty-tty3 b/init.d/agetty-tty3 new file mode 120000 index 0000000..a1abdb2 --- /dev/null +++ b/init.d/agetty-tty3 @@ -0,0 +1 @@ +agetty \ No newline at end of file diff --git a/init.d/agetty-tty4 b/init.d/agetty-tty4 new file mode 120000 index 0000000..a1abdb2 --- /dev/null +++ b/init.d/agetty-tty4 @@ -0,0 +1 @@ +agetty \ No newline at end of file diff --git a/init.d/agetty-tty5 b/init.d/agetty-tty5 new file mode 120000 index 0000000..a1abdb2 --- /dev/null +++ b/init.d/agetty-tty5 @@ -0,0 +1 @@ +agetty \ No newline at end of file diff --git a/init.d/agetty-tty6 b/init.d/agetty-tty6 new file mode 120000 index 0000000..a1abdb2 --- /dev/null +++ b/init.d/agetty-tty6 @@ -0,0 +1 @@ +agetty \ No newline at end of file diff --git a/init.d/crond b/init.d/crond new file mode 100755 index 0000000..cf7c722 --- /dev/null +++ b/init.d/crond @@ -0,0 +1,4 @@ +#!/usr/bin/env watchman + +service_command='/bin/crond' +service_args='-n' diff --git a/init.d/dbus b/init.d/dbus new file mode 100755 index 0000000..60c5756 --- /dev/null +++ b/init.d/dbus @@ -0,0 +1,20 @@ +#!/usr/bin/env watchman + +service_command='/usr/bin/dbus-daemon' +service_args='--system' +service_pidfile='/run/dbus/pid' + +start_pre() { + /usr/bin/dbus-uuidgen --ensure=/etc/machine-id + [[ -e /run/dbus ]] || { mkdir /run/dbus; } +} + +start() { + start_pre + watchman.start +} + +stop() { + [[ -e "$service_pidfile" ]] && { rm "$service_pidfile"; } + watchman.stop +} diff --git a/init.d/devfs b/init.d/devfs new file mode 100755 index 0000000..80ed7c0 --- /dev/null +++ b/init.d/devfs @@ -0,0 +1,32 @@ +#!/usr/bin/env watchman + +service_type='oneshot' + +cfg_mounts+=( 'dev:devtmpfs:defaults:/dev' ) +cfg_mounts+=( '/dev/pts:devpts:noexec,nosuid,gid=5,mode=0620:/dev/pts' ) +cfg_mounts+=( '/dev/mqueue:mqueue:noexec,nosuid,nodev:/dev/mqueue' ) +cfg_mounts+=( '/dev/pts:devpts:noexec,nosuid,gid=5,mode=0620:/dev/pts' ) +cfg_mounts+=( 'tmpfs:tmpfs:defaults,mode=0777:/dev/shm' ) + +start() { + for m in ${cfg_mounts[@]}; do + fs_dev=`echo "$m" | cut -d':' -f1` + fs_type=`echo "$m" | cut -d':' -f2` + fs_opts=`echo "$m" | cut -d':' -f3` + fs_mountpoint=`echo "$m" | cut -d':' -f4` + + mountpoint -q "$fs_mountpoint" || { + [[ -d "$fs_mountpoint" ]] || { mkdir "$fs_mountpoint"; } + mount "$fs_dev" -n -t "$fs_type" -o "$fs_opts" "$fs_mountpoint" + } + done +} + +stop() { + for m in "${cfg_mounts[@]}"; do + fs_mountpoint=`echo "$m" | cut -d ':' -f 4` + mountpoint -q "$fs_mountpoint" && { + umount "$fs_mountpoint" + } + done +} diff --git a/init.d/dhcpcd b/init.d/dhcpcd new file mode 100755 index 0000000..1292043 --- /dev/null +++ b/init.d/dhcpcd @@ -0,0 +1,7 @@ +#!/usr/bin/env watchman + +depends network + +service_command='/usr/sbin/dhcpcd' +service_args='-q' +service_pidfile='/var/run/dhcpcd.pid' diff --git a/init.d/fsck b/init.d/fsck new file mode 100755 index 0000000..749a135 --- /dev/null +++ b/init.d/fsck @@ -0,0 +1,16 @@ +#!/usr/bin/env watchman + +service_type='oneshot' + +unset stop restart status + +start() { + watchman.msg "Remounting / as read-only..." + mount / -o remount,ro + + watchman.msg "Checking filesystems..." + /bin/fsck -A -p + + watchman.msg "Remounting / as read-write..." + mount / -o remount,rw +} diff --git a/init.d/hostname b/init.d/hostname new file mode 100755 index 0000000..dde1ce0 --- /dev/null +++ b/init.d/hostname @@ -0,0 +1,16 @@ +#!/usr/bin/env watchman + +service_type='oneshot' +service_command='hostname' +service_args="$cfg_hostname" + +start() { + [[ -e "/etc/hostname" ]] && { + cfg_hostname=`cat /etc/hostname` + } || { + watchman.err "/etc/hostname: no such file" + return 1 + } + + watchman.start +} diff --git a/init.d/mdev b/init.d/mdev new file mode 100755 index 0000000..83adcc4 --- /dev/null +++ b/init.d/mdev @@ -0,0 +1,9 @@ +#!/usr/bin/env watchman + +service_command='/usr/local/sbin/mdev' +service_rgs='-s' + +hotplug() { + echo "Enabling hotplug..." + echo /sbin/mdev > /proc/sys/kernel/hotplug +} diff --git a/init.d/miscfs b/init.d/miscfs new file mode 100755 index 0000000..85b7811 --- /dev/null +++ b/init.d/miscfs @@ -0,0 +1,34 @@ +#!/usr/bin/env watchman + +service_type='oneshot' + +cfg_mounts+=( 'proc:proc:defaults:/proc' ) +cfg_mounts+=( 'run:tmpfs:defaults:/run' ) +cfg_mounts+=( 'sys:sysfs:defaults:/sys' ) + +start() { + for m in ${cfg_mounts[@]}; do + fs_dev=`echo "$m" | cut -d':' -f1` + fs_type=`echo "$m" | cut -d':' -f2` + fs_opts=`echo "$m" | cut -d':' -f3` + fs_mountpoint=`echo "$m" | cut -d':' -f4` + + mountpoint -q "$fs_mountpoint" || { + [[ -d "$fs_mountpoint" ]] || { mkdir "$fs_mountpoint"; } + mount "$fs_dev" -n -t "$fs_type" -o "$fs_opts" "$fs_mountpoint" || { + could not mount "$fs_dev on $fs_mountpoint :(" + } + } + done + + return 0 +} + +stop() { + for m in "${cfg_mounts[@]}"; do + fs_mountpoint=`echo "$m" | cut -d ':' -f 4` + mountpoint -q "$fs_mountpoint" && { + umount "$fs_mountpoint" + } + done +} diff --git a/init.d/mount b/init.d/mount new file mode 100755 index 0000000..720a016 --- /dev/null +++ b/init.d/mount @@ -0,0 +1,9 @@ +#!/usr/bin/env watchman + +depends miscfs + +service_type='oneshot' +service_command='/bin/mount' +service_args='-a' + +unset stop diff --git a/init.d/network b/init.d/network new file mode 100755 index 0000000..85245eb --- /dev/null +++ b/init.d/network @@ -0,0 +1,18 @@ +#!/usr/bin/env watchman + +service_type='oneshot' + +start() { + watchman.msg "Activating the loopback interface (lo)..." + ip link set lo up +} + +stop() { + watchman.status || { + watchman.err "$service_name is already disabled" + return 1 + } + watchman.msg "Deactivating the loopback interface (lo)..." + ip link set lo down + watchman.stop +} diff --git a/init.d/nrpe b/init.d/nrpe new file mode 100755 index 0000000..a30a8fa --- /dev/null +++ b/init.d/nrpe @@ -0,0 +1,7 @@ +#!/usr/bin/env watchman + +cfg_nrpe_config='/etc/nrpe/nrpe.cfg' + +service_command='/bin/nrpe' +service_args="-c $cfg_nrpe_config -d" +service_pidfile='/run/nrpe.pid' diff --git a/init.d/ntpd b/init.d/ntpd new file mode 100755 index 0000000..e3dc959 --- /dev/null +++ b/init.d/ntpd @@ -0,0 +1,7 @@ +#!/usr/bin/env watchman + +cfg_ntpd_config='/etc/ntp.conf' + +service_command='/bin/ntpd' +service_pidfile='/run/ntpd.pid' +service_args="-c $cfg_ntpd_config -p $service_pidfile" diff --git a/init.d/openvpn-mh b/init.d/openvpn-mh new file mode 100755 index 0000000..ea0c0a1 --- /dev/null +++ b/init.d/openvpn-mh @@ -0,0 +1,7 @@ +#!/usr/bin/env watchman + +cfg_ovpn_instance="${service_name##*-}" + +service_command="/usr/sbin/openvpn" +service_workdir="/etc/openvpn/$cfg_ovpn_instance" +service_args="client.cfg" diff --git a/init.d/rc.local b/init.d/rc.local new file mode 100755 index 0000000..cc2445c --- /dev/null +++ b/init.d/rc.local @@ -0,0 +1,11 @@ +#!/usr/bin/env watchman + +service_type='oneshot' +service_command="$BASH" +service_args='/etc/rc.local' + +unset stop + +start() { + [[ -f "/etc/rc.local" ]] && { watchman.start; } +} diff --git a/init.d/sshd b/init.d/sshd new file mode 100755 index 0000000..d98ef34 --- /dev/null +++ b/init.d/sshd @@ -0,0 +1,14 @@ +#!/usr/bin/env watchman + +watchman.depends network + +cfg_sshd_cfgdir='/etc/ssh' + +service_command='/bin/sshd' +service_args="-f $cfg_sshd_cfgdir/sshd_config" +service_pidfile='/run/sshd.pid' + +sshd_genkeys() { + [[ -e "/etc/ssh/ssh_host_key" ]] || { ssh-keygen -A; } + watchman.start +} diff --git a/init.d/syslog-ng b/init.d/syslog-ng new file mode 100755 index 0000000..ad983fb --- /dev/null +++ b/init.d/syslog-ng @@ -0,0 +1,4 @@ +#!/usr/bin/env watchman + +service_command='/bin/syslog-ng' +service_pidfile='/run/syslog-ng.pid' diff --git a/init.d/udev b/init.d/udev new file mode 100755 index 0000000..49769a5 --- /dev/null +++ b/init.d/udev @@ -0,0 +1,27 @@ +#!/usr/bin/env watchman + +service_command='/usr/lib/systemd/systemd-udevd' +service_args='--resolve-names=never' + +cfg_udev_settle_timeout="${cfg_udev_settle_timeout:-60}" + +watchman.depends devfs + +udev.populate_dev() { + watchman.msg "Populating /dev with udev..." + udevadm trigger --type=subsystems --action=add + udevadm trigger --type=devices --action=add + watchman.msg "Waiting for uevents..." + udevadm settle --timeout=${cfg_udev_settle_timeout} + udevadm control --property=do_not_run_plug_service= +} + +start() { + watchman.start + sleep 1 + udev.populate_dev +} + +reload() { + udevadm control --reload +} diff --git a/init.d/xinetd b/init.d/xinetd new file mode 100755 index 0000000..2364f02 --- /dev/null +++ b/init.d/xinetd @@ -0,0 +1,5 @@ +#!/usr/bin/env watchman + +service_command='/usr/bin/xinetd' +service_pidfile="/run/xinetd.pid" +service_args="-pidfile $service_pidfile"