1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/openvpn/templates/announcer

30 lines
857 B
Text
Raw Normal View History

2017-05-27 18:09:50 +00:00
#!/bin/bash -x
# small daemon to identify this machine to the openvpn server
HANDLE=
UUID=
source /etc/xsce/xsce.env
if [ -z "$HANDLE" ]; then
HANDLE=`cat /etc/xsce/xsce.ini | gawk \
'{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'`
fi
if [ -z "$HANDLE" ]; then
if [ -f /etc/xsce/handle ]; then
HANDLE=`cat /etc/xsce/handle`
fi
fi
if [ -f /etc/xsce/uuid ]; then
UUID=`cat /etc/xsce/uuid`
fi
# start the daemon which will serve the handle on demand
source /etc/init.d/functions
SERVER=/usr/bin/ncat
PID_FILE=/var/run/openvpn/announce.pid
HANDLE=${HANDLE// /_}
2017-05-27 23:10:45 +00:00
{% if is_debuntu %}
2017-05-27 18:09:50 +00:00
ID=`printf "HANDLE = %s|UUID = %s|" $HANDLE $UUID`
$SERVER -l -k -p1705 --exec "/bin/echo $ID" &
{% else %}
daemon --pidfile=${PID_FILE} $SERVER "-l -k -p1705 --exec \"/usr/bin/echo $(printf 'HANDLE = %s|UUID = %s' $HANDLE $UUID)\"" &
2017-05-27 18:09:50 +00:00
{% endif %}