Compare commits

..

No commits in common. "ca14cb19886d166f011c02cc8155c54be91a308b" and "0ef3f8d8d6dc8ab82ebf1cbfc98567ca51de9d1e" have entirely different histories.

19 changed files with 132 additions and 210 deletions

View File

@ -1,13 +0,0 @@
#!/bin/bash
if [ ! "$BASH_VERSION" ] ; then
bash $0 $1 $2 $3 $4 $5 $6 $7 $8 $9
exit 1
fi
if [[ -f "./wx" ]] && [[ -d "./src" ]]
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
mv wx.tmp wx &> /dev/null
chmod +x wx &> /dev/null
fi

View File

@ -22,6 +22,7 @@ declare -Ax config
{{ FUNCTIONS }} {{ FUNCTIONS }}
{{ COMMANDS }} {{ COMMANDS }}
wx-start
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]] if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then then
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9 wx-$1 $2 $3 $4 $5 $6 $7 $8 $9

View File

@ -1,6 +1,8 @@
wx-auto(){ wx-auto(){
wx-login wx-login
wx-header "Auto"
echo " >> Auto << "
echo "------------------------------"
wx-ssh-config-sync wx-ssh-config-sync
wx-ssh-keys-sync wx-ssh-keys-sync

View File

@ -1,6 +1,7 @@
wx-help(){ wx-help(){
wx-header "Help" echo " >> Help << "
echo "------------------------------"
echo -n " echo -n "
Usage: $0 COMMAND [OPTIONS] Usage: $0 COMMAND [OPTIONS]
@ -20,13 +21,9 @@ Common Commands:
sync Sync sync Sync
sign Certificates sign Certificates
Authentication Commands:
login Login
logout Logout
Management Commands: Management Commands:
auto Auto auto Auto
install Install login Login
settings Settings settings Settings
"; ";

View File

@ -2,8 +2,8 @@ wx-infra(){
wx-login wx-login
wx-ssh-sign &> /dev/null wx-ssh-sign &> /dev/null
wx-header "Infra" echo " >> Infra << "
wx-restricted echo "------------------------------"
INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra" INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"

View File

@ -1,19 +0,0 @@
wx-install(){
if [[ -z $1 ]]
then
wx-header "Install"
fi
wx-restricted
if [[ -f "./wx" ]] && [[ -d "./src" ]]
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
mv wx.tmp wx &> /dev/null
chmod +x wx &> /dev/null
fi
mkdir $HOME/bin &> /dev/null
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
chmod +x $HOME/bin/wx &> /dev/null
}

View File

@ -3,7 +3,9 @@ wx-login(){
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]] if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]
then then
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Hostname Required" echo "Status: Hostname Required"
wx-stop wx-stop
fi fi
@ -21,7 +23,9 @@ wx-login(){
then then
ORG=cwchristerw ORG=cwchristerw
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Organization Required" echo "Status: Organization Required"
wx-stop wx-stop
fi fi
@ -36,7 +40,9 @@ wx-login(){
then then
DOMAIN=christerwaren.fi DOMAIN=christerwaren.fi
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Organization Unsupported" echo "Status: Organization Unsupported"
wx-stop wx-stop
fi fi
@ -53,7 +59,9 @@ wx-login(){
then then
HOSTNAME=$(hostname --fqdn) HOSTNAME=$(hostname --fqdn)
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Hostname Required" echo "Status: Hostname Required"
wx-stop wx-stop
fi fi
@ -64,7 +72,9 @@ wx-login(){
then then
if [[ -z LOGNAME ]] if [[ -z LOGNAME ]]
then then
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Username Required" echo "Status: Username Required"
wx-stop wx-stop
else else
@ -78,8 +88,7 @@ wx-login(){
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/sys/health) VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/sys/health)
if [[ $VAULT_STATUS -eq 200 ]] if [[ $VAULT_STATUS -eq 200 ]]
then then
if [[ -f "$HOME/.config/warengroup/config.json" ]]
if [[ $USER != "root" && $USER != "local" && -f "$HOME/.config/warengroup/config.json" ]]
then then
TOKEN="$(cat $HOME/.config/warengroup/config.json | jq -r .login.$ORG)" TOKEN="$(cat $HOME/.config/warengroup/config.json | jq -r .login.$ORG)"
fi fi
@ -88,16 +97,15 @@ wx-login(){
if [[ ! -z $VAULT_LOGIN && ${#VAULT_LOGIN} == 95 ]] if [[ ! -z $VAULT_LOGIN && ${#VAULT_LOGIN} == 95 ]]
then then
config["login",${ORG}]=$VAULT_LOGIN config["login",${ORG}]=$VAULT_LOGIN
if [[ $USER != "root" && $USER != "local" ]]
then
jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
fi
else else
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN) IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
if [[ $IDM_STATUS -eq 301 ]] if [[ $IDM_STATUS -eq 301 ]]
then then
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo $wxBold$ORG$wxNormal echo $wxBold$ORG$wxNormal
if [[ -z $USERNAME || $USERNAME == "root" || $USERNAME == "local" ]] if [[ -z $USERNAME || $USERNAME == "root" || $USERNAME == "local" ]]
@ -125,17 +133,15 @@ wx-login(){
fi fi
config["login",${ORG}]=$VAULT_LOGIN config["login",${ORG}]=$VAULT_LOGIN
if [[ $USER != "root" && $USER != "local" ]]
then
jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
fi
wx-start wx-start
fi fi
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo $wxBold$ORG$wxNormal echo $wxBold$ORG$wxNormal
echo -n "Token: " echo -n "Token: "
@ -156,19 +162,18 @@ wx-login(){
fi fi
config["login",${ORG}]=$VAULT_LOGIN config["login",${ORG}]=$VAULT_LOGIN
if [[ $USER != "root" && $USER != "local" ]]
then
jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
fi
wx-start wx-start
fi fi
fi fi
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo $wxBold$ORG$wxNormal echo $wxBold$ORG$wxNormal
echo "Status: Vault Offline" echo "Status: Vault Offline"
wx-stop wx-stop
fi fi

View File

@ -1,3 +0,0 @@
wx-logout(){
wx-header "Logout"
}

View File

@ -1,4 +1,6 @@
wx-settings(){ wx-settings(){
wx-login wx-login
wx-header "Settings"
echo " >> Settings << "
echo "------------------------------"
} }

View File

@ -15,7 +15,8 @@ wx-ssh(){
wx-ssh-config $2 wx-ssh-config $2
;; ;;
*) *)
wx-header "SSH" echo " >> SSH << "
echo "------------------------------"
wx-stop wx-stop
;; ;;

View File

@ -1,6 +1,6 @@
wx-ssh-config(){ wx-ssh-config(){
wx-header "SSH / Config" echo " >> SSH / Config << "
wx-restricted echo "------------------------------"
case $1 in case $1 in
edit) edit)
@ -22,17 +22,14 @@ wx-ssh-config(){
} }
wx-ssh-config-edit(){ wx-ssh-config-edit(){
wx-restricted
nano ~/.ssh/config nano ~/.ssh/config
} }
wx-ssh-config-save(){ wx-ssh-config-save(){
wx-restricted
curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
} }
wx-ssh-config-sync(){ wx-ssh-config-sync(){
wx-restricted
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}") VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
if [[ $VAULT_STATUS -eq 200 ]] if [[ $VAULT_STATUS -eq 200 ]]
then then

View File

@ -1,5 +1,6 @@
wx-ssh-keys(){ wx-ssh-keys(){
wx-header "SSH / Keys" echo " >> SSH / Keys << "
echo "------------------------------"
case $1 in case $1 in
generate) generate)
@ -27,7 +28,6 @@ wx-ssh-keys(){
} }
wx-ssh-keys-generate(){ wx-ssh-keys-generate(){
wx-restricted
if [[ ! -z $1 ]] if [[ ! -z $1 ]]
then then
if [[ ! -f "$HOME/.ssh/keys/$1" ]] if [[ ! -f "$HOME/.ssh/keys/$1" ]]
@ -38,7 +38,6 @@ wx-ssh-keys-generate(){
} }
wx-ssh-keys-retrieve(){ wx-ssh-keys-retrieve(){
wx-restricted
if [[ ! -z $1 ]] if [[ ! -z $1 ]]
then then
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}") VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
@ -51,7 +50,6 @@ wx-ssh-keys-retrieve(){
} }
wx-ssh-keys-save(){ wx-ssh-keys-save(){
wx-restricted
if [[ ! -z $1 ]] if [[ ! -z $1 ]]
then then
if [[ -f "$HOME/.ssh/keys/$1" ]] if [[ -f "$HOME/.ssh/keys/$1" ]]
@ -62,6 +60,5 @@ wx-ssh-keys-save(){
} }
wx-ssh-keys-sync(){ wx-ssh-keys-sync(){
wx-restricted
echo "" echo ""
} }

View File

@ -1,6 +1,6 @@
wx-ssh-sign(){ wx-ssh-sign(){
wx-header "SSH / Sign" echo " >> SSH / Sign << "
wx-restricted echo "------------------------------"
if [[ $ORG == "warengroup" ]] if [[ $ORG == "warengroup" ]]
then then
@ -17,8 +17,6 @@ wx-ssh-sign(){
} }
wx-ssh-sign-create(){ wx-ssh-sign-create(){
wx-restricted
NAME=$1 NAME=$1
ROLE=$2 ROLE=$2
PRINCIPALS=$2 PRINCIPALS=$2

View File

@ -1,4 +0,0 @@
wx-update(){
wx-header "Update"
wx-install --update
}

View File

@ -1,3 +1,4 @@
wx-welcome(){ wx-welcome(){
wx-header "Welcome" echo " >> Welcome << "
echo "------------------------------"
} }

View File

@ -1,6 +0,0 @@
wx-header(){
wx-start
echo ">> $1 <<"
echo "------------------------------"
}

View File

@ -1,10 +0,0 @@
wx-restricted(){
if [[ $USER == "root" || $USER == "local" ]]
then
echo "Status: Command Restricted"
echo " "
echo " "
echo " "
exit 1
fi
}

View File

@ -2,8 +2,19 @@ wx-stop (){
echo " " echo " "
echo " " echo " "
echo " " echo " "
if [[ -f "./wx" ]] && [[ -d "./src" ]]
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
mv wx.tmp wx &> /dev/null
chmod +x wx &> /dev/null
fi
wx-install --auto if [[ $USER != "root" && $USER != "local" ]]
then
mkdir $HOME/bin &> /dev/null
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
chmod +x $HOME/bin/wx &> /dev/null
fi
exit 1 exit 1
} }

155
wx
View File

@ -19,24 +19,6 @@ wxNormal=$(tput sgr0)
declare -Ax config declare -Ax config
wx-header(){
wx-start
echo ">> $1 <<"
echo "------------------------------"
}
wx-restricted(){
if [[ $USER == "root" || $USER == "local" ]]
then
echo "Status: Command Restricted"
echo " "
echo " "
echo " "
exit 1
fi
}
wx-start(){ wx-start(){
echo "" echo ""
echo "" echo ""
@ -59,15 +41,28 @@ wx-stop (){
echo " " echo " "
echo " " echo " "
echo " " echo " "
if [[ -f "./wx" ]] && [[ -d "./src" ]]
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
mv wx.tmp wx &> /dev/null
chmod +x wx &> /dev/null
fi
wx-install --auto if [[ $USER != "root" && $USER != "local" ]]
then
mkdir $HOME/bin &> /dev/null
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
chmod +x $HOME/bin/wx &> /dev/null
fi
exit 1 exit 1
} }
wx-auto(){ wx-auto(){
wx-login wx-login
wx-header "Auto"
echo " >> Auto << "
echo "------------------------------"
wx-ssh-config-sync wx-ssh-config-sync
wx-ssh-keys-sync wx-ssh-keys-sync
@ -76,7 +71,8 @@ wx-auto(){
wx-help(){ wx-help(){
wx-header "Help" echo " >> Help << "
echo "------------------------------"
echo -n " echo -n "
Usage: $0 COMMAND [OPTIONS] Usage: $0 COMMAND [OPTIONS]
@ -96,13 +92,9 @@ Common Commands:
sync Sync sync Sync
sign Certificates sign Certificates
Authentication Commands:
login Login
logout Logout
Management Commands: Management Commands:
auto Auto auto Auto
install Install login Login
settings Settings settings Settings
"; ";
@ -112,8 +104,8 @@ wx-infra(){
wx-login wx-login
wx-ssh-sign &> /dev/null wx-ssh-sign &> /dev/null
wx-header "Infra" echo " >> Infra << "
wx-restricted echo "------------------------------"
INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra" INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
@ -146,32 +138,14 @@ wx-infra(){
esac esac
} }
wx-install(){
if [[ -z $1 ]]
then
wx-header "Install"
fi
wx-restricted
if [[ -f "./wx" ]] && [[ -d "./src" ]]
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
mv wx.tmp wx &> /dev/null
chmod +x wx &> /dev/null
fi
mkdir $HOME/bin &> /dev/null
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
chmod +x $HOME/bin/wx &> /dev/null
}
wx-login(){ wx-login(){
ORG=$1 ORG=$1
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]] if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]
then then
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Hostname Required" echo "Status: Hostname Required"
wx-stop wx-stop
fi fi
@ -189,7 +163,9 @@ wx-login(){
then then
ORG=cwchristerw ORG=cwchristerw
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Organization Required" echo "Status: Organization Required"
wx-stop wx-stop
fi fi
@ -204,7 +180,9 @@ wx-login(){
then then
DOMAIN=christerwaren.fi DOMAIN=christerwaren.fi
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Organization Unsupported" echo "Status: Organization Unsupported"
wx-stop wx-stop
fi fi
@ -221,7 +199,9 @@ wx-login(){
then then
HOSTNAME=$(hostname --fqdn) HOSTNAME=$(hostname --fqdn)
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Hostname Required" echo "Status: Hostname Required"
wx-stop wx-stop
fi fi
@ -232,7 +212,9 @@ wx-login(){
then then
if [[ -z LOGNAME ]] if [[ -z LOGNAME ]]
then then
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo "Status: Username Required" echo "Status: Username Required"
wx-stop wx-stop
else else
@ -246,8 +228,7 @@ wx-login(){
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/sys/health) VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/sys/health)
if [[ $VAULT_STATUS -eq 200 ]] if [[ $VAULT_STATUS -eq 200 ]]
then then
if [[ -f "$HOME/.config/warengroup/config.json" ]]
if [[ $USER != "root" && $USER != "local" && -f "$HOME/.config/warengroup/config.json" ]]
then then
TOKEN="$(cat $HOME/.config/warengroup/config.json | jq -r .login.$ORG)" TOKEN="$(cat $HOME/.config/warengroup/config.json | jq -r .login.$ORG)"
fi fi
@ -256,16 +237,15 @@ wx-login(){
if [[ ! -z $VAULT_LOGIN && ${#VAULT_LOGIN} == 95 ]] if [[ ! -z $VAULT_LOGIN && ${#VAULT_LOGIN} == 95 ]]
then then
config["login",${ORG}]=$VAULT_LOGIN config["login",${ORG}]=$VAULT_LOGIN
if [[ $USER != "root" && $USER != "local" ]]
then
jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
fi
else else
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN) IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
if [[ $IDM_STATUS -eq 301 ]] if [[ $IDM_STATUS -eq 301 ]]
then then
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo $wxBold$ORG$wxNormal echo $wxBold$ORG$wxNormal
if [[ -z $USERNAME || $USERNAME == "root" || $USERNAME == "local" ]] if [[ -z $USERNAME || $USERNAME == "root" || $USERNAME == "local" ]]
@ -293,17 +273,15 @@ wx-login(){
fi fi
config["login",${ORG}]=$VAULT_LOGIN config["login",${ORG}]=$VAULT_LOGIN
if [[ $USER != "root" && $USER != "local" ]]
then
jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
fi
wx-start wx-start
fi fi
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo $wxBold$ORG$wxNormal echo $wxBold$ORG$wxNormal
echo -n "Token: " echo -n "Token: "
@ -324,31 +302,28 @@ wx-login(){
fi fi
config["login",${ORG}]=$VAULT_LOGIN config["login",${ORG}]=$VAULT_LOGIN
if [[ $USER != "root" && $USER != "local" ]]
then
jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
fi
wx-start wx-start
fi fi
fi fi
else else
wx-header "Login" echo " >> Login << "
echo "------------------------------"
echo $wxBold$ORG$wxNormal echo $wxBold$ORG$wxNormal
echo "Status: Vault Offline" echo "Status: Vault Offline"
wx-stop wx-stop
fi fi
} }
wx-logout(){
wx-header "Logout"
}
wx-settings(){ wx-settings(){
wx-login wx-login
wx-header "Settings"
echo " >> Settings << "
echo "------------------------------"
} }
wx-ssh(){ wx-ssh(){
@ -368,25 +343,22 @@ wx-ssh(){
wx-ssh-config $2 wx-ssh-config $2
;; ;;
*) *)
wx-header "SSH" echo " >> SSH << "
echo "------------------------------"
wx-stop wx-stop
;; ;;
esac esac
} }
wx-update(){
wx-header "Update"
wx-install --update
}
wx-welcome(){ wx-welcome(){
wx-header "Welcome" echo " >> Welcome << "
echo "------------------------------"
} }
wx-ssh-config(){ wx-ssh-config(){
wx-header "SSH / Config" echo " >> SSH / Config << "
wx-restricted echo "------------------------------"
case $1 in case $1 in
edit) edit)
@ -408,17 +380,14 @@ wx-ssh-config(){
} }
wx-ssh-config-edit(){ wx-ssh-config-edit(){
wx-restricted
nano ~/.ssh/config nano ~/.ssh/config
} }
wx-ssh-config-save(){ wx-ssh-config-save(){
wx-restricted
curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
} }
wx-ssh-config-sync(){ wx-ssh-config-sync(){
wx-restricted
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}") VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
if [[ $VAULT_STATUS -eq 200 ]] if [[ $VAULT_STATUS -eq 200 ]]
then then
@ -427,7 +396,8 @@ wx-ssh-config-sync(){
} }
wx-ssh-keys(){ wx-ssh-keys(){
wx-header "SSH / Keys" echo " >> SSH / Keys << "
echo "------------------------------"
case $1 in case $1 in
generate) generate)
@ -455,7 +425,6 @@ wx-ssh-keys(){
} }
wx-ssh-keys-generate(){ wx-ssh-keys-generate(){
wx-restricted
if [[ ! -z $1 ]] if [[ ! -z $1 ]]
then then
if [[ ! -f "$HOME/.ssh/keys/$1" ]] if [[ ! -f "$HOME/.ssh/keys/$1" ]]
@ -466,7 +435,6 @@ wx-ssh-keys-generate(){
} }
wx-ssh-keys-retrieve(){ wx-ssh-keys-retrieve(){
wx-restricted
if [[ ! -z $1 ]] if [[ ! -z $1 ]]
then then
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}") VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
@ -479,7 +447,6 @@ wx-ssh-keys-retrieve(){
} }
wx-ssh-keys-save(){ wx-ssh-keys-save(){
wx-restricted
if [[ ! -z $1 ]] if [[ ! -z $1 ]]
then then
if [[ -f "$HOME/.ssh/keys/$1" ]] if [[ -f "$HOME/.ssh/keys/$1" ]]
@ -490,13 +457,12 @@ wx-ssh-keys-save(){
} }
wx-ssh-keys-sync(){ wx-ssh-keys-sync(){
wx-restricted
echo "" echo ""
} }
wx-ssh-sign(){ wx-ssh-sign(){
wx-header "SSH / Sign" echo " >> SSH / Sign << "
wx-restricted echo "------------------------------"
if [[ $ORG == "warengroup" ]] if [[ $ORG == "warengroup" ]]
then then
@ -513,8 +479,6 @@ wx-ssh-sign(){
} }
wx-ssh-sign-create(){ wx-ssh-sign-create(){
wx-restricted
NAME=$1 NAME=$1
ROLE=$2 ROLE=$2
PRINCIPALS=$2 PRINCIPALS=$2
@ -533,6 +497,7 @@ wx-ssh-sign-create(){
} }
wx-start
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]] if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then then
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9 wx-$1 $2 $3 $4 $5 $6 $7 $8 $9