New behavior, new tests, added wizzard and processor

Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
2022-08-07 21:44:31 +02:00
parent f4ac509665
commit 1fef7bc404
8 changed files with 203 additions and 118 deletions

View File

@@ -1,70 +1,5 @@
#!/bin/bash
function checkProjectName(){
# check, if volume does not exist yet
name=$1
# should not be empty
[ -n "$read_project_name" ] || die "Empty project name is not allowed"
if [ -d /data/$dir_prefix-$name ]
then
die "Target volume for project '$name' exists - please try again!"
fi
}
function generateSSHKey(){
# generates ssh key with $1 path and $2 description
local keyfile=$1/identity
local description=$2
echo "Creating SSH deployment key.."
ssh-keygen -f $keyfile -t ed25519 -C "$description" -N ""
echo
echo "Public key is:"
echo "-----------------------------------------------------"
cat $keyfile.pub
echo "-----------------------------------------------------"
echo -n "Please make sure that key is set up at your git hosting and press enter.."
read
}
function reuseSSHKey(){
# pastes ssh key to file $1 with vim
local keyfile=$1
local scratch=$(mktemp)
echo "# Please paste private ssh key here and save this file" > $scratch
vim $scratch
sed -e 's/#.*$//' $scratch > $keyfile
rm $scratch
echo "Checking key..."
chmod 0700 $keyfile
ssh-keygen -y -f $keyfile -P "" || true # will fail in the end, so script will continue and clean up the mess
}
# use ssh config?
echo -n "Would you like to use SSH auth? ([C]reate new key/[U]se existing key/[N]o) [C/u/n]: "
read read_ssh
[ -n "$read_ssh" ] || read_ssh=C
[[ "$read_ssh" =~ ^[CcUuNn]$ ]] || die "Invalid SSH key option, script is exiting now.."
# ssh resolutions?
# create dir if needed
[[ "$read_ssh" =~ ^[nN]$ ]] || mkdir -p $root/config/auth/ssh
# generate new key
if [[ "$read_ssh" =~ ^[Cc]$ ]]
then
# create key
generateSSHKey $root/config/auth/ssh "cloner-deploy-key-$read_project_name"
fi
# use existing key
if [[ "$read_ssh" =~ ^[Uu]$ ]]
then
# load key
reuseSSHKey $root/config/auth/ssh/identity
fi
echo "First run - initialization of repos..."
if ! env BASE=$root run-checker
then
@@ -76,7 +11,7 @@ then
rm -Rf $root
fi
else
createDetectorConfig $root/config/detector.cfg
echo "Setup has finished!"
touch $root/.enabled
fi