Compare commits

..
56 Commits
Author SHA1 Message Date
Christer Warén 1d906696aa Deprecation Notice 2026-08-26 00:39:28 +03:00
Christer Warén 869a22cb73 Add extra-vars parameter to use with Build tasks on Manager playbook in Infra command 2026-01-22 01:44:41 +02:00
Christer Warén 21db6ac4e9 Update Login in Config function 2026-01-22 01:30:42 +02:00
Christer Warén 7dd2a07186 Update SSH Keys Sign feature 2026-01-18 19:01:40 +02:00
Christer Warén a37fce53e8 Update Login and Logout process 2026-01-18 18:54:36 +02:00
Christer Warén a9539ffb9d Remove operation variable from Manager playbook in Infra command 2026-01-15 07:15:52 +02:00
Christer Warén c479044caf Change hostname to host parameter in Infra command 2026-01-06 07:46:25 +02:00
Christer Warén c9008a981b Fix Infra command 2026-01-04 08:26:52 +02:00
Christer Warén a9e5b2c336 Use new arguments and fix Init playbook location in Infra command 2025-12-29 15:09:07 +02:00
Christer Warén cf9bc49c27 Fix SSH subcommands 2025-12-12 16:52:58 +02:00
Christer Warén d91a7c21c0 Rename Login Type to Auth Method 2025-12-03 13:30:21 +02:00
Christer Warén 7898e55f30 Fix missing token variable in login command when auth method is ldap 2025-11-26 21:16:39 +02:00
Christer Warén 3fafb66781 FIx typos part 2 2025-11-10 21:13:56 +02:00
Christer Warén 54409a4197 FIx typos 2025-11-10 19:48:07 +02:00
Christer Warén 77a54ef1f6 Comment debugging args in stop function 2025-11-10 12:41:58 +02:00
Christer Warén fbaa5780d9 Refactoring Code 2025-11-10 12:40:35 +02:00
Christer Warén 5a666e6f60 VSCode Settings: Update 2025-11-03 02:41:43 +02:00
Christer Warén 1e4f9ed508 Generator Update 2025-11-03 02:40:44 +02:00
Christer Warén 592cd95f42 Replace bin only on successful connection 2025-09-27 00:02:35 +03:00
Christer Warén bce9c3c4d6 Auto - Create SSH certificates before getting SSH privatekeys 2025-09-24 13:39:33 +03:00
Christer Warén f91e69ee55 Run clean in Uninstall command 2025-08-21 18:35:09 +03:00
Christer Warén 32e6b83611 Exit after Uninstall finished 2025-08-21 18:32:01 +03:00
Christer Warén 2742d39818 Fix issue with crontab removal in Uninstall 2025-08-21 18:18:30 +03:00
Christer Warén fe5abf5419 Fix grep to ignore wildcard as regexp 2025-08-21 17:58:38 +03:00
Christer Warén 43192faed1 Fix typos 2025-08-21 17:44:27 +03:00
Christer Warén a276adb6d2 Remove logout from uninstall 2025-08-21 17:28:23 +03:00
Christer Warén b5186f0380 Add cronjob removal into uninstall 2025-08-21 17:26:21 +03:00
Christer Warén 86bb04d2ea Add cronjob to installation 2025-08-21 17:21:22 +03:00
Christer Warén 67fabf0ce1 Code Update 2025-06-26 23:07:14 +03:00
Christer Warén fe56c50bfb Code Update 2025-06-23 09:35:37 +03:00
Christer Warén eb14aa46ff Code Update 2025-06-22 01:24:09 +03:00
Christer Warén c59d1b374d Code Update 2025-06-22 01:22:12 +03:00
Christer Warén 1a99d2e2a1 Code Update 2025-06-22 00:44:42 +03:00
Christer Warén 1d03f7be64 Code Update 2025-06-22 00:31:52 +03:00
Christer Warén 994e44d8f1 Code Update 2025-06-22 00:22:15 +03:00
Christer Warén f016a452cd Remove Hostname variable from login process 2025-06-21 23:46:20 +03:00
Christer Warén c17b9a0e42 Code Update 2025-05-10 12:09:50 +03:00
Christer Warén a91d5d6011 Code Update 2025-05-10 11:29:56 +03:00
Christer Warén 3a0902fe8e Code Update 2025-04-27 15:39:50 +03:00
Christer Warén 9baae5bccc Code Update 2025-04-27 15:32:10 +03:00
Christer Warén 7b837fdba7 Code Update 2025-04-27 15:21:27 +03:00
Christer Warén 283b7538e6 Rename build.sh to maintainer.sh 2025-01-04 08:18:12 +02:00
Christer Warén 14ae6e5dad Fix typo in code 2025-01-04 06:22:06 +02:00
Christer Warén 87608f9bfb Code Update 2025-01-04 06:19:35 +02:00
Christer Warén 5903932328 Update copyright year 2025-01-01 18:00:22 +02:00
Christer Warén 96193196cc Fix typo on curl that will get Vault passwords in Infra command 2024-11-23 07:42:02 +02:00
Christer Warén 0186421fc6 Get Ansible vault passwords in Infra command 2024-11-23 07:18:17 +02:00
Christer Warén 714feda225 Hide git command output from stdout in Infra command 2024-11-23 07:06:57 +02:00
Christer Warén 3d834933e7 Fix home directory issue 2024-11-23 07:04:12 +02:00
Christer Warén dd72a873ab Temporarily disable using jump host when getting Infra repo from Git server 2024-11-23 07:01:33 +02:00
Christer Warén 81cd3a1c1c Create secondary Infra directory and pull changes when using Infra command 2024-11-23 06:57:41 +02:00
Christer Warén b52f1d4486 Add secondary Infra repo path to Infra command 2024-11-23 06:50:26 +02:00
Christer Warén 42239ef54d Add secondary Ansible Vault to cwchristerw user 2024-11-22 00:16:35 +02:00
Christer Warén 256a79e427 Code Update 2024-06-24 06:32:58 +03:00
Christer Warén b36f98e5e9 Hide Clean output in logout command 2024-06-19 20:56:27 +03:00
Christer Warén 2f33daaaa7 Code Update 2024-06-16 04:06:43 +03:00
26 changed files with 835 additions and 1263 deletions
-6
View File
@@ -1,6 +0,0 @@
{
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"editor.renderFinalNewline": false
}
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023-2024 Warén Group
Copyright (c) 2023-2026 Warén Group
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+2 -13
View File
@@ -1,15 +1,4 @@
# Warén Group - Warén CLI (wx)
## Install
```
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
export PATH=$HOME/bin:$PATH
```
## Schedule
```
# Warén CLI
*/30 * * * * $HOME/bin/wx auto
```
## Documentation
Check documentation in Warén Group's Infra repository. This repository is going to be deprecated soon.
-13
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
-37
View File
@@ -1,37 +0,0 @@
<?php
$base = file_get_contents(__DIR__."/src/base.sh");
$dirs = [
__DIR__.'/src/commands/*.sh',
__DIR__.'/src/commands/*/*.sh',
__DIR__.'/src/commands/*/*/*.sh',
__DIR__.'/src/functions/*.sh'
];
$codes = [];
foreach($dirs as $dir){
foreach(glob($dir) as $file){
if(str_contains($dir, "functions")){
$codes['functions'][$file] = file_get_contents($file);
}
if(str_contains($dir, "commands")){
$codes['commands'][$file] = file_get_contents($file);
}
}
}
$code = str_replace("{{ FUNCTIONS }}", implode("\n", $codes['functions']), $base);
$code = str_replace("{{ COMMANDS }}", implode("\n", $codes['commands']), $code);
try {
$file = __DIR__.'/wx.tmp';
$file = fopen($file, "w");
fwrite($file, $code);
fclose($file);
} catch (\Error $e) {
}
?>
-31
View File
@@ -1,31 +0,0 @@
#!/bin/bash
if [ ! "$BASH_VERSION" ] ; then
bash $0 $1 $2 $3 $4 $5 $6 $7 $8 $9
exit 1
fi
wxRed=$(tput setaf 196)
wxGreen=$(tput setaf 46)
wxYellow=$(tput setaf 226)
wxBlue=$(tput setaf 21)
wxPurple=$(tput setaf 165)
wxTurquoise=$(tput setaf 14)
wxPink=$(tput setaf 198)
wxOrange=$(tput setaf 202)
wxUnderline=$(tput smul)
wxBold=$(tput bold)
wxNormal=$(tput sgr0)
declare -Ax config
{{ FUNCTIONS }}
{{ COMMANDS }}
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
else
wx-welcome
fi
wx-stop
-171
View File
@@ -1,171 +0,0 @@
wx-login(){
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]
then
wx-header "Login"
echo "Status: Hostname Required"
wx-stop
fi
if [[ ! -z $1 ]]
then
ORG=$1
elif [[ $(hostname -d) = *"devices.waren.io" ]]
then
ORG=warengroup
elif [[ $(hostname -d) = *"devices.cwinfo.net" ]]
then
ORG=cwinfo
elif [[ $(hostname -d) = *"devices.christerwaren.fi" ]]
then
ORG=cwchristerw
else
wx-header "Login"
echo "Status: Organization Required"
wx-stop
fi
if [[ $ORG == "warengroup" ]]
then
DOMAIN=waren.io
elif [[ $ORG == "cwinfo" ]]
then
DOMAIN=cwinfo.net
elif [[ $ORG == "cwchristerw" ]]
then
DOMAIN=christerwaren.fi
else
wx-header "Login"
echo "Status: Organization Unsupported"
wx-stop
fi
FOLDER=$ORG
DEVICE_DOMAIN="devices.$DOMAIN"
IDM_DOMAIN="idm.cwinfo.net"
VAULT_DOMAIN="vault.cwinfo.net"
if [[ ! -z $2 ]]
then
HOSTNAME="$2.$DEVICE_DOMAIN"
elif [[ $(hostname -d) ]]
then
HOSTNAME=$(hostname --fqdn)
else
wx-header "Login"
echo "Status: Hostname Required"
wx-stop
fi
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
then
if [[ -z $SUDO_USER ]]
then
if [[ -z LOGNAME ]]
then
wx-header "Login"
echo "Status: Username Required"
wx-stop
else
USERNAME=$LOGNAME
fi
else
USERNAME=$SUDO_USER
fi
else
USERNAME=$USER
fi
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" ]]
then
TOKEN="$(cat $HOME/.config/warengroup/config.json | jq -r .login.$ORG)"
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} == 95 ]]
then
config["login",${ORG}]=$VAULT_LOGIN
if [[ $USER != "root" && $USER != "local" ]]
then
jq '.login.'$ORG' = "'$VAULT_LOGIN'"' $HOME/.config/warengroup/config.json 1> $HOME/.config/warengroup/config.json.tmp
mv $HOME/.config/warengroup/config.json.tmp $HOME/.config/warengroup/config.json &> /dev/null
fi
else
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
if [[ $IDM_STATUS -eq 301 ]]
then
wx-header "Login"
echo $wxBold$ORG$wxNormal
if [[ -z $USERNAME || $USERNAME == "root" || $USERNAME == "local" ]]
then
echo -n "Username: "
read USERNAME
else
echo "Username: $USERNAME"
fi
echo -n "Password: "
read -s PASSWORD
echo "****************"
if [[ -z $USERNAME || -z $PASSWORD ]]
then
echo "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 "Status: Login Failed"
wx-stop
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
fi
else
wx-header "Login"
echo $wxBold$ORG$wxNormal
echo -n "Token: "
read -s TOKEN
echo "****************"
if [[ -z $TOKEN || ${#TOKEN} -lt 95 || ${#TOKEN} -gt 95 ]]
then
echo "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 "Status: Login Failed"
wx-stop
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
fi
fi
else
wx-header "Login"
echo $wxBold$ORG$wxNormal
echo "Status: Vault Offline"
wx-stop
fi
}
-13
View File
@@ -1,13 +0,0 @@
wx-logout(){
wx-header "Logout"
if [[ $USER != "root" && $USER != "local" && -f "$HOME/.config/warengroup/config.json" ]]
then
VAULT_LOGIN=$(cat $HOME/.config/warengroup/config.json | jq -r .login)
if [[ $VAULT_LOGIN != null && $VAULT_LOGIN != "{}" ]]
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
}
-40
View File
@@ -1,40 +0,0 @@
wx-help(){
wx-header "Help"
echo -n "
Usage: $0 COMMAND [OPTIONS]
Common Commands:
init Init
help Help
ssh SSH
config Config
edit Edit
save Save
sync Sync
clean Clean
keys Keys
generate Generate
sign Sign
retrieve Retrieve
save Save
sync Sync
delete Delete
clean Clean
Authentication Commands:
login Login
logout Logout
Management Commands:
auto Auto
clean Clean
settings Settings
Maintenance Commands:
install Install
update Update
";
}
-37
View File
@@ -1,37 +0,0 @@
wx-infra(){
wx-login
wx-auto &> /dev/null
wx-header "Infra"
wx-restricted
INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
case $USERNAME in
cwchristerw)
if [[ -z $1 ]]
then
echo "Tag Required"
else
if [[ $1 == "init" ]]
then
if [[ -z $2 ]]
then
echo "Tag Required"
else
cd "$INFRA_PATH"
ansible-playbook --vault-id warengroup@vault/warengroup playbooks/init.yml -t $2 $3 $4 $5 $6 $7 $8 $9
cd "$OLDPWD"
fi
else
cd "$INFRA_PATH"
ansible-playbook --vault-id warengroup@vault/warengroup playbooks.yml -t $1 $2 $3 $4 $5 $6 $7 $8 $9
cd "$OLDPWD"
fi
fi
;;
*)
echo "User Unsupported"
;;
esac
}
-19
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
}
-8
View File
@@ -1,8 +0,0 @@
wx-uninstall(){
wx-header "Uninstall"
wx-logout
if [[ ! -d "$HOME/.config/warengroup" ]]
then
rm "$HOME/.config/warengroup" -rf
fi
}
-4
View File
@@ -1,4 +0,0 @@
wx-update(){
wx-header "Update"
wx-install --update
}
-8
View File
@@ -1,8 +0,0 @@
wx-auto(){
wx-login
wx-header "Auto"
wx-ssh-config-sync
wx-ssh-keys-sync
wx-ssh-keys-sign
}
-6
View File
@@ -1,6 +0,0 @@
wx-clean(){
wx-login
wx-header "Clean"
wx-ssh-config-clean
wx-ssh-keys-clean
}
-4
View File
@@ -1,4 +0,0 @@
wx-settings(){
wx-login
wx-header "Settings"
}
-21
View File
@@ -1,21 +0,0 @@
wx-ssh(){
wx-login
mkdir -p $HOME/.ssh/keys
chmod 700 -R $HOME/.ssh/keys
mkdir -p $HOME/.ssh/multiplex
chmod 700 -R $HOME/.ssh/multiplex
case $1 in
keys)
wx-ssh-keys $2 $3
;;
config)
wx-ssh-config $2
;;
*)
wx-header "SSH"
wx-stop
;;
esac
}
-57
View File
@@ -1,57 +0,0 @@
wx-ssh-config(){
wx-restricted
case $1 in
edit)
wx-ssh-config-sync
wx-ssh-config-edit
wx-ssh-config-save
;;
save)
wx-ssh-config-save
;;
sync)
wx-ssh-config-sync
;;
clean)
wx-ssh-config-clean
;;
*)
wx-ssh-config-sync
wx-stop
;;
esac
}
wx-ssh-config-edit(){
wx-header "SSH / Config / Edit"
wx-restricted
nano ~/.ssh/config
}
wx-ssh-config-save(){
wx-header "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-header "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
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.data') | base64 -d > ~/.ssh/config 2>&1
chmod 700 ~/.ssh/config
fi
}
wx-ssh-config-clean(){
wx-header "SSH / Config / Clean"
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 [[ -f "$HOME/.ssh/config" && $VAULT_STATUS -eq 200 ]]
then
rm "$HOME/.ssh/config"
fi
}
-167
View File
@@ -1,167 +0,0 @@
wx-ssh-keys(){
wx-restricted
case $1 in
generate)
wx-ssh-keys-retrieve $2
wx-ssh-keys-generate $2
wx-ssh-keys-save $2
;;
sign)
wx-ssh-keys-sign
;;
retrieve)
wx-ssh-keys-retrieve $2
;;
save)
wx-ssh-keys-save $2
;;
sync)
wx-ssh-keys-sync $2
;;
delete)
wx-ssh-keys-delete $2
;;
clean)
wx-ssh-keys-clean $2
;;
*)
wx-stop
;;
esac
}
wx-ssh-keys-generate(){
wx-header "SSH / Keys / Generate"
wx-restricted
if [[ ! -z $1 ]]
then
if [[ ! -f "$HOME/.ssh/keys/$1" ]]
then
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$1 -q -N "" -C "$USERNAME" &> /dev/null
fi
fi
}
wx-ssh-keys-sign(){
wx-header "SSH / Keys / Sign"
wx-restricted
if [[ $ORG == "warengroup" ]]
then
wx-ssh-keys-sign-create warengroup sysadmin 3600
elif [[ $ORG == "cwinfo" ]]
then
wx-ssh-keys-sign-create cwinfo sysadmin 3600
elif [[ $ORG == "cwchristerw" ]]
then
wx-ssh-keys-sign-create warengroup sysadmin 3600
wx-ssh-keys-sign-create cwinfo sysadmin 3600
wx-ssh-keys-sign-create cwchristerw sysadmin 3600
fi
}
wx-ssh-keys-sign-create(){
wx-restricted
NAME=$1
ROLE=$2
PRINCIPALS=$2
TTL=$3
if [[ ! -f "$HOME/.ssh/keys/$NAME" ]]
then
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$NAME -q -N "" -C "$USERNAME" &> /dev/null
fi
if [[ -f "$HOME/.ssh/keys/$NAME" ]]
then
echo "$NAME/$ROLE"
echo $(curl https://$VAULT_DOMAIN/v1/ssh/sign/$ROLE -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"public_key\": \"$(cat $HOME/.ssh/keys/$NAME.pub)\", \"valid_principals\": \"$PRINCIPALS,$USERNAME\", \"ttl\": \"$TTL\" }" -s | jq -r '.data.signed_key') > ~/.ssh/keys/$NAME.sig 2>&1
fi
}
wx-ssh-keys-retrieve(){
if [[ -z $2 ]]
then
wx-header "SSH / Keys / Retrieve"
fi
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]}")
if [[ $VAULT_STATUS -eq 200 ]]
then
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.private') | base64 -d > ~/.ssh/keys/$1 2>&1
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.public') | base64 -d > ~/.ssh/keys/$1.pub 2>&1
fi
fi
}
wx-ssh-keys-save(){
wx-header "SSH / Keys / Save"
wx-restricted
if [[ ! -z $1 ]]
then
if [[ -f "$HOME/.ssh/keys/$1" ]]
then
curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"private\": \"$(cat ~/.ssh/keys/$1 | base64 -w 0)\", \"public\": \"$(cat ~/.ssh/keys/$1.pub | base64 -w 0)\" } }" -s &> /dev/null
fi
fi
}
wx-ssh-keys-sync(){
wx-header "SSH / Keys / Sync"
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(){
if [[ -z $1 ]]
then
wx-header "SSH / Keys / Clean"
fi
wx-restricted
if [[ ! -z $1 ]]
then
if [[ -f "$HOME/.ssh/keys/$1" && $(basename "$HOME/.ssh/keys/$1") != "legacy" ]]
then
rm "$HOME/.ssh/keys/$1" &> /dev/null
rm "$HOME/.ssh/keys/$1.pub" &> /dev/null
rm "$HOME/.ssh/keys/$1.sig" &> /dev/null
fi
else
if [[ $ORG == "warengroup" ]]
then
wx-ssh-keys-clean warengroup
elif [[ $ORG == "cwinfo" ]]
then
wx-ssh-keys-clean cwinfo
elif [[ $ORG == "cwchristerw" ]]
then
wx-ssh-keys-clean warengroup
wx-ssh-keys-clean cwinfo
wx-ssh-keys-clean cwchristerw
fi
for file in ~/.ssh/keys/*
do
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$(basename "$file" .pub) -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
if [[ $(basename "$file") != "legacy" && $VAULT_STATUS -eq 200 ]]
then
rm "$file" &> /dev/null
fi
done
fi
}
-3
View File
@@ -1,3 +0,0 @@
wx-welcome(){
wx-header "Welcome"
}
-24
View File
@@ -1,24 +0,0 @@
wx-header(){
if [[ $2 == "h1" ]]
then
echo ""
echo ""
echo ""
echo "=============================="
wx-repeat " " $((30/2-${#1}/2))
echo -n "$wxBold"
echo -n "$1"
echo -n "$wxNormal"
echo ""
echo "=============================="
fi
if [[ $2 == "h2" || -z $2 ]]
then
wx-start
wx-repeat " " $((30/2-6/2-${#1}/2))
echo -n ">> $1 <<"
echo ""
echo "------------------------------"
fi
}
-5
View File
@@ -1,5 +0,0 @@
wx-repeat() {
local str=$1 n=$2 spaces
printf -v spaces "%*s" $n " "
printf "%s" "${spaces// /$str}"
}
-10
View File
@@ -1,10 +0,0 @@
wx-restricted(){
if [[ $USER == "root" || $USER == "local" ]]
then
echo "Status: Command Restricted"
echo " "
echo " "
echo " "
exit 1
fi
}
-13
View File
@@ -1,13 +0,0 @@
wx-start(){
wx-header "Warén CLI" h1
if [[ $USER != "root" && $USER != "local" ]]
then
mkdir -p $HOME/.config/warengroup &> /dev/null
if [[ ! -f "$HOME/.config/warengroup/config.json" ]]
then
echo '{}' | jq > $HOME/.config/warengroup/config.json
fi
fi
}
-9
View File
@@ -1,9 +0,0 @@
wx-stop (){
echo " "
echo " "
echo " "
wx-install --auto
exit 1
}
+832 -543
View File
File diff suppressed because it is too large Load Diff