Upclapi/bin/make_kenv.sh
2021-08-28 14:45:05 +01:00

24 lines
700 B
Bash
Executable File

#!/bin/bash
# tecoder --fencrypt _datacfg.yaml > kdata.yaml
#
ENCODER="/usr/local/bin/tecoder"
ARGSENCODER="-e"
SOURCE_ENV=".env"
TARGET_ENV=".envk"
[ ! -r "$SOURCE_ENV" ] && echo "File $SOURCE_ENV not found" && exit 1
USER=$(grep "USER" $SOURCE_ENV | cut -f2 -d"=")
[ -z "$USER" ] && echo "User is empty" && exit 1
PASSWRD=$(grep "PASSWORD" $SOURCE_ENV | cut -f2 -d"=")
[ -z "$PASSWRD" ] && echo "Password is empty" && exit 1
kuser=$($ENCODER $ARGSENCODER $USER)
[ -z "$kuser" ] && echo "Unable to encode User" && exit 1
kpasswdr=$($ENCODER $ARGSENCODER $PASSWRD)
[ -z "$kpasswdr" ] && echo "Unable to encode Password" && exit 1
echo "export KUPCLAPI=\"$kuser $kpasswdr\"" > $TARGET_ENV