diff options
author | Karel Kočí <cynerd@email.cz> | 2017-09-20 21:19:05 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-09-20 21:22:36 +0200 |
commit | f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 (patch) | |
tree | 5025b33a8c3d4c69ad2b62e1169b669c56f712f9 /scripts/setup.sh | |
parent | 65f52ead41dc6df73671ddd3a8c6a2edecb6dfb3 (diff) | |
download | multiconfig-complicated.tar.gz multiconfig-complicated.tar.bz2 multiconfig-complicated.zip |
Commit current statecomplicated
Diffstat (limited to 'scripts/setup.sh')
-rwxr-xr-x | scripts/setup.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..5ca4211 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,38 @@ +#!/bin/sh +set -e + +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + echo "Multiconfig system setup script" + echo "Usage: setup.sh" + exit 0 + ;; + esac + shift +done + +# Move to multiconfig root +cd "$(dirname "$(dirname "$(readlink -f "$1")")")" + +PREFIX="/root/.multiconfig" + +echo "Creating directory $PREFIX" +sudo mkdir -p "$PREFIX" + +# Manage new key +echo "Generating new key for this host" +KEY="$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 128 | xargs)" +sudo -- sh -c "echo -n '$KEY' > '$PREFIX/key'" +# TODO setup access rights + +echo -n "$KEY" > wkey +FKEY="files/keys/$(hostname)" +echo "Writing key to repository" +gpg2 --decrypt files/keys/primary.gpg | \ + openssl aes-192-cbc -e -a -kfile wkey -out "$FKEY" +rm -f wkey +echo "Don't forget to add key to git!" + +# Deploy multiconfig script +sudo cp scripts/multiconfig.sh /usr/local/bin/multiconfig.sh |