2013-11-05 14:10:22 +00:00
|
|
|
#!/usr/bin/env watchman
|
|
|
|
|
|
|
|
unset reload
|
|
|
|
|
2013-11-08 21:39:33 +00:00
|
|
|
service_username='cjdns'
|
2013-11-09 18:37:01 +00:00
|
|
|
service_command='/usr/local/sbin/cjdroute'
|
|
|
|
service_args='< /etc/cjdns/cjdroute.conf'
|
2013-11-05 14:10:22 +00:00
|
|
|
|
|
|
|
cjdroute_tun_interface='cjd0'
|
2013-11-08 21:39:33 +00:00
|
|
|
cjdroute_ipv6_addr='fca7:8aef:6571:63c5:b23c:2fbc:8dea:e207/8'
|
2013-11-09 18:37:01 +00:00
|
|
|
cjdroute_listen_port='11270'
|
2013-11-05 14:10:22 +00:00
|
|
|
|
2013-11-09 18:28:54 +00:00
|
|
|
service_pid=`lsof -i :"$cjdroute_listen_port" | tail -1 | cut -d ' ' -f 2`
|
2013-11-05 14:10:22 +00:00
|
|
|
|
2013-11-08 21:41:42 +00:00
|
|
|
service_pid=`lsof -i :"$cjdroute_listen_port" | tail -1 | cut -d ' ' -f 2`
|
|
|
|
|
2013-11-05 14:10:22 +00:00
|
|
|
cjdroute.create_tun() {
|
|
|
|
ip tuntap add mode tun user "$service_username" group "$service_username" "$cjdroute_tun_interface"
|
|
|
|
ip a add "$cjdroute_ipv6_addr" dev "$cjdroute_tun_interface"
|
|
|
|
ip link set "$cjdroute_tun_interface" up
|
|
|
|
}
|
|
|
|
|
|
|
|
cjdroute.destroy_tun() {
|
|
|
|
ip tuntap del mode tun "$cjdroute_tun_interface"
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2013-11-09 18:37:01 +00:00
|
|
|
[[ "$service_username" ]] && {
|
|
|
|
cjdroute.create_tun || { return 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
watchman.start
|
2013-11-05 14:10:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2013-11-08 21:39:33 +00:00
|
|
|
watchman.stop
|
2013-11-09 18:37:01 +00:00
|
|
|
|
|
|
|
[[ "$service_username" ]] && { cjdroute.destroy_tun; }
|
2013-11-05 14:10:22 +00:00
|
|
|
}
|