watchman -> ssm

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2017-07-13 16:09:42 +03:00
parent 3953df0dba
commit 2205f72a2e
71 changed files with 198 additions and 212 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_respawn='true'
service_command='/usr/bin/acpid'
service_args=( -f )

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_respawn='true'
service_command='/usr/bin/agetty'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/alsactl'

View File

@ -1,5 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_respawn=true
service_command='/usr/bin/atd'
service_args=( -f )
service_command=( /usr/bin/atd -f )

18
init.d/binfmt-register Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/watchman
service_type=oneshot
service_command=( /usr/bin/true )
pre_start() {
echo '1' > /proc/sys/fs/binfmt_misc/status || return 1
if [[ -d /etc/binfmt.d ]]; then
for i in /etc/binfmt.d/*; do
cat "$i" > /proc/sys/fs/binfmt_misc/register || return 1
done
fi
}
pre_stop() {
echo '-1' > /proc/sys/fs/binfmt_misc/status || return 1
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# This script is intended for Daemon mode.
# Modify it for your setup.

3
init.d/cgmanager Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ssm
service_command='/usr/bin/cgmanager'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn=true
service_command='/usr/bin/chef-client'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/chronyd'

View File

@ -1,63 +1,28 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# Two warnings:
# 1) This script uses a script to run cjdroute and feed it
# the config. It can be found in the main cjdns repo:
# contrib/sh/run-cjdroute.sh
# Or here: http://ix.io/fYT
# the config. It can be found in the main cjdns repo:
# contrib/sh/run-cjdroute.sh
# Or here: http://ix.io/fYT
# 2) service_respawn is disabled by default because you need
# "noBackground":1 in cjdroute.conf for it to actually work.
# Barely.
unset reload
#service_respawn=true
service_respawn=true
service_command='/usr/bin/run-cjdroute'
cjdroute_admin_port='11234'
cjdroute.check_tun_module() {
[[ -e '/dev/net/tun' ]] || {
modprobe tun || {
watchman.err "Could not load module tun!"
printf 'Could not load module tun!\n'
return 1
}
}
}
start() {
if cjdroute.check_tun_module; then
watchman.start
fi
}
get_control_pid() {
lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2
}
status() {
# Check the actual cjdroute process and not the watchdog
cjdroute_control_pid=$( get_control_pid )
counter=0
until kill -0 "$cjdroute_control_pid"; do
cjdroute_control_pid=$( get_control_pid )
(( counter >= 5 )) && {
watchman.msg "cjdroute is down"
return 1
}
(( counter++ ))
sleep 1
done
watchman.msg "cjdroute is running ($cjdroute_control_pid)"
}
stop() {
[[ "$service_respawn" == 'true' ]] && { watchman.stop; } # stopping the watchdog
# Stopping the actual s-o-b daemon that won't die properly.
cjdroute_control_pid=$( get_control_pid )
watchman.pid_check "$cjdroute_control_pid" && {
kill "$cjdroute_control_pid"
watchman.pid_wait "$cjdroute_control_pid"
}
pre_start() {
cjdroute.check_tun_module
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# Author: Alad Wenter
depends dbus || return 1

4
init.d/cronie Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ssm
service_command='/bin/crond'
service_args=( -n )

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/cupsd'

View File

@ -1,15 +1,10 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn=true
service_command='/usr/bin/dbus-daemon'
service_args=( --system --nofork )
service_tmpfiles=( '/run/dbus:dir' )
start_pre() {
pre_start() {
/usr/bin/dbus-uuidgen --ensure=/etc/machine-id
}
start() {
start_pre
watchman.start
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# This is a script to set up the links in /dev in absence of e?(u|s?m)dev.
service_type='oneshot'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# dhcp client daemon initscript
#service_respawn=true

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# soft depend, OR return 1 for hard depend
depends dnscrypt-backup

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/dnscrypt-proxy'

View File

@ -1,15 +1,12 @@
#!/usr/bin/env watchman
docker_dir='/home/docker'
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/docker'
service_args=( -g "$docker_dir" -d )
service_command=( '/usr/bin/dockerd' -s overlay2 )
update() {
watchman.stop && {
stop && {
wget "https://get.docker.io/builds/Linux/x86_64/docker-latest" -O "$service_command"
}
watchman.start
start
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_respawn=true
service_command='/usr/bin/dropbear'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/udevd'
@ -6,12 +6,12 @@ service_command='/usr/bin/udevd'
cfg_udev_settle_timeout="${cfg_udev_settle_timeout:-60}"
udev.populate_dev() {
watchman.msg "Populating /dev with udev..."
printf 'Populating /dev with udev...\n'
udevadm trigger --type=subsystems --action=add
udevadm trigger --type=devices --action=add
watchman.msg "Waiting for uevents..."
udevadm settle --timeout=${cfg_udev_settle_timeout}
printf 'Waiting for uevents...\n'
udevadm settle "--timeout=${cfg_udev_settle_timeout}"
udevadm control --property=do_not_run_plug_service=
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# The configuration is in conf.d.
#service_respawn='true'

View File

@ -1,14 +1,19 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command=( /usr/bin/fsck -A -C -p )
pre_start() {
printf 'Remounting / as read-only...\n'
mount / -o remount,ro
}
start() {
watchman.msg "Remounting / as read-only..."
mount / -o remount,ro
printf 'Checking filesystems...\n'
super_start
}
watchman.msg "Checking filesystems..."
/usr/bin/fsck -A -C -p
watchman.msg "Remounting / as read-write..."
post_start() {
printf 'Remounting / as read-write...\n'
mount / -o remount,rw
}

5
init.d/haproxy Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env ssm
#service_respawn=true
service_command='/usr/bin/haproxy'
service_args=( -db -f /etc/haproxy/haproxy.cfg )

4
init.d/haveged Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ssm
service_command=/usr/bin/haveged
service_args=( -F -w 1024 -v 1 )

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# Get hostname from /etc/hostname
if [[ -e "/etc/hostname" ]]; then

View File

@ -1,15 +1,12 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command=( /usr/bin/true )
start() {
watchman.msg "Running module autodetect..."
watchman.start
}
pre_start() {
printf '(${service_name}) Running module autodetect...\n'
spawn() {
# The Alpine Linux hwdetect script runs this twice.
# Apparently to make sure we get devices that appear after loading a module on the first run.
# The Alpine Linux hwdetect script runs this twice. Apparently to make sure we get devices that appear after loading a module on the first run.
find /sys -name modalias -type f -print0 | xargs -0 sort -u | xargs modprobe -b -a 2>/dev/null
find /sys -name modalias -type f -print0 | xargs -0 sort -u | xargs modprobe -b -a 2>/dev/null

View File

@ -1,13 +1,12 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
cfg_ip4dump='/etc/iptables/ip4.rules'
cfg_ip6dump='/etc/iptables/ip6.rules'
spawn() {
watchman.msg "Restoring netfilter rules..."
service_command=( /usr/bin/true )
start() {
[[ -f "$cfg_ip4dump" ]] && {
iptables-restore -t < "$cfg_ip4dump" || return 1
iptables-restore < "$cfg_ip4dump"
@ -17,20 +16,22 @@ spawn() {
ip6tables-restore -t < "$cfg_ip6dump" || return 1
ip6tables-restore < "$cfg_ip6dump"
}
super_start
}
stop() {
watchman.msg "Flushing netfilter rules..."
iptables-save | sed -re 's/(:[A-Z]+\s+)[A-Z]+/\1ACCEPT/g' -e '/-.+/d' | iptables-restore
ip6tables-save | sed -re 's/(:[A-Z]+\s+)[A-Z]+/\1ACCEPT/g' -e '/-.+/d' | ip6tables-restore
for i in $(iptables-save | grep -E '^\*'); do iptables -t "${i//\*/}" -X; done
for i in $(ip6tables-save | grep -E '^\*'); do ip6tables -t "${i//\*/}" -X; done
super_stop
}
save() {
watchman.msg "Saving netfilter rules..."
printf 'Saving rules.\n'
/usr/bin/iptables-save > "$cfg_ip4dump";
/usr/bin/ip6tables-save > "$cfg_ip6dump";
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# dhcp client daemon initscript
#service_respawn=true

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
tty="${service_name##*-}"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/libvirtd'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
cfg_iface="${service_name%%.*}"
@ -6,7 +6,7 @@ service_type='oneshot'
service_command='/usr/bin/ip'
service_args=( link set "$cfg_iface" up)
wait_for_iface() {
ready() {
local iface="$1" timer='0' timeout='6'
until [[ "$(ip link show $iface up)" ]]; do
@ -15,18 +15,7 @@ wait_for_iface() {
done
}
start() {
watchman.msg "Activating the $cfg_iface interface..."
watchman.start
wait_for_iface || {
echo "Interface $cfg_iface failed to come up!"
return 1
}
}
stop() {
watchman.msg "Deactivating the $cfg_iface interface..."
pre_stop() {
ip link set "${cfg_iface}" down
watchman.stop
super_stop
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_workdir='/usr'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command='/usr/bin/mdev'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn=true
service_command='/usr/bin/memcached'

4
init.d/motd Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ssm
service_type='oneshot'
service_command=( /usr/local/bin/update-motd )

View File

@ -1,11 +1,12 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command=( /usr/bin/mount -a )
spawn() {
pre_start() {
[[ -w / ]] || { mount -o remount,rw /; }
mount -a
swapon -a
}
unset stop
post_start() {
swapon -a
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn=true
service_command='/usr/bin/mpd'

10
init.d/network Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env ssm
service_type='oneshot'
service_command=( /usr/bin/znet -d up )
ifaces=( 'eth0' 'warp' )
pre_stop() {
"$service_command" "${service_args[@]}" down
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_respawn='true'
service_command='/usr/bin/ngetty'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# For respawn to work, set 'daemon no' in nginx.conf
#service_respawn='true'
@ -11,15 +11,12 @@ conftest() {
nginx.test_config
}
reload() {
if nginx.test_config -q; then
watchman.reload
else
watchman.err "Nginx config test failed, not reloading."
return 1
fi
pre_reload() {
nginx.test_config || {
printf 'Config test failed, not reloading.\n'
}
}
upgrade() {
watchman.msg "This script has no zero-downtime upgrade support for nginx."
printf 'This script has no zero-downtime upgrade support for nginx.\n'
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
cfg_nrpe_config='/etc/nrpe/nrpe.cfg'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/ntpd'

View File

@ -1,4 +1,4 @@
#!/usr/bin/watchman
#!/usr/bin/env ssm
service_command='/usr/bin/oidentd'
service_args=( -i )

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/ntpd'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
cfg_ovpn_instance="${service_name##*-}"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_respawn='true'
service_command="/usr/sbin/openvpn"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command='/usr/bin/mkdir'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/php-fpm'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/preload'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
privoxy_username='privoxy'
privoxy_configfile='/etc/privoxy/config'
@ -7,16 +7,6 @@ privoxy_configfile='/etc/privoxy/config'
service_command='/usr/bin/privoxy'
service_args=( --no-daemon --user "$privoxy_username" "$privoxy_configfile" )
privoxy::configtest() {
pre_restart() {
"$service_command" --config-test "${service_args[@]}"
}
restart() {
privoxy::configtest || {
watchman.err "Config test failed, not restarting!"
return 1
}
watchman.stop
watchman.start
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
_prosodyctl='/usr/bin/prosodyctl'

View File

@ -1,12 +1,6 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command="/etc/rc.local"
unset stop
start() {
[[ -f "/etc/rc.local" ]] && {
watchman.start
}
}
pre_start() [[ -f "/etc/rc.local" ]]

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
# Author: Alad Wenter
#service_respawn=true

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/crond'

7
init.d/sdhcp Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env ssm
# dhcp client daemon initscript
service_style='oneshot'
service_command='/usr/bin/sdhcp'
stop() { killall sdhcp; }

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command='/usr/bin/smdev'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
cfg_sshd_cfgdir='/etc/ssh'
@ -6,6 +6,10 @@ service_respawn=true
service_command='/usr/bin/sshd'
service_args=( -D -f "$cfg_sshd_cfgdir/sshd_config" )
depends_ready=( znet )
pre_start() {
[[ -e "/etc/ssh/ssh_host_key" ]] || { ssh-keygen -A; }
if ! [[ -e "/etc/ssh/ssh_host_key" ]]; then
ssh-keygen -A
fi
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
unset reload
service_type='oneshot'
@ -13,11 +13,3 @@ pre_start() {
service_args=( -p "${sysctl_config_files[@]}" )
}
start() {
if ! [[ "$sysctl_config_files" ]]; then
return 0
fi
watchman.start
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn=true
service_command='/usr/bin/syslog-ng'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/lib/systemd/systemd-udevd'
@ -6,11 +6,11 @@ service_command='/usr/lib/systemd/systemd-udevd'
cfg_udev_settle_timeout="${cfg_udev_settle_timeout:-60}"
udev.populate_dev() {
watchman.msg "Populating /dev with udev..."
prinft 'Populating /dev with udev...\n'
udevadm trigger --type=subsystems --action=add
udevadm trigger --type=devices --action=add
watchman.msg "Waiting for uevents..."
printf 'Waiting for uevents...\n'
udevadm settle --timeout=${cfg_udev_settle_timeout}
udevadm control --property=do_not_run_plug_service=
}

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn=true
service_pidfile='/run/teamviewerd.pid'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
instance="${service_name##*-}"

View File

@ -1,18 +1,11 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/unbound'
service_args=( -d )
service_command=( /usr/bin/unbound -d )
conftest() {
unbound-checkconf
}
reload() {
if conftest; then
watchman.reload
else
watchman.err "Configtest failed, not reloading."
pre_reload() {
unbound-checkconf || {
printf 'Configtest failed, not reloading.\n'
return 1
fi
}
}

4
init.d/userrc Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ssm
service_type='oneshot'
service_command='/usr/bin/userrc'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/vdevd'

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn='true'
service_command='/usr/bin/crond'

5
init.d/wpa_supplicant Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env ssm
service_command='/usr/bin/wpa_supplicant'
service_config='/etc/wpa_supplicant/wpa_supplicant.conf'
service_args=( -i "${service_name##*-}" -c "$service_config" )

View File

@ -1,4 +1,4 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
#service_respawn=true
service_command='/usr/bin/xinetd'

View File

@ -1,10 +1,10 @@
#!/usr/bin/env watchman
#!/usr/bin/env ssm
service_type='oneshot'
service_command='/usr/bin/znet'
service_args=( -d )
service_command=( /usr/bin/znet -d up )
stop() {
"$service_command" $service_args down
watchman.stop
ifaces=( 'eth0' 'warp' )
pre_stop() {
"$service_command" "${service_args[@]}" down
}

3
init.d/zt Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ssm
service_command="/usr/bin/zerotier-one"