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 }}
{{ COMMANDS }}
wx-start
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
wx-ssh-config(){
wx-header "SSH / Config"
wx-restricted
echo " >> SSH / Config << "
echo "------------------------------"
case $1 in
edit)
@ -22,17 +22,14 @@ wx-ssh-config(){
}
wx-ssh-config-edit(){
wx-restricted
nano ~/.ssh/config
}
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
}
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]}")
if [[ $VAULT_STATUS -eq 200 ]]
then

View File

@ -1,5 +1,6 @@
wx-ssh-keys(){
wx-header "SSH / Keys"
echo " >> SSH / Keys << "
echo "------------------------------"
case $1 in
generate)
@ -27,7 +28,6 @@ wx-ssh-keys(){
}
wx-ssh-keys-generate(){
wx-restricted
if [[ ! -z $1 ]]
then
if [[ ! -f "$HOME/.ssh/keys/$1" ]]
@ -38,7 +38,6 @@ wx-ssh-keys-generate(){
}
wx-ssh-keys-retrieve(){
wx-restricted
if [[ ! -z $1 ]]
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]}")
@ -51,7 +50,6 @@ wx-ssh-keys-retrieve(){
}
wx-ssh-keys-save(){
wx-restricted
if [[ ! -z $1 ]]
then
if [[ -f "$HOME/.ssh/keys/$1" ]]
@ -62,6 +60,5 @@ wx-ssh-keys-save(){
}
wx-ssh-keys-sync(){
wx-restricted
echo ""
}

View File

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

167
wx
View File

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