Source Update

This commit is contained in:
Christer Warén
2024-05-01 02:52:21 +03:00
parent cb76cbd190
commit 7765af850a
10 changed files with 37 additions and 206 deletions

View File

@ -1,7 +1,5 @@
wx-login(){
echo -n "$wxItalic"
echo " >> Login << "
echo -n "$wxNormal";
echo "------------------------------"
ORG=$1
@ -22,11 +20,7 @@ wx-login(){
ORG=cwchristerw
elif [[ -z $ORG ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Organization Required"
echo -n $wxNormal
echo -n "Status: Organization Required"
wx-stop
fi
@ -40,11 +34,7 @@ wx-login(){
then
DOMAIN=christerwaren.fi
else
echo -n "Status: "
echo -n $wxItalic
echo -n "Organization Unsupported"
echo -n $wxNormal
echo -n "Status: Organization Unsupported"
wx-stop
fi
@ -61,11 +51,7 @@ wx-login(){
then
HOSTNAME="$2.$DEVICE_DOMAIN"
else
echo -n "Status: "
echo -n $wxItalic
echo -n "Hostname Required"
echo -n $wxNormal
echo -n "Status: Hostname Required"
wx-stop
fi
@ -75,11 +61,7 @@ wx-login(){
then
if [[ -z LOGNAME ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Username Required"
echo -n $wxNormal
echo -n "Status: Username Required"
wx-stop
else
USER=$LOGNAME
@ -100,19 +82,13 @@ wx-login(){
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} == 95 ]]
then
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo $wxBold$ORG$wxNormal
echo -n "Username: "
echo -n $wxItalic
echo -n $(curl https://$VAULT_DOMAIN/v1/auth/token/lookup-self -X GET --header "X-Vault-Token: $VAULT_LOGIN" -s | jq -r '.data.meta.username')
echo $wxNormal
echo -n "Token: "
echo -n $wxItalic
echo -n "****************"
echo $wxNormal
echo "****************"
config[${ORG}]=$VAULT_LOGIN
echo '{ "'$ORG'": "'$VAULT_LOGIN'" }' | jq > $HOME/.config/warengroup/login.json
@ -122,47 +98,30 @@ wx-login(){
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
if [[ $IDM_STATUS -eq 301 ]]
then
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo $wxBold$ORG$wxNormal
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
then
echo -n "Username: "
echo -n $wxItalic
read USERNAME
echo -n $wxNormal
else
echo -n "Username: "
echo -n $wxItalic
echo -n $USER
echo $wxNormal
echo "Username: $USER"
USERNAME=$USER
fi
echo -n "Password: "
echo -n $wxItalic
read -s PASSWORD
echo -n "****************"
echo $wxNormal
echo "****************"
if [[ -z $USERNAME || -z $PASSWORD ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Username & Password Required"
echo -n $wxNormal
echo -n "Status: Username & Password Required"
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
echo -n "Status: Login Failed"
wx-stop
fi
@ -176,9 +135,7 @@ wx-login(){
wx-start
fi
else
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo $wxBold$ORG$wxNormal
echo -n "Token: "
read -s TOKEN
@ -186,22 +143,14 @@ wx-login(){
if [[ -z $TOKEN || ${#TOKEN} -lt 95 || ${#TOKEN} -gt 95 ]]
then
echo -n "Status: "
echo -n $wxItalic
echo -n "Vault Token Required"
echo -n $wxNormal
echo -n "Status: Vault Token Required"
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
echo -n "Status: Login Failed"
wx-stop
fi
@ -216,15 +165,9 @@ wx-login(){
fi
fi
else
echo -n $wxBold
echo -n $ORG
echo $wxNormal
echo -n "Status: "
echo -n $wxItalic
echo -n "Vault Offline"
echo -n $wxNormal
echo $wxBold$ORG$wxNormal
echo -n "Status: Vault Offline"
wx-stop
fi
}