mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-25 21:51:38 +00:00
contrib/openrc: add init file for OpenRC
This commit is contained in:
parent
d5a9c39dab
commit
26a952aa6c
49
contrib/openrc/yggdrasil
Executable file
49
contrib/openrc/yggdrasil
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/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"
|
||||||
|
|
||||||
|
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() {
|
||||||
|
ebegin "Starting Yggdrasil"
|
||||||
|
start-stop-daemon --start --quiet \
|
||||||
|
--pidfile "${pidfile}" \
|
||||||
|
--make-pidfile \
|
||||||
|
--background \
|
||||||
|
--stdout /var/log/yggdrasil.stdout.log \
|
||||||
|
--stderr /var/log/yggdrasil.stderr.log \
|
||||||
|
--exec "${command}" -- -useconf < "${CONFFILE}"
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
ebegin "Stopping Yggdrasil"
|
||||||
|
start-stop-daemon --stop --pidfile "${pidfile}" --exec "${command}"
|
||||||
|
eend $?
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user