Build Update

This commit is contained in:
Christer Warén 2024-04-27 20:08:43 +03:00
parent 3daa8a84dc
commit 9f0df0dbdf

96
wx
View File

@ -5,25 +5,14 @@ if [ ! "$BASH_VERSION" ] ; then
exit 1 exit 1
fi fi
syntax-line-douple() { wx-elements-line-douple () {
echo -n " echo "=============================="
============================== }
" wx-elements-line-single () {
echo "------------------------------"
} }
syntax-line-single() { wx-login() {
echo -n "
------------------------------
"
}
start() {
syntax-line-douple
echo -n "Warén CLI "
syntax-line-douple
}
login() {
echo ">>> Login <<<" echo ">>> Login <<<"
ORG=$2 ORG=$2
@ -43,7 +32,7 @@ login() {
elif [[ -z $ORG ]] elif [[ -z $ORG ]]
then then
echo "Organization: Required" echo "Organization: Required"
exit 1 stop
fi fi
if [[ $ORG == "warengroup" ]] if [[ $ORG == "warengroup" ]]
@ -57,7 +46,7 @@ login() {
DOMAIN=christerwaren.fi DOMAIN=christerwaren.fi
else else
echo "Organization: Unsupported" echo "Organization: Unsupported"
exit 1 stop
fi fi
FOLDER=$ORG FOLDER=$ORG
@ -74,7 +63,7 @@ login() {
HOSTNAME="$2.$DEVICE_DOMAIN" HOSTNAME="$2.$DEVICE_DOMAIN"
else else
echo "Hostname: Required" echo "Hostname: Required"
exit 1 stop
fi fi
if [[ -z $USER ]] if [[ -z $USER ]]
@ -84,7 +73,7 @@ login() {
if [[ -z LOGNAME ]] if [[ -z LOGNAME ]]
then then
echo "Username: Required" echo "Username: Required"
exit 1 stop
else else
USER=$LOGNAME USER=$LOGNAME
fi fi
@ -111,21 +100,22 @@ login() {
echo -n "Password: " echo -n "Password: "
read -s PASSWORD read -s PASSWORD
echo -n "****************" echo "****************"
VAULT_LOGIN=$(curl https://$VAULT_DOMAIN/v1/auth/ldap/login/$USERNAME -X POST -d '{ "password": "'$PASSWORD'" }' -s | jq -r '.auth.client_token') VAULT_LOGIN=$(curl https://$VAULT_DOMAIN/v1/auth/ldap/login/$USERNAME -X POST -d '{ "password": "'$PASSWORD'" }' -s | jq -r '.auth.client_token')
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]; then if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]; then
echo "Status: Login Failed" echo "Status: Login Failed"
exit 1 stop
fi fi
echo ""
else else
echo "Organization: $ORG" echo "Organization: $ORG"
echo "Status: IDM Offline" echo "Status: IDM Offline"
exit 1 stop
fi fi
else else
echo "Organization: $ORG" echo "Organization: $ORG"
echo "Status: Vault Offline" echo "Status: Vault Offline"
exit 1 stop
fi fi
@ -144,7 +134,7 @@ login() {
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null) # VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
# echo "" # echo ""
# if [[ -z $VAULT_LOGIN ]]; then # if [[ -z $VAULT_LOGIN ]]; then
# exit 1 stop
# fi # fi
# else # else
# echo "vault.$DOMAIN - Login" # echo "vault.$DOMAIN - Login"
@ -153,7 +143,7 @@ login() {
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null) # VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null)
# echo "" # echo ""
# if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then # if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then
# exit 1 # stop
# fi # fi
# fi # fi
# fi # fi
@ -164,10 +154,21 @@ login() {
# then # then
# echo "Status: Login Failed" # echo "Status: Login Failed"
# fi # fi
start
} }
stop () { wx-start() {
echo ""
echo ""
echo ""
wx-elements-line-douple
echo "Warén CLI"
wx-elements-line-douple
}
wx-stop () {
echo " "
echo " "
echo " "
if [[ -d "./src" ]] if [[ -d "./src" ]]
then then
podman run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp docker.io/library/php:8-cli php generator.php &> /dev/null podman run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp docker.io/library/php:8-cli php generator.php &> /dev/null
@ -181,12 +182,11 @@ stop () {
fi fi
sudo chmod +x /usr/bin/wx &> /dev/null sudo chmod +x /usr/bin/wx &> /dev/null
fi fi
echo " "
echo " "
exit 1 exit 1
} }
warencli-help() { wx-help() {
echo -n ">>> Help <<<";
echo " echo "
Usage: $0 COMMAND [OPTIONS] Usage: $0 COMMAND [OPTIONS]
@ -200,26 +200,34 @@ Management Commands:
"; ";
} }
warencli-settings() { wx-settings() {
echo ">>> Settings <<<"; echo -n ">>> Settings <<<";
} }
warencli-ssh() { wx-ssh() {
echo ">>> SSH <<<"; echo -n ">>> SSH <<<";
} }
warencli-ssh-config(){ wx-welcome() {
echo ">>> SSH: Config <<<" echo -n ">>> Welcome <<<"
} }
warencli-ssh-sign(){ wx-ssh-config(){
echo ">>> SSH: Certificates <<<" echo -n ">>> SSH: Config <<<"
}
wx-ssh-sign(){
echo -n ">>> SSH: Certificates <<<"
} }
start wx-start
if [[ ! -z $1 ]] && [[ $(type -t warencli-$1) == function ]] if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then then
warencli-$1 $2 $3 $4 $5 $6 $7 $8 $9 wx-login
wx-start
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
else
wx-welcome
fi fi
stop wx-stop