2019-03-05 22:30:06 +03:00
|
|
|
#!/sbin/openrc-run
|
|
|
|
|
|
|
|
description="An experiment in scalable routing as an encrypted IPv6 overlay network."
|
|
|
|
|
|
|
|
CONFFILE="/etc/yggdrasil.conf"
|
|
|
|
pidfile="/run/${RC_SVCNAME}.pid"
|
|
|
|
|
|
|
|
command="/usr/bin/yggdrasil"
|
2019-03-05 22:50:24 +03:00
|
|
|
extra_started_commands="reload"
|
2019-03-05 22:30:06 +03:00
|
|
|
|
|
|
|
depend() {
|
|
|
|
use net dns logger
|
|
|
|
}
|
|
|
|
|
|
|
|
start_pre() {
|
|
|
|
if [ ! -f "${CONFFILE}" ]; then
|
|
|
|
ebegin "Generating new configuration file into ${CONFFILE}"
|
|
|
|
if ! eval ${command} -genconf > ${CONFFILE}; then
|
|
|
|
eerror "Failed to generate configuration file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -e /dev/net/tun ]; then
|
|
|
|
ebegin "Inserting TUN module"
|
|
|
|
if ! modprobe tun; then
|
|
|
|
eerror "Failed to insert TUN kernel module"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2019-03-05 22:50:24 +03:00
|
|
|
ebegin "Starting ${RC_SVCNAME}"
|
2019-03-05 22:30:06 +03:00
|
|
|
start-stop-daemon --start --quiet \
|
|
|
|
--pidfile "${pidfile}" \
|
|
|
|
--make-pidfile \
|
|
|
|
--background \
|
|
|
|
--stdout /var/log/yggdrasil.stdout.log \
|
|
|
|
--stderr /var/log/yggdrasil.stderr.log \
|
2019-03-05 22:50:24 +03:00
|
|
|
--exec "${command}" -- -useconffile "${CONFFILE}"
|
|
|
|
eend $?
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
ebegin "Reloading ${RC_SVCNAME}"
|
|
|
|
start-stop-daemon --signal HUP --pidfile "${pidfile}"
|
2019-03-05 22:30:06 +03:00
|
|
|
eend $?
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2019-03-05 22:50:24 +03:00
|
|
|
ebegin "Stopping ${RC_SVCNAME}"
|
2019-03-05 22:30:06 +03:00
|
|
|
start-stop-daemon --stop --pidfile "${pidfile}" --exec "${command}"
|
|
|
|
eend $?
|
|
|
|
}
|