Compare commits
No commits in common. "56b6f58f4ec5dde55f45848a750427b79dfe3d35" and "a1ff2b40d73e21b28ad70e6ed1abc69ee198b196" have entirely different histories.
56b6f58f4e
...
a1ff2b40d7
@ -1,8 +1 @@
|
|||||||
# Warén Group - WX
|
# Warén Group - WX
|
||||||
|
|
||||||
## Install
|
|
||||||
```
|
|
||||||
sudo curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o /opt/wx &> /dev/null
|
|
||||||
sudo ln -sf /opt/wx /usr/bin/wx &> /dev/null
|
|
||||||
sudo chmod +x /usr/bin/wx &> /dev/null
|
|
||||||
```
|
|
||||||
|
@ -6,31 +6,18 @@ $base = file_get_contents(__DIR__."/src/base.sh");
|
|||||||
$dirs = [
|
$dirs = [
|
||||||
__DIR__.'/src/commands/*.sh',
|
__DIR__.'/src/commands/*.sh',
|
||||||
__DIR__.'/src/commands/*/*.sh',
|
__DIR__.'/src/commands/*/*.sh',
|
||||||
__DIR__.'/src/commands/*/*/*.sh',
|
__DIR__.'/src/commands/*/*/*.sh'
|
||||||
__DIR__.'/src/functions/*.sh',
|
|
||||||
__DIR__.'/src/elements.sh'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$codes = [];
|
$codes = [];
|
||||||
|
|
||||||
foreach($dirs as $dir){
|
foreach($dirs as $dir){
|
||||||
foreach(glob($dir) as $file){
|
foreach(glob($dir) as $file){
|
||||||
if(str_contains($dir, "elements")){
|
$codes[$file] = file_get_contents($file);
|
||||||
echo $dir;
|
|
||||||
$codes['elements'][$file] = file_get_contents($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("{{ ELEMENTS }}", implode("\n", $codes['elements']), $base);
|
$code = str_replace("{{ COMMANDS }}", implode("\n", $codes), $base);
|
||||||
$code = str_replace("{{ FUNCTIONS }}", implode("\n", $codes['functions']), $code);
|
|
||||||
$code = str_replace("{{ COMMANDS }}", implode("\n", $codes['commands']), $code);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$file = __DIR__.'/wx.tmp';
|
$file = __DIR__.'/wx.tmp';
|
||||||
|
195
src/base.sh
195
src/base.sh
@ -5,17 +5,192 @@ if [ ! "$BASH_VERSION" ] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
{{ ELEMENTS }}
|
syntax-line-douple() {
|
||||||
{{ FUNCTIONS }}
|
echo -n "
|
||||||
|
==============================
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
syntax-line-single() {
|
||||||
|
echo -n "
|
||||||
|
------------------------------
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
syntax-line-douple
|
||||||
|
echo -n "Warén CLI "
|
||||||
|
syntax-line-douple
|
||||||
|
}
|
||||||
|
|
||||||
|
login() {
|
||||||
|
echo ">>> Login <<<"
|
||||||
|
ORG=$2
|
||||||
|
|
||||||
|
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then
|
||||||
|
stop
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $(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
|
||||||
|
elif [[ -z $ORG ]]
|
||||||
|
then
|
||||||
|
echo "Organization: Required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $ORG == "warengroup" ]]
|
||||||
|
then
|
||||||
|
DOMAIN=waren.io
|
||||||
|
elif [[ $ORG == "cwinfo" ]]
|
||||||
|
then
|
||||||
|
DOMAIN=cwinfo.net
|
||||||
|
elif [[ $ORG == "cwchristerw" ]]
|
||||||
|
then
|
||||||
|
DOMAIN=christerwaren.fi
|
||||||
|
else
|
||||||
|
echo "Organization: Unsupported"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
FOLDER=$ORG
|
||||||
|
DEVICE_DOMAIN="devices.$DOMAIN"
|
||||||
|
IDM_DOMAIN="idm.cwinfo.net"
|
||||||
|
VAULT_DOMAIN="vault.cwinfo.net"
|
||||||
|
GIT_DOMAIN="git.cwinfo.net"
|
||||||
|
|
||||||
|
if [[ $(hostname -d) ]]
|
||||||
|
then
|
||||||
|
HOSTNAME=$(hostname --fqdn)
|
||||||
|
elif [[ -z $(hostname -d) ]] && [[ ! -z $2 ]]
|
||||||
|
then
|
||||||
|
HOSTNAME="$2.$DEVICE_DOMAIN"
|
||||||
|
else
|
||||||
|
echo "Hostname: Required"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $USER ]]
|
||||||
|
then
|
||||||
|
if [[ -z $SUDO_USER ]]
|
||||||
|
then
|
||||||
|
if [[ -z LOGNAME ]]
|
||||||
|
then
|
||||||
|
echo "Username: Required"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
USER=$LOGNAME
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
USER=$SUDO_USER
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/sys/health)
|
||||||
|
if [[ $VAULT_STATUS -eq 200 ]]
|
||||||
|
then
|
||||||
|
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
|
||||||
|
if [[ $IDM_STATUS -eq 301 ]]
|
||||||
|
then
|
||||||
|
echo "Organization: $ORG"
|
||||||
|
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
|
||||||
|
then
|
||||||
|
echo -n "Username: "
|
||||||
|
read USERNAME
|
||||||
|
else
|
||||||
|
echo "Username: $USER"
|
||||||
|
USERNAME=$USER
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -n "Password: "
|
||||||
|
read -s PASSWORD
|
||||||
|
echo -n "****************"
|
||||||
|
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"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Organization: $ORG"
|
||||||
|
echo "Status: IDM Offline"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Organization: $ORG"
|
||||||
|
echo "Status: Vault Offline"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://vault.$DOMAIN/v1/sys/health)
|
||||||
|
# if [[ $VAULT_STATUS -eq 200 ]]; then
|
||||||
|
# export VAULT_ADDR="https://vault.$DOMAIN"
|
||||||
|
# VAULT_LOGIN=$(vault token lookup -address=https://vault.$DOMAIN 2> /dev/null)
|
||||||
|
# if [[ -z $VAULT_LOGIN ]]; then
|
||||||
|
# IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://idm.$DOMAIN)
|
||||||
|
# if [[ $IDM_STATUS -eq 301 ]]; then
|
||||||
|
# echo "vault.$DOMAIN - Login"
|
||||||
|
# echo "Username: $USER"
|
||||||
|
# echo -n "Password: "
|
||||||
|
# export VAULT_ADDR="https://vault.$DOMAIN"
|
||||||
|
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
|
||||||
|
# echo ""
|
||||||
|
# if [[ -z $VAULT_LOGIN ]]; then
|
||||||
|
# exit 1
|
||||||
|
# fi
|
||||||
|
# else
|
||||||
|
# echo "vault.$DOMAIN - Login"
|
||||||
|
# echo -n "Token: "
|
||||||
|
# export VAULT_ADDR="https://vault.$DOMAIN"
|
||||||
|
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null)
|
||||||
|
# echo ""
|
||||||
|
# if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then
|
||||||
|
# exit 1
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
|
|
||||||
|
# if [[ $USER == "root" || $USER == "local" ]]
|
||||||
|
# then
|
||||||
|
# echo "Status: Login Failed"
|
||||||
|
# fi
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
|
stop () {
|
||||||
|
if [[ -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
|
||||||
|
else
|
||||||
|
sudo curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o /opt/wx &> /dev/null
|
||||||
|
if [[ -d "/usr/bin" ]]
|
||||||
|
then
|
||||||
|
sudo ln -sf /opt/wx /usr/bin/wx &> /dev/null
|
||||||
|
fi
|
||||||
|
sudo chmod +x /usr/bin/wx &> /dev/null
|
||||||
|
fi
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
{{ COMMANDS }}
|
{{ COMMANDS }}
|
||||||
|
|
||||||
wx-start
|
start
|
||||||
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
|
if [[ ! -z $1 ]] && [[ $(type -t warencli-$1) == function ]]
|
||||||
then
|
then
|
||||||
wx-login
|
warencli-$1 $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
wx-start
|
|
||||||
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
|
|
||||||
else
|
|
||||||
wx-welcome
|
|
||||||
fi
|
fi
|
||||||
wx-stop
|
stop
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
wx-help() {
|
warencli-help() {
|
||||||
echo -n ">>> Help <<<";
|
|
||||||
echo "
|
echo "
|
||||||
Usage: $0 COMMAND [OPTIONS]
|
Usage: $0 COMMAND [OPTIONS]
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
wx-settings() {
|
warencli-settings() {
|
||||||
echo -n ">>> Settings <<<";
|
echo ">>> Settings <<<";
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
wx-ssh() {
|
warencli-ssh() {
|
||||||
echo -n ">>> SSH <<<";
|
echo ">>> SSH <<<";
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
wx-ssh-config(){
|
warencli-ssh-config(){
|
||||||
echo -n ">>> SSH: Config <<<"
|
echo ">>> SSH: Config <<<"
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
wx-ssh-sign(){
|
warencli-ssh-sign(){
|
||||||
echo -n ">>> SSH: Certificates <<<"
|
echo ">>> SSH: Certificates <<<"
|
||||||
}
|
}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
wx-welcome() {
|
|
||||||
echo -n ">>> Welcome <<<"
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
wx-elements-line-douple () {
|
|
||||||
echo "=============================="
|
|
||||||
}
|
|
||||||
wx-elements-line-single () {
|
|
||||||
echo "------------------------------"
|
|
||||||
}
|
|
@ -1,143 +0,0 @@
|
|||||||
wx-login() {
|
|
||||||
echo ">>> Login <<<"
|
|
||||||
ORG=$2
|
|
||||||
|
|
||||||
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $(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
|
|
||||||
elif [[ -z $ORG ]]
|
|
||||||
then
|
|
||||||
echo "Organization: Required"
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $ORG == "warengroup" ]]
|
|
||||||
then
|
|
||||||
DOMAIN=waren.io
|
|
||||||
elif [[ $ORG == "cwinfo" ]]
|
|
||||||
then
|
|
||||||
DOMAIN=cwinfo.net
|
|
||||||
elif [[ $ORG == "cwchristerw" ]]
|
|
||||||
then
|
|
||||||
DOMAIN=christerwaren.fi
|
|
||||||
else
|
|
||||||
echo "Organization: Unsupported"
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
|
|
||||||
FOLDER=$ORG
|
|
||||||
DEVICE_DOMAIN="devices.$DOMAIN"
|
|
||||||
IDM_DOMAIN="idm.cwinfo.net"
|
|
||||||
VAULT_DOMAIN="vault.cwinfo.net"
|
|
||||||
GIT_DOMAIN="git.cwinfo.net"
|
|
||||||
|
|
||||||
if [[ $(hostname -d) ]]
|
|
||||||
then
|
|
||||||
HOSTNAME=$(hostname --fqdn)
|
|
||||||
elif [[ -z $(hostname -d) ]] && [[ ! -z $2 ]]
|
|
||||||
then
|
|
||||||
HOSTNAME="$2.$DEVICE_DOMAIN"
|
|
||||||
else
|
|
||||||
echo "Hostname: Required"
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $USER ]]
|
|
||||||
then
|
|
||||||
if [[ -z $SUDO_USER ]]
|
|
||||||
then
|
|
||||||
if [[ -z LOGNAME ]]
|
|
||||||
then
|
|
||||||
echo "Username: Required"
|
|
||||||
stop
|
|
||||||
else
|
|
||||||
USER=$LOGNAME
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
USER=$SUDO_USER
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/sys/health)
|
|
||||||
if [[ $VAULT_STATUS -eq 200 ]]
|
|
||||||
then
|
|
||||||
IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$IDM_DOMAIN)
|
|
||||||
if [[ $IDM_STATUS -eq 301 ]]
|
|
||||||
then
|
|
||||||
echo "Organization: $ORG"
|
|
||||||
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
|
|
||||||
then
|
|
||||||
echo -n "Username: "
|
|
||||||
read USERNAME
|
|
||||||
else
|
|
||||||
echo "Username: $USER"
|
|
||||||
USERNAME=$USER
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -n "Password: "
|
|
||||||
read -s PASSWORD
|
|
||||||
echo "****************"
|
|
||||||
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"
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
echo ""
|
|
||||||
else
|
|
||||||
echo "Organization: $ORG"
|
|
||||||
echo "Status: IDM Offline"
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Organization: $ORG"
|
|
||||||
echo "Status: Vault Offline"
|
|
||||||
stop
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://vault.$DOMAIN/v1/sys/health)
|
|
||||||
# if [[ $VAULT_STATUS -eq 200 ]]; then
|
|
||||||
# export VAULT_ADDR="https://vault.$DOMAIN"
|
|
||||||
# VAULT_LOGIN=$(vault token lookup -address=https://vault.$DOMAIN 2> /dev/null)
|
|
||||||
# if [[ -z $VAULT_LOGIN ]]; then
|
|
||||||
# IDM_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://idm.$DOMAIN)
|
|
||||||
# if [[ $IDM_STATUS -eq 301 ]]; then
|
|
||||||
# echo "vault.$DOMAIN - Login"
|
|
||||||
# echo "Username: $USER"
|
|
||||||
# echo -n "Password: "
|
|
||||||
# export VAULT_ADDR="https://vault.$DOMAIN"
|
|
||||||
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
|
|
||||||
# echo ""
|
|
||||||
# if [[ -z $VAULT_LOGIN ]]; then
|
|
||||||
stop
|
|
||||||
# fi
|
|
||||||
# else
|
|
||||||
# echo "vault.$DOMAIN - Login"
|
|
||||||
# echo -n "Token: "
|
|
||||||
# export VAULT_ADDR="https://vault.$DOMAIN"
|
|
||||||
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null)
|
|
||||||
# echo ""
|
|
||||||
# if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then
|
|
||||||
# stop
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
|
|
||||||
|
|
||||||
# if [[ $USER == "root" || $USER == "local" ]]
|
|
||||||
# then
|
|
||||||
# echo "Status: Login Failed"
|
|
||||||
# fi
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
wx-start() {
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
wx-elements-line-douple
|
|
||||||
echo "Warén CLI"
|
|
||||||
wx-elements-line-douple
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
wx-stop () {
|
|
||||||
echo " "
|
|
||||||
echo " "
|
|
||||||
echo " "
|
|
||||||
if [[ -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
|
|
||||||
else
|
|
||||||
sudo curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o /opt/wx &> /dev/null
|
|
||||||
if [[ -d "/usr/bin" ]]
|
|
||||||
then
|
|
||||||
sudo ln -sf /opt/wx /usr/bin/wx &> /dev/null
|
|
||||||
fi
|
|
||||||
sudo chmod +x /usr/bin/wx &> /dev/null
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
}
|
|
96
wx
96
wx
@ -5,14 +5,25 @@ if [ ! "$BASH_VERSION" ] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wx-elements-line-douple () {
|
syntax-line-douple() {
|
||||||
echo "=============================="
|
echo -n "
|
||||||
}
|
==============================
|
||||||
wx-elements-line-single () {
|
"
|
||||||
echo "------------------------------"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-login() {
|
syntax-line-single() {
|
||||||
|
echo -n "
|
||||||
|
------------------------------
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
syntax-line-douple
|
||||||
|
echo -n "Warén CLI "
|
||||||
|
syntax-line-douple
|
||||||
|
}
|
||||||
|
|
||||||
|
login() {
|
||||||
echo ">>> Login <<<"
|
echo ">>> Login <<<"
|
||||||
ORG=$2
|
ORG=$2
|
||||||
|
|
||||||
@ -32,7 +43,7 @@ wx-login() {
|
|||||||
elif [[ -z $ORG ]]
|
elif [[ -z $ORG ]]
|
||||||
then
|
then
|
||||||
echo "Organization: Required"
|
echo "Organization: Required"
|
||||||
stop
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $ORG == "warengroup" ]]
|
if [[ $ORG == "warengroup" ]]
|
||||||
@ -46,7 +57,7 @@ wx-login() {
|
|||||||
DOMAIN=christerwaren.fi
|
DOMAIN=christerwaren.fi
|
||||||
else
|
else
|
||||||
echo "Organization: Unsupported"
|
echo "Organization: Unsupported"
|
||||||
stop
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FOLDER=$ORG
|
FOLDER=$ORG
|
||||||
@ -63,7 +74,7 @@ wx-login() {
|
|||||||
HOSTNAME="$2.$DEVICE_DOMAIN"
|
HOSTNAME="$2.$DEVICE_DOMAIN"
|
||||||
else
|
else
|
||||||
echo "Hostname: Required"
|
echo "Hostname: Required"
|
||||||
stop
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $USER ]]
|
if [[ -z $USER ]]
|
||||||
@ -73,7 +84,7 @@ wx-login() {
|
|||||||
if [[ -z LOGNAME ]]
|
if [[ -z LOGNAME ]]
|
||||||
then
|
then
|
||||||
echo "Username: Required"
|
echo "Username: Required"
|
||||||
stop
|
exit 1
|
||||||
else
|
else
|
||||||
USER=$LOGNAME
|
USER=$LOGNAME
|
||||||
fi
|
fi
|
||||||
@ -100,22 +111,21 @@ wx-login() {
|
|||||||
|
|
||||||
echo -n "Password: "
|
echo -n "Password: "
|
||||||
read -s PASSWORD
|
read -s PASSWORD
|
||||||
echo "****************"
|
echo -n "****************"
|
||||||
VAULT_LOGIN=$(curl https://$VAULT_DOMAIN/v1/auth/ldap/login/$USERNAME -X POST -d '{ "password": "'$PASSWORD'" }' -s | jq -r '.auth.client_token')
|
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
|
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]; then
|
||||||
echo "Status: Login Failed"
|
echo "Status: Login Failed"
|
||||||
stop
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo ""
|
|
||||||
else
|
else
|
||||||
echo "Organization: $ORG"
|
echo "Organization: $ORG"
|
||||||
echo "Status: IDM Offline"
|
echo "Status: IDM Offline"
|
||||||
stop
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Organization: $ORG"
|
echo "Organization: $ORG"
|
||||||
echo "Status: Vault Offline"
|
echo "Status: Vault Offline"
|
||||||
stop
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +144,7 @@ wx-login() {
|
|||||||
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
|
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=ldap username=$USER 2> /dev/null)
|
||||||
# echo ""
|
# echo ""
|
||||||
# if [[ -z $VAULT_LOGIN ]]; then
|
# if [[ -z $VAULT_LOGIN ]]; then
|
||||||
stop
|
# exit 1
|
||||||
# fi
|
# fi
|
||||||
# else
|
# else
|
||||||
# echo "vault.$DOMAIN - Login"
|
# echo "vault.$DOMAIN - Login"
|
||||||
@ -143,7 +153,7 @@ wx-login() {
|
|||||||
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null)
|
# VAULT_LOGIN=$(vault login -address=https://vault.$DOMAIN -method=token 2> /dev/null)
|
||||||
# echo ""
|
# echo ""
|
||||||
# if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then
|
# if [[ -z $VAULT_LOGIN || ${#VAULT_TOKEN} -lt 95 || ${#VAULT_TOKEN} -gt 95 ]]; then
|
||||||
# stop
|
# exit 1
|
||||||
# fi
|
# fi
|
||||||
# fi
|
# fi
|
||||||
# fi
|
# fi
|
||||||
@ -154,21 +164,10 @@ wx-login() {
|
|||||||
# then
|
# then
|
||||||
# echo "Status: Login Failed"
|
# echo "Status: Login Failed"
|
||||||
# fi
|
# fi
|
||||||
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-start() {
|
stop () {
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
wx-elements-line-douple
|
|
||||||
echo "Warén CLI"
|
|
||||||
wx-elements-line-douple
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-stop () {
|
|
||||||
echo " "
|
|
||||||
echo " "
|
|
||||||
echo " "
|
|
||||||
if [[ -d "./src" ]]
|
if [[ -d "./src" ]]
|
||||||
then
|
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
|
podman run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp docker.io/library/php:8-cli php generator.php &> /dev/null
|
||||||
@ -182,11 +181,12 @@ wx-stop () {
|
|||||||
fi
|
fi
|
||||||
sudo chmod +x /usr/bin/wx &> /dev/null
|
sudo chmod +x /usr/bin/wx &> /dev/null
|
||||||
fi
|
fi
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-help() {
|
warencli-help() {
|
||||||
echo -n ">>> Help <<<";
|
|
||||||
echo "
|
echo "
|
||||||
Usage: $0 COMMAND [OPTIONS]
|
Usage: $0 COMMAND [OPTIONS]
|
||||||
|
|
||||||
@ -200,34 +200,26 @@ Management Commands:
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-settings() {
|
warencli-settings() {
|
||||||
echo -n ">>> Settings <<<";
|
echo ">>> Settings <<<";
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh() {
|
warencli-ssh() {
|
||||||
echo -n ">>> SSH <<<";
|
echo ">>> SSH <<<";
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-welcome() {
|
warencli-ssh-config(){
|
||||||
echo -n ">>> Welcome <<<"
|
echo ">>> SSH: Config <<<"
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config(){
|
warencli-ssh-sign(){
|
||||||
echo -n ">>> SSH: Config <<<"
|
echo ">>> SSH: Certificates <<<"
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-sign(){
|
|
||||||
echo -n ">>> SSH: Certificates <<<"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wx-start
|
start
|
||||||
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
|
if [[ ! -z $1 ]] && [[ $(type -t warencli-$1) == function ]]
|
||||||
then
|
then
|
||||||
wx-login
|
warencli-$1 $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
wx-start
|
|
||||||
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
|
|
||||||
else
|
|
||||||
wx-welcome
|
|
||||||
fi
|
fi
|
||||||
wx-stop
|
stop
|
||||||
|
Loading…
Reference in New Issue
Block a user