ssm-services/init.d/cjdroute

41 lines
1.0 KiB
Plaintext
Raw Normal View History

2013-11-05 14:10:22 +00:00
#!/usr/bin/env watchman
2014-07-24 20:31:44 +00:00
# Two warnings:
# 1) This script uses a script to run cjdroute and feed it
2014-09-30 04:42:00 +00:00
# the config. It can be found in the main cjdns repo:
2015-01-26 09:38:29 +00:00
# contrib/sh/run-cjdroute.sh
# Or here: http://ix.io/fYT
2014-07-24 20:31:44 +00:00
# 2) service_respawn is disabled by default because you need
# "noBackground":1 in cjdroute.conf for it to actually work.
# Barely.
2013-11-05 14:10:22 +00:00
unset reload
2014-11-11 11:50:48 +00:00
#service_respawn=true
service_command='/usr/bin/run-cjdroute'
cjdroute_admin_port='11234'
2013-11-05 14:10:22 +00:00
2013-11-13 07:04:27 +00:00
cjdroute.check_tun_module() {
[[ -e '/dev/net/tun' ]] || {
modprobe tun || {
watchman.err "Could not load module tun!"
return 1
}
}
}
2013-11-05 14:10:22 +00:00
start() {
2013-11-13 07:04:27 +00:00
cjdroute.check_tun_module || { return 1; }
2014-07-03 07:05:52 +00:00
watchman.start
}
stop() {
[[ "$service_respawn" == 'true' ]] && { watchman.stop; } # stopping the watchdog
# Stopping the actual s-o-b daemon that won't die properly.
2015-01-26 09:38:29 +00:00
cjdroute_control_pid=$(lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2)
2014-07-03 07:05:52 +00:00
watchman.pid_check "$cjdroute_control_pid" && {
kill "$cjdroute_control_pid"
watchman.pid_wait "$cjdroute_control_pid"
2014-06-28 06:54:06 +00:00
}
2013-11-05 14:10:22 +00:00
}