diff options
author | Erich Eckner <git@eckner.net> | 2019-03-30 20:20:27 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-03-30 20:20:27 +0100 |
commit | 36c29f82abf95dc1520989a48814b6882a6db374 (patch) | |
tree | f72f1b2a6e857cd782fe428f18a7a45d3f731d86 /gen-new-auth-token | |
download | ddns-36c29f82abf95dc1520989a48814b6882a6db374.tar.xz |
Initial commit
Diffstat (limited to 'gen-new-auth-token')
-rwxr-xr-x | gen-new-auth-token | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gen-new-auth-token b/gen-new-auth-token new file mode 100755 index 0000000..681f35a --- /dev/null +++ b/gen-new-auth-token @@ -0,0 +1,36 @@ +#!/bin/bash + +set -e + +echoToken() { + base64 < /dev/urandom | \ + tr -d '\n/+' | \ + head -c 64 +} + +dir="$(dirname "$(readlink -f "$0")")" + +read -p 'Subdomain von ddns.eckner.net: ' subDom + +if [ -z "${subDom}" ]; then + inh="$(sed 's|^.\{64\} ||' "${dir}/tokens")" + echo "${inh}" | \ + while read -r s; do + echoToken + echo " ${s}" + done > \ + "${dir}/tokens" +else + authToken="$( + echoToken + )" + + if [ ! -f "${dir}/tokens" ]; then + touch "${dir}/tokens" + fi + chmod 600 "${dir}/tokens" + + sed -i "/ ${subDom}\$/d" "${dir}/tokens" + + echo "${authToken} ${subDom}" >> "${dir}/tokens" +fi |