Add unit systemd files

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2017-11-26 08:23:25 +00:00
parent 0f5a6f5d98
commit 75b2903ac2
6 changed files with 135 additions and 7 deletions

36
systemd/glorytun-setup Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/sh
set -e
_ask() {
printf "%s: " "$1"
read -r "$2"
}
_NAME=tun0
_ask "Config filename ($_NAME)" NAME
NAME=${NAME:-$_NAME}
if [ -f /etc/glorytun/"$NAME" ]; then
echo "This config already exit!"
exit 1
fi
_ask "Server ip (enter for server conf)" HOST
_ask "Server key (enter to generate a new one)" KEY
if [ -z "$KEY" ]; then
KEY=$(glorytun keygen) || exit
echo "Your new key: $KEY"
fi
mkdir -p /etc/glorytun
FILE="/etc/glorytun/$NAME"
echo "${HOST:+HOST=$HOST}" > "$FILE"
touch "$FILE.key"
chmod 600 "$FILE.key"
echo "$KEY" > "$FILE.key"
echo "Done"