From e26ecf37a3714474737e6ed201fc8a7b4e730b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Sun, 26 Nov 2017 20:52:36 +0000 Subject: [PATCH] Cleanup glorytun-setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- systemd/glorytun-setup | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/systemd/glorytun-setup b/systemd/glorytun-setup index 51536b5..e4565ec 100755 --- a/systemd/glorytun-setup +++ b/systemd/glorytun-setup @@ -7,9 +7,8 @@ _ask() { read -r "$2" } -_NAME=tun0 -_ask "Config filename ($_NAME)" NAME -NAME=${NAME:-$_NAME} +_ask "Config filename (tun0)" NAME +NAME=${NAME:-tun0} if [ -f /etc/glorytun/"$NAME" ]; then echo "This config already exit!" @@ -20,23 +19,21 @@ _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 + KEY=$(glorytun keygen) echo "Your new key: $KEY" fi +# install files + mkdir -p /etc/glorytun -FILE="/etc/glorytun/$NAME" +env | grep 'TABLE=\|HOST=' > /etc/glorytun/"$NAME" +( umask 077; echo "$KEY" > /etc/glorytun/"$NAME".key ) -echo "${HOST:+HOST=$HOST}" > "$FILE" - -touch "$FILE.key" -chmod 600 "$FILE.key" -echo "$KEY" > "$FILE.key" +# start services _ask "Start glorytun now ? (enter to skip)" START -case "$START" in - y*|Y*) - systemctl restart systemd-networkd - systemctl start glorytun@"$NAME" - ;; +case "$START" in y*|Y*) + systemctl daemon-reload + systemctl start systemd-networkd + systemctl start glorytun@"$NAME" ;; esac