Fixed initrc

* Made routing work properly (sometimes yggdrasil due to some bug doesn't add route) 
* Removed tap0 if it existed during start (and recreated it)
* Use the `/usr/local/etc/` instead of `/etc/` to comply with the FreeBSD hier. In FreeBSD, `/etc/` is reserved for the base system; `/usr/local/etc/` is meant for the third-party applications.
This commit is contained in:
Rany 2020-02-01 00:08:16 +02:00 committed by GitHub
parent a9cfa5bc0d
commit 9563826e30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,25 +31,30 @@ yggdrasil_start()
return 1
)
test ! -f /etc/yggdrasil.conf && (
logger -s -t yggdrasil "Generating new configuration file into /etc/yggdrasil.conf"
/usr/local/bin/yggdrasil -genconf > /etc/yggdrasil.conf
test ! -f /usr/local/etc/yggdrasil.conf && (
logger -s -t yggdrasil "Generating new configuration file into /usr/local/etc/yggdrasil.conf"
/usr/local/bin/yggdrasil -genconf > /usr/local/etc/yggdrasil.conf
)
tap_path="$(cat /etc/yggdrasil.conf | egrep -o '/dev/tap[0-9]{1,2}$')"
tap_path="$(cat /usr/local/etc/yggdrasil.conf | egrep -o '/dev/tap[0-9]{1,2}$')"
tap_name="$(echo -n ${tap_path} | tr -d '/dev/')"
/sbin/ifconfig ${tap_name} >/dev/null 2>&1 || (
/sbin/ifconfig ${tap_name} >/dev/null 2>&1
if [ $? != 0 ]; then
logger -s -t yggdrasil "Creating ${tap_name} adapter"
/sbin/ifconfig ${tap_name} create || logger -s -t yggdrasil "Failed to create ${tap_name} adapter"
)
else
logger -s -t yggdrasil "Destroying ${tap_name} adapter"
/sbin/ifconfig ${tap_name} destroy || logger -s -t yggdrasil "Failed to destroy ${tap_name} adapter"
test ! -d /var/run/yggdrasil && mkdir -p /var/run/yggdrasil
logger -s -t yggdrasil "Starting yggdrasil"
${command} ${command_args} /usr/local/bin/yggdrasil -useconffile /etc/yggdrasil.conf \
${command} ${command_args} /usr/local/bin/yggdrasil -useconffile /usr/local/etc/yggdrasil.conf \
1>/var/log/yggdrasil.stdout.log \
2>/var/log/yggdrasil.stderr.log &
route -6 add 200::/7 -iface ${tap_name} > /dev/null 1>/dev/null 2>/dev/null &
}
yggdrasil_stop()
@ -57,7 +62,7 @@ yggdrasil_stop()
logger -s -t yggdrasil "Stopping yggdrasil"
test -f /var/run/yggdrasil/${name}.pid && kill -TERM $(cat /var/run/yggdrasil/${name}.pid)
tap_path="$(cat /etc/yggdrasil.conf | grep /dev/tap | egrep -o '/dev/.*$')"
tap_path="$(cat /usr/local/etc/yggdrasil.conf | grep /dev/tap | egrep -o '/dev/.*$')"
tap_name="$(echo -n ${tap_path} | tr -d '/dev/')"
/sbin/ifconfig ${tap_name} >/dev/null 2>&1 && (