forked from Spark/ssm-services
41 lines
931 B
Plaintext
Executable File
41 lines
931 B
Plaintext
Executable File
#!/usr/bin/env watchman
|
|
|
|
unset reload
|
|
|
|
service_command='/usr/local/sbin/cjdroute-start'
|
|
service_respawn=true
|
|
|
|
cjdroute_config='/etc/cjdroute.conf'
|
|
cjdroute_admin_port='11234'
|
|
|
|
cjdroute.check_tun_module() {
|
|
[[ -e '/dev/net/tun' ]] || {
|
|
modprobe tun || {
|
|
watchman.err "Could not load module tun!"
|
|
return 1
|
|
}
|
|
}
|
|
}
|
|
|
|
start() {
|
|
cjdroute.check_tun_module || { return 1; }
|
|
|
|
[[ -e "$cjdroute_config" ]] || {
|
|
watchman.err "$cjdroute_config does not exist, please create it by running cjdroute --genconf >> /etc/cjdroute.conf"
|
|
return 1
|
|
}
|
|
|
|
watchman.start
|
|
}
|
|
|
|
stop() {
|
|
[[ "$service_respawn" == 'true' ]] && { watchman.stop; } # stopping the watchdog
|
|
|
|
# Stopping the actual s-o-b daemon that won't die properly.
|
|
cjdroute_control_pid=`lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2`
|
|
watchman.pid_check "$cjdroute_control_pid" && {
|
|
kill "$cjdroute_control_pid"
|
|
watchman.pid_wait "$cjdroute_control_pid"
|
|
}
|
|
}
|