Source Update

This commit is contained in:
Christer Warén 2024-04-27 21:13:32 +03:00
parent 56b6f58f4e
commit ee152b0562
5 changed files with 24 additions and 38 deletions

View File

@ -5,7 +5,6 @@ if [ ! "$BASH_VERSION" ] ; then
exit 1
fi
{{ ELEMENTS }}
{{ FUNCTIONS }}
{{ COMMANDS }}

View File

@ -1,6 +0,0 @@
wx-elements-line-douple () {
echo "=============================="
}
wx-elements-line-single () {
echo "------------------------------"
}

View File

@ -3,7 +3,7 @@ wx-login() {
ORG=$2
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then
stop
wx-stop
fi
if [[ $(hostname -d) == "devices.waren.io" ]]
@ -18,7 +18,7 @@ wx-login() {
elif [[ -z $ORG ]]
then
echo "Organization: Required"
stop
wx-stop
fi
if [[ $ORG == "warengroup" ]]
@ -32,7 +32,7 @@ wx-login() {
DOMAIN=christerwaren.fi
else
echo "Organization: Unsupported"
stop
wx-stop
fi
FOLDER=$ORG
@ -49,7 +49,7 @@ wx-login() {
HOSTNAME="$2.$DEVICE_DOMAIN"
else
echo "Hostname: Required"
stop
wx-stop
fi
if [[ -z $USER ]]
@ -59,7 +59,7 @@ wx-login() {
if [[ -z LOGNAME ]]
then
echo "Username: Required"
stop
wx-stop
else
USER=$LOGNAME
fi
@ -90,18 +90,18 @@ wx-login() {
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
echo "Status: Login Failed"
stop
wx-stop
fi
echo ""
else
echo "Organization: $ORG"
echo "Status: IDM Offline"
stop
wx-stop
fi
else
echo "Organization: $ORG"
echo "Status: Vault Offline"
stop
wx-stop
fi
@ -120,7 +120,7 @@ wx-login() {
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
# echo ""
# if [[ -z $VAULT_LOGIN ]]; then
stop
# wx-stop
# fi
# else
# echo "vault.$DOMAIN - Login"
@ -129,7 +129,7 @@ wx-login() {
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null)
# echo ""
# if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then
# stop
# wx-stop
# fi
# fi
# fi

View File

@ -2,7 +2,7 @@ wx-start() {
echo ""
echo ""
echo ""
wx-elements-line-douple
echo "=============================="
echo "Warén CLI"
wx-elements-line-douple
echo "=============================="
}

31
wx
View File

@ -5,19 +5,12 @@ if [ ! "$BASH_VERSION" ] ; then
exit 1
fi
wx-elements-line-douple () {
echo "=============================="
}
wx-elements-line-single () {
echo "------------------------------"
}
wx-login() {
echo ">>> Login <<<"
ORG=$2
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then
stop
wx-stop
fi
if [[ $(hostname -d) == "devices.waren.io" ]]
@ -32,7 +25,7 @@ wx-login() {
elif [[ -z $ORG ]]
then
echo "Organization: Required"
stop
wx-stop
fi
if [[ $ORG == "warengroup" ]]
@ -46,7 +39,7 @@ wx-login() {
DOMAIN=christerwaren.fi
else
echo "Organization: Unsupported"
stop
wx-stop
fi
FOLDER=$ORG
@ -63,7 +56,7 @@ wx-login() {
HOSTNAME="$2.$DEVICE_DOMAIN"
else
echo "Hostname: Required"
stop
wx-stop
fi
if [[ -z $USER ]]
@ -73,7 +66,7 @@ wx-login() {
if [[ -z LOGNAME ]]
then
echo "Username: Required"
stop
wx-stop
else
USER=$LOGNAME
fi
@ -104,18 +97,18 @@ wx-login() {
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
echo "Status: Login Failed"
stop
wx-stop
fi
echo ""
else
echo "Organization: $ORG"
echo "Status: IDM Offline"
stop
wx-stop
fi
else
echo "Organization: $ORG"
echo "Status: Vault Offline"
stop
wx-stop
fi
@ -134,7 +127,7 @@ wx-login() {
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
# echo ""
# if [[ -z $VAULT_LOGIN ]]; then
stop
# wx-stop
# fi
# else
# echo "vault.$DOMAIN - Login"
@ -143,7 +136,7 @@ wx-login() {
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null)
# echo ""
# if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then
# stop
# wx-stop
# fi
# fi
# fi
@ -160,9 +153,9 @@ wx-start() {
echo ""
echo ""
echo ""
wx-elements-line-douple
echo "=============================="
echo "Warén CLI"
wx-elements-line-douple
echo "=============================="
}
wx-stop () {