mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
Update rc script for FreeBSD and fix logging
This commit is contained in:
parent
3dfa6d0cc9
commit
b41a1bb63f
3 changed files with 15 additions and 20 deletions
|
@ -1,10 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Put the yggdrasil and yggdrasilctl binaries into /usr/local/bin
|
# Put the yggdrasil and yggdrasilctl binaries into /usr/local/bin
|
||||||
# Then copy this script into /etc/rc.d/yggdrasil
|
# Then copy this script into /usr/local/etc/rc.d/yggdrasil
|
||||||
|
# yggdrasil_syslog.conf into /usr/local/etc/syslog.d/yggdrasil.conf
|
||||||
|
# and yggdrasil_newsyslog.conf into /usr/local/etc/newsyslog.conf.d/yggdrasil.conf
|
||||||
# Finally, run:
|
# Finally, run:
|
||||||
# 1. chmod +x /etc/rc.d/yggdrasil /usr/local/bin/{yggdrasil,yggdrasilctl}
|
# 1. chmod +x /etc/rc.d/yggdrasil /usr/local/bin/{yggdrasil,yggdrasilctl}
|
||||||
# 2. echo "yggdrasil_enable=yes" >> /etc/rc.d
|
# 2. sysrc yggdrasil_enable=YES
|
||||||
# 3. service yggdrasil start
|
# 3. service yggdrasil start
|
||||||
#
|
#
|
||||||
# PROVIDE: yggdrasil
|
# PROVIDE: yggdrasil
|
||||||
|
@ -19,9 +21,10 @@ rcvar="yggdrasil_enable"
|
||||||
start_cmd="${name}_start"
|
start_cmd="${name}_start"
|
||||||
stop_cmd="${name}_stop"
|
stop_cmd="${name}_stop"
|
||||||
|
|
||||||
|
yggdrasil_command="/usr/local/bin/yggdrasil"
|
||||||
pidfile="/var/run/yggdrasil/${name}.pid"
|
pidfile="/var/run/yggdrasil/${name}.pid"
|
||||||
command="/usr/sbin/daemon"
|
command="/usr/sbin/daemon"
|
||||||
command_args="-P ${pidfile} -r -f ${yggdrasil_command}"
|
command_args="-P ${pidfile} -r -S -m 3 -s info -T yggdrasil ${yggdrasil_command}"
|
||||||
|
|
||||||
yggdrasil_start()
|
yggdrasil_start()
|
||||||
{
|
{
|
||||||
|
@ -31,25 +34,15 @@ yggdrasil_start()
|
||||||
return 1
|
return 1
|
||||||
)
|
)
|
||||||
|
|
||||||
test ! -f /etc/yggdrasil.conf && (
|
test ! -f /usr/local/etc/yggdrasil.conf && (
|
||||||
logger -s -t yggdrasil "Generating new configuration file into /etc/yggdrasil.conf"
|
logger -s -t yggdrasil "Generating new configuration file into /usr/local/etc/yggdrasil.conf"
|
||||||
/usr/local/bin/yggdrasil -genconf > /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}$')"
|
mkdir -p /var/run/yggdrasil
|
||||||
tap_name="$(echo -n ${tap_path} | tr -d '/dev/')"
|
|
||||||
|
|
||||||
/sbin/ifconfig ${tap_name} >/dev/null 2>&1 || (
|
|
||||||
logger -s -t yggdrasil "Creating ${tap_name} adapter"
|
|
||||||
/sbin/ifconfig ${tap_name} create || logger -s -t yggdrasil "Failed to create ${tap_name} adapter"
|
|
||||||
)
|
|
||||||
|
|
||||||
test ! -d /var/run/yggdrasil && mkdir -p /var/run/yggdrasil
|
|
||||||
|
|
||||||
logger -s -t yggdrasil "Starting yggdrasil"
|
logger -s -t yggdrasil "Starting yggdrasil"
|
||||||
${command} ${command_args} /usr/local/bin/yggdrasil -useconffile /etc/yggdrasil.conf \
|
${command} ${command_args} -useconffile /usr/local/etc/yggdrasil.conf &
|
||||||
1>/var/log/yggdrasil.stdout.log \
|
|
||||||
2>/var/log/yggdrasil.stderr.log &
|
|
||||||
}
|
}
|
||||||
|
|
||||||
yggdrasil_stop()
|
yggdrasil_stop()
|
||||||
|
@ -57,8 +50,7 @@ yggdrasil_stop()
|
||||||
logger -s -t yggdrasil "Stopping yggdrasil"
|
logger -s -t yggdrasil "Stopping yggdrasil"
|
||||||
test -f /var/run/yggdrasil/${name}.pid && kill -TERM $(cat /var/run/yggdrasil/${name}.pid)
|
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_name="$(egrep '^[ \t]+IfName:' /usr/local/etc/yggdrasil.conf | sed 's/[ \t]*IfName:[ \t]*//')"
|
||||||
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 && (
|
||||||
logger -s -t yggdrasil "Destroying ${tap_name} adapter"
|
logger -s -t yggdrasil "Destroying ${tap_name} adapter"
|
||||||
|
|
1
contrib/freebsd/yggdrasil_newsyslog.conf
Normal file
1
contrib/freebsd/yggdrasil_newsyslog.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/var/log/yggdrasil.log 644 3 1000 * JC
|
2
contrib/freebsd/yggdrasil_syslog.conf
Normal file
2
contrib/freebsd/yggdrasil_syslog.conf
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
!yggdrasil
|
||||||
|
*.* /var/log/yggdrasil.log
|
Loading…
Add table
Add a link
Reference in a new issue