2015-01-26 13:26:18 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if [ -z "$BASH" ]; then
|
|
|
|
echo "All vpn scripts requires bash!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-01-26 13:37:42 +00:00
|
|
|
set -eu
|
|
|
|
|
2015-03-12 22:36:20 +00:00
|
|
|
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
|
|
|
|
source "$SCRIPT_DIR/lib/core.bash"
|
|
|
|
|
2015-01-26 13:37:42 +00:00
|
|
|
die() {
|
|
|
|
echo $1 &>2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
warn() {
|
|
|
|
echo $1 &>2
|
|
|
|
}
|
|
|
|
|
2015-03-12 22:36:20 +00:00
|
|
|
if [ ! -f "$SCRIPT_DIR/ed25519_key.priv" ]; then
|
2015-01-26 13:37:42 +00:00
|
|
|
warn "No ed25519_key.priv found!"
|
|
|
|
fi
|
|
|
|
|
2015-03-12 22:36:20 +00:00
|
|
|
if [ ! -f "$SCRIPT_DIR/rsa_key.priv" ]; then
|
2015-01-26 13:37:42 +00:00
|
|
|
warn "No rsa_key.priv found!"
|
|
|
|
fi
|
|
|
|
|
2015-01-26 13:26:18 +00:00
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
if has sudo; then
|
|
|
|
echo "Start tinc. Cancel with Ctrl+C ..."
|
2015-03-12 22:36:20 +00:00
|
|
|
sudo TINC_DEBUG=1 tincd -c "$SCRIPT_DIR" -D -d
|
2015-01-26 13:26:18 +00:00
|
|
|
else
|
|
|
|
die "run this script as root"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Start tinc. Cancel with Ctrl+C ..."
|
2015-02-19 08:37:49 +00:00
|
|
|
export TINC_DEBUG=1
|
2015-03-12 22:36:20 +00:00
|
|
|
tincd -c "$SCRIPT_DIR" -D -d
|
2015-01-26 13:26:18 +00:00
|
|
|
fi
|