Source Update

This commit is contained in:
Christer Warén 2024-04-28 01:19:47 +03:00
parent b2d3908d6f
commit 0da7c1ade1
2 changed files with 186 additions and 106 deletions

View File

@ -21,7 +21,11 @@ wx-login() {
ORG=cwchristerw
elif [[ -z $ORG ]]
then
echo "Organization: Required"
echo -n "Status: "
echo -n $wxItalic
echo -n "Organization Required"
echo -n $wxNormal
wx-stop
fi
@ -35,7 +39,11 @@ wx-login() {
then
DOMAIN=christerwaren.fi
else
echo "Organization: Unsupported"
echo -n "Status: "
echo -n $wxItalic
echo -n "Organization Unsupported"
echo -n $wxNormal
wx-stop
fi
@ -52,7 +60,11 @@ wx-login() {
then
HOSTNAME="$2.$DEVICE_DOMAIN"
else
echo "Hostname: Required"
echo -n "Status: "
echo -n $wxItalic
echo -n "Hostname Required"
echo -n $wxNormal
wx-stop
fi
@ -62,7 +74,11 @@ wx-login() {
then
if [[ -z LOGNAME ]]
then
echo "Username: Required"
echo -n "Status: "
echo -n $wxItalic
echo -n "Username Required"
echo -n $wxNormal
wx-stop
else
USER=$LOGNAME
@ -76,73 +92,97 @@ wx-login() {
if [[ $VAULT_STATUS -eq 200 ]]
then
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
if [[ $IDM_STATUS -eq 301 ]]
if [[ $IDM_STATUS -eq 302 ]]
then
echo "Organization: $ORG"
echo -n $wxBold
echo -n $ORG
echo $wxNormal
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
then
echo -n "Username: "
echo -n $wxItalic
read USERNAME
echo -n $wxNormal
else
echo "Username: $USER"
echo -n "Username: "
echo -n $wxItalic
echo -n $USER
echo $wxNormal
USERNAME=$USER
fi
echo -n "Password: "
echo -n $wxItalic
read -s PASSWORD
echo "****************"
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"
echo -n "****************"
echo $wxNormal
if [[ -z $USERNAME || -z $PASSWORD ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Username & Password Required"
echo -n $wxNormal
wx-stop
else
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 -n "Status: "
echo -n $wxItalic
echo -n "Login Failed"
echo -n $wxNormal
wx-stop
fi
fi
echo ""
wx-start
else
echo "Organization: $ORG"
echo "Status: IDM Offline"
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo -n "Token: "
read -s TOKEN
echo "****************"
if [[ -z $TOKEN || ${#TOKEN} -lt 95 || ${#TOKEN} -gt 95 ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Vault Token Required"
echo -n $wxNormal
wx-stop
fi
VAULT_LOGIN=$(curl https://$VAULT_DOMAIN/v1/auth/token/renew -X POST --header "X-Vault-Token: $TOKEN" -d '{ "token": "'$TOKEN'" }' -s | jq -r '.auth.client_token')
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Login Failed"
echo -n $wxNormal
wx-stop
fi
wx-start
fi
else
echo "Organization: $ORG"
echo "Status: Vault Offline"
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo -n "Status: "
echo -n $wxItalic
echo -n "Vault Offline"
echo -n $wxNormal
wx-stop
fi
# VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://vault.$DOMAIN/v1/sys/health)
# if [[ $VAULT_STATUS -eq 200 ]]; then
# export VAULT_ADDR="https://vault.$DOMAIN"
# VAULT_LOGIN=$(vault token lookup -address=https://vault.$DOMAIN 2> /dev/null)
# if [[ -z $VAULT_LOGIN ]]; then
# IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://idm.$DOMAIN)
# if [[ $IDM_STATUS -eq 301 ]]; then
# echo "vault.$DOMAIN - Login"
# echo "Username: $USER"
# echo -n "Password: "
# export VAULT_ADDR="https://vault.$DOMAIN"
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
# echo ""
# if [[ -z $VAULT_LOGIN ]]; then
# wx-stop
# fi
# else
# echo "vault.$DOMAIN - Login"
# echo -n "Token: "
# export VAULT_ADDR="https://vault.$DOMAIN"
# 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
# wx-stop
# fi
# fi
# fi
# fi
# if [[ $USER == "root" || $USER == "local" ]]
# then
# echo "Status: Login Failed"
# fi
}

144
wx
View File

@ -41,7 +41,11 @@ wx-login() {
ORG=cwchristerw
elif [[ -z $ORG ]]
then
echo "Organization: Required"
echo -n "Status: "
echo -n $wxItalic
echo -n "Organization Required"
echo -n $wxNormal
wx-stop
fi
@ -55,7 +59,11 @@ wx-login() {
then
DOMAIN=christerwaren.fi
else
echo "Organization: Unsupported"
echo -n "Status: "
echo -n $wxItalic
echo -n "Organization Unsupported"
echo -n $wxNormal
wx-stop
fi
@ -72,7 +80,11 @@ wx-login() {
then
HOSTNAME="$2.$DEVICE_DOMAIN"
else
echo "Hostname: Required"
echo -n "Status: "
echo -n $wxItalic
echo -n "Hostname Required"
echo -n $wxNormal
wx-stop
fi
@ -82,7 +94,11 @@ wx-login() {
then
if [[ -z LOGNAME ]]
then
echo "Username: Required"
echo -n "Status: "
echo -n $wxItalic
echo -n "Username Required"
echo -n $wxNormal
wx-stop
else
USER=$LOGNAME
@ -96,75 +112,99 @@ wx-login() {
if [[ $VAULT_STATUS -eq 200 ]]
then
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
if [[ $IDM_STATUS -eq 301 ]]
if [[ $IDM_STATUS -eq 302 ]]
then
echo "Organization: $ORG"
echo -n $wxBold
echo -n $ORG
echo $wxNormal
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
then
echo -n "Username: "
echo -n $wxItalic
read USERNAME
echo -n $wxNormal
else
echo "Username: $USER"
echo -n "Username: "
echo -n $wxItalic
echo -n $USER
echo $wxNormal
USERNAME=$USER
fi
echo -n "Password: "
echo -n $wxItalic
read -s PASSWORD
echo "****************"
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"
echo -n "****************"
echo $wxNormal
if [[ -z $USERNAME || -z $PASSWORD ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Username & Password Required"
echo -n $wxNormal
wx-stop
else
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 -n "Status: "
echo -n $wxItalic
echo -n "Login Failed"
echo -n $wxNormal
wx-stop
fi
fi
echo ""
echo $VAULT_LOGIN
wx-start
else
echo "Organization: $ORG"
echo "Status: IDM Offline"
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo -n "Token: "
read -s TOKEN
echo "****************"
if [[ -z $TOKEN || ${#TOKEN} -lt 95 || ${#TOKEN} -gt 95 ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Vault Token Required"
echo -n $wxNormal
wx-stop
fi
VAULT_LOGIN=$(curl https://$VAULT_DOMAIN/v1/auth/token/renew -X POST --header "X-Vault-Token: $TOKEN" -d '{ "token": "'$TOKEN'" }' -s | jq -r '.auth.client_token')
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Login Failed"
echo -n $wxNormal
wx-stop
fi
wx-start
fi
else
echo "Organization: $ORG"
echo "Status: Vault Offline"
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo -n "Status: "
echo -n $wxItalic
echo -n "Vault Offline"
echo -n $wxNormal
wx-stop
fi
# VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://vault.$DOMAIN/v1/sys/health)
# if [[ $VAULT_STATUS -eq 200 ]]; then
# export VAULT_ADDR="https://vault.$DOMAIN"
# VAULT_LOGIN=$(vault token lookup -address=https://vault.$DOMAIN 2> /dev/null)
# if [[ -z $VAULT_LOGIN ]]; then
# IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://idm.$DOMAIN)
# if [[ $IDM_STATUS -eq 301 ]]; then
# echo "vault.$DOMAIN - Login"
# echo "Username: $USER"
# echo -n "Password: "
# export VAULT_ADDR="https://vault.$DOMAIN"
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
# echo ""
# if [[ -z $VAULT_LOGIN ]]; then
# wx-stop
# fi
# else
# echo "vault.$DOMAIN - Login"
# echo -n "Token: "
# export VAULT_ADDR="https://vault.$DOMAIN"
# 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
# wx-stop
# fi
# fi
# fi
# fi
# if [[ $USER == "root" || $USER == "local" ]]
# then
# echo "Status: Login Failed"
# fi
}
wx-start() {