Code Update
This commit is contained in:
parent
b014dd1990
commit
0071b7407d
@ -1,9 +1,13 @@
|
|||||||
wx-logout(){
|
wx-logout(){
|
||||||
wx-header "Logout"
|
wx-header "Logout"
|
||||||
if [[ $USER != "root" && $USER != "local" ]]
|
if [[ $USER != "root" && $USER != "local" && -f "$HOME/.config/warengroup/config.json" ]]
|
||||||
then
|
then
|
||||||
wx-clean
|
VAULT_LOGIN=$(cat $HOME/.config/warengroup/config.json | jq -r .login)
|
||||||
jq '.login = {}' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
|
if [[ $VAULT_LOGIN != null && $VAULT_LOGIN != "{}" ]]
|
||||||
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
|
then
|
||||||
|
wx-clean
|
||||||
|
jq '.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
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
wx-infra(){
|
wx-infra(){
|
||||||
wx-login
|
wx-login
|
||||||
wx-ssh-sign &> /dev/null
|
wx-auto &> /dev/null
|
||||||
|
|
||||||
wx-header "Infra"
|
wx-header "Infra"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
|
@ -7,9 +7,6 @@ wx-ssh(){
|
|||||||
chmod 700 -R $HOME/.ssh/multiplex
|
chmod 700 -R $HOME/.ssh/multiplex
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
sign)
|
|
||||||
wx-ssh-sign
|
|
||||||
;;
|
|
||||||
keys)
|
keys)
|
||||||
wx-ssh-keys $2 $3
|
wx-ssh-keys $2 $3
|
||||||
;;
|
;;
|
||||||
@ -18,7 +15,6 @@ wx-ssh(){
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
wx-header "SSH"
|
wx-header "SSH"
|
||||||
|
|
||||||
wx-stop
|
wx-stop
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -24,19 +24,19 @@ wx-ssh-config(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-edit(){
|
wx-ssh-config-edit(){
|
||||||
wx-header "SSH / Config"
|
wx-header "SSH / Config / Edit"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
nano ~/.ssh/config
|
nano ~/.ssh/config
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-save(){
|
wx-ssh-config-save(){
|
||||||
wx-header "SSH / Config"
|
wx-header "SSH / Config / Save"
|
||||||
wx-restricted
|
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-header "SSH / Config"
|
wx-header "SSH / Config / Sync"
|
||||||
wx-restricted
|
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 ]]
|
||||||
@ -46,7 +46,7 @@ wx-ssh-config-sync(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-clean(){
|
wx-ssh-config-clean(){
|
||||||
wx-header "SSH / Config"
|
wx-header "SSH / Config / Clean"
|
||||||
wx-restricted
|
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 [[ -f "$HOME/.ssh/config" && $VAULT_STATUS -eq 200 ]]
|
if [[ -f "$HOME/.ssh/config" && $VAULT_STATUS -eq 200 ]]
|
||||||
|
@ -32,7 +32,7 @@ wx-ssh-keys(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-generate(){
|
wx-ssh-keys-generate(){
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Generate"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
if [[ ! -z $1 ]]
|
if [[ ! -z $1 ]]
|
||||||
then
|
then
|
||||||
@ -44,7 +44,7 @@ wx-ssh-keys-generate(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-sign(){
|
wx-ssh-keys-sign(){
|
||||||
wx-header "SSH / Sign"
|
wx-header "SSH / Keys / Sign"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
|
|
||||||
if [[ $ORG == "warengroup" ]]
|
if [[ $ORG == "warengroup" ]]
|
||||||
@ -82,7 +82,11 @@ wx-ssh-keys-sign-create(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-retrieve(){
|
wx-ssh-keys-retrieve(){
|
||||||
wx-header "SSH / Keys"
|
if [[ -z $2 ]]
|
||||||
|
then
|
||||||
|
wx-header "SSH / Keys / Retrieve"
|
||||||
|
fi
|
||||||
|
|
||||||
wx-restricted
|
wx-restricted
|
||||||
if [[ ! -z $1 ]]
|
if [[ ! -z $1 ]]
|
||||||
then
|
then
|
||||||
@ -96,7 +100,7 @@ wx-ssh-keys-retrieve(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-save(){
|
wx-ssh-keys-save(){
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Save"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
if [[ ! -z $1 ]]
|
if [[ ! -z $1 ]]
|
||||||
then
|
then
|
||||||
@ -108,14 +112,24 @@ wx-ssh-keys-save(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-sync(){
|
wx-ssh-keys-sync(){
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Sync"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
|
|
||||||
|
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/metadata/$USERNAME/settings/ssh/keys -X LIST --header "X-Vault-Token: ${config["login",$ORG]}")
|
||||||
|
if [[ $VAULT_STATUS -eq 200 ]]
|
||||||
|
then
|
||||||
|
for name in $(curl https://$VAULT_DOMAIN/v1/cli/metadata/$USERNAME/settings/ssh/keys -X LIST --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.keys | @sh' | tr -d \')
|
||||||
|
do
|
||||||
|
echo $name
|
||||||
|
wx-ssh-keys-retrieve $name --multiple
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-clean(){
|
wx-ssh-keys-clean(){
|
||||||
if [[ -z $1 ]]
|
if [[ -z $1 ]]
|
||||||
then
|
then
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Clean"
|
||||||
fi
|
fi
|
||||||
wx-restricted
|
wx-restricted
|
||||||
|
|
||||||
|
52
wx
52
wx
@ -128,7 +128,7 @@ Maintenance Commands:
|
|||||||
|
|
||||||
wx-infra(){
|
wx-infra(){
|
||||||
wx-login
|
wx-login
|
||||||
wx-ssh-sign &> /dev/null
|
wx-auto &> /dev/null
|
||||||
|
|
||||||
wx-header "Infra"
|
wx-header "Infra"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
@ -173,9 +173,6 @@ wx-ssh(){
|
|||||||
chmod 700 -R $HOME/.ssh/multiplex
|
chmod 700 -R $HOME/.ssh/multiplex
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
sign)
|
|
||||||
wx-ssh-sign
|
|
||||||
;;
|
|
||||||
keys)
|
keys)
|
||||||
wx-ssh-keys $2 $3
|
wx-ssh-keys $2 $3
|
||||||
;;
|
;;
|
||||||
@ -184,7 +181,6 @@ wx-ssh(){
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
wx-header "SSH"
|
wx-header "SSH"
|
||||||
|
|
||||||
wx-stop
|
wx-stop
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -368,11 +364,15 @@ wx-login(){
|
|||||||
|
|
||||||
wx-logout(){
|
wx-logout(){
|
||||||
wx-header "Logout"
|
wx-header "Logout"
|
||||||
if [[ $USER != "root" && $USER != "local" ]]
|
if [[ $USER != "root" && $USER != "local" && -f "$HOME/.config/warengroup/config.json" ]]
|
||||||
then
|
then
|
||||||
wx-clean
|
VAULT_LOGIN=$(cat $HOME/.config/warengroup/config.json | jq -r .login)
|
||||||
jq '.login = {}' $HOME/.config/warengroup/config.json &> $HOME/.config/warengroup/config.json.tmp
|
if [[ $VAULT_LOGIN != null && $VAULT_LOGIN != "{}" ]]
|
||||||
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
|
then
|
||||||
|
wx-clean
|
||||||
|
jq '.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
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,19 +457,19 @@ wx-ssh-config(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-edit(){
|
wx-ssh-config-edit(){
|
||||||
wx-header "SSH / Config"
|
wx-header "SSH / Config / Edit"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
nano ~/.ssh/config
|
nano ~/.ssh/config
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-save(){
|
wx-ssh-config-save(){
|
||||||
wx-header "SSH / Config"
|
wx-header "SSH / Config / Save"
|
||||||
wx-restricted
|
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-header "SSH / Config"
|
wx-header "SSH / Config / Sync"
|
||||||
wx-restricted
|
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 ]]
|
||||||
@ -479,7 +479,7 @@ wx-ssh-config-sync(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-clean(){
|
wx-ssh-config-clean(){
|
||||||
wx-header "SSH / Config"
|
wx-header "SSH / Config / Clean"
|
||||||
wx-restricted
|
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 [[ -f "$HOME/.ssh/config" && $VAULT_STATUS -eq 200 ]]
|
if [[ -f "$HOME/.ssh/config" && $VAULT_STATUS -eq 200 ]]
|
||||||
@ -522,7 +522,7 @@ wx-ssh-keys(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-generate(){
|
wx-ssh-keys-generate(){
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Generate"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
if [[ ! -z $1 ]]
|
if [[ ! -z $1 ]]
|
||||||
then
|
then
|
||||||
@ -534,7 +534,7 @@ wx-ssh-keys-generate(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-sign(){
|
wx-ssh-keys-sign(){
|
||||||
wx-header "SSH / Sign"
|
wx-header "SSH / Keys / Sign"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
|
|
||||||
if [[ $ORG == "warengroup" ]]
|
if [[ $ORG == "warengroup" ]]
|
||||||
@ -572,7 +572,11 @@ wx-ssh-keys-sign-create(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-retrieve(){
|
wx-ssh-keys-retrieve(){
|
||||||
wx-header "SSH / Keys"
|
if [[ -z $2 ]]
|
||||||
|
then
|
||||||
|
wx-header "SSH / Keys / Retrieve"
|
||||||
|
fi
|
||||||
|
|
||||||
wx-restricted
|
wx-restricted
|
||||||
if [[ ! -z $1 ]]
|
if [[ ! -z $1 ]]
|
||||||
then
|
then
|
||||||
@ -586,7 +590,7 @@ wx-ssh-keys-retrieve(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-save(){
|
wx-ssh-keys-save(){
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Save"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
if [[ ! -z $1 ]]
|
if [[ ! -z $1 ]]
|
||||||
then
|
then
|
||||||
@ -598,14 +602,24 @@ wx-ssh-keys-save(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-sync(){
|
wx-ssh-keys-sync(){
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Sync"
|
||||||
wx-restricted
|
wx-restricted
|
||||||
|
|
||||||
|
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/metadata/$USERNAME/settings/ssh/keys -X LIST --header "X-Vault-Token: ${config["login",$ORG]}")
|
||||||
|
if [[ $VAULT_STATUS -eq 200 ]]
|
||||||
|
then
|
||||||
|
for name in $(curl https://$VAULT_DOMAIN/v1/cli/metadata/$USERNAME/settings/ssh/keys -X LIST --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.keys | @sh' | tr -d \')
|
||||||
|
do
|
||||||
|
echo $name
|
||||||
|
wx-ssh-keys-retrieve $name --multiple
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-keys-clean(){
|
wx-ssh-keys-clean(){
|
||||||
if [[ -z $1 ]]
|
if [[ -z $1 ]]
|
||||||
then
|
then
|
||||||
wx-header "SSH / Keys"
|
wx-header "SSH / Keys / Clean"
|
||||||
fi
|
fi
|
||||||
wx-restricted
|
wx-restricted
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user