34 lines
653 B
Plaintext
Executable File
34 lines
653 B
Plaintext
Executable File
#!/usr/bin/env watchman
|
|
|
|
unset reload
|
|
|
|
service_command='/usr/bin/cjdroute'
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|
|
|
|
get_pid() {
|
|
lsof -i :"$cjdroute_admin_port" | tail -1 | cut -d ' ' -f 2
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
"$service_command" < "$cjdroute_config" &>"$service_logfile"
|
|
}
|