Compare commits
5 Commits
a710bfa4b2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3277f8632 | ||
|
|
40db0d7c04 | ||
|
|
68cda952e2 | ||
|
|
655c86e508 | ||
|
|
b544f7af1e |
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023-2025 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
|
||||
|
||||
34
init.sh
34
init.sh
@@ -19,7 +19,7 @@ wx-init(){
|
||||
|
||||
if [[ ! -z ${args['hostname']} && ${#args['hostname']} -gt 5 ]]
|
||||
then
|
||||
HOSTNAME="${args['hostname']}.$DEVICE_DOMAIN"
|
||||
HOSTNAME="${args['hostname']}.devices.$DOMAIN"
|
||||
elif [[ $(hostname -d) ]]
|
||||
then
|
||||
HOSTNAME=$(hostname --fqdn)
|
||||
@@ -30,9 +30,12 @@ wx-init(){
|
||||
|
||||
if [[ ! -z ${args['device-type']} ]]
|
||||
then
|
||||
if [[ ${args['device-type']} == "server" || ${args['device-type']} == "workstation" ]]
|
||||
if [[ ${args['device-type']} == "server" ]]
|
||||
then
|
||||
DEVICE_TYPE="${args['device-type']}"
|
||||
DEVICE_TYPE="Server"
|
||||
elif [[ ${args['device-type']} == "workstation" ]]
|
||||
then
|
||||
DEVICE_TYPE="Workstation"
|
||||
else
|
||||
wxi-content status "Device Type" "Invalid"
|
||||
wxi-stop
|
||||
@@ -66,7 +69,7 @@ wx-init(){
|
||||
echo "---" > ~/.ansible/vars.yml
|
||||
echo "hostname: $HOSTNAME" >> ~/.ansible/vars.yml
|
||||
echo "info:" >> ~/.ansible/vars.yml
|
||||
echo " type: $TYPE" >> ~/.ansible/vars.yml
|
||||
echo " type: $DEVICE_TYPE" >> ~/.ansible/vars.yml
|
||||
echo "config:" >> ~/.ansible/vars.yml
|
||||
echo " identity:" >> ~/.ansible/vars.yml
|
||||
echo " vault:" >> ~/.ansible/vars.yml
|
||||
@@ -81,7 +84,7 @@ wx-init(){
|
||||
|
||||
/opt/ansible/bin/ansible-galaxy collection install ansible.posix ansible.utils ansible.windows community.crypto community.dns community.docker community.general community.grafana community.hashi_vault community.libvirt community.mongodb community.mysql community.postgresql community.windows containers.podman --upgrade &> /dev/null
|
||||
|
||||
/opt/ansible/bin/ansible-pull -U ssh://git@$GIT_DOMAIN:$GIT_PORT/$GIT_REPOSITORY -d ~/.ansible/pull/infra --accept-host-key --private-key ~/.ssh/keys/init --extra-vars @~/.ansible/vars.yml playbooks/init.yml -t init
|
||||
/opt/ansible/bin/ansible-pull -U ssh://git@$GIT_DOMAIN:$GIT_PORT/$GIT_REPOSITORY -d ~/.ansible/pull/infra --accept-host-key --private-key ~/.ssh/keys/init --extra-vars @~/.ansible/vars.yml init.yml -t init
|
||||
|
||||
unset HVT
|
||||
}
|
||||
@@ -100,7 +103,7 @@ wx-login(){
|
||||
elif [[ ! -z ${args['token']} ]]
|
||||
then
|
||||
AUTH_METHOD=token
|
||||
elif [[ -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != 'null' && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != '' ]]
|
||||
elif [[ $(wxi-config login read) ]]
|
||||
then
|
||||
AUTH_METHOD=token
|
||||
elif [[ ! -z ${args['username']} ]]
|
||||
@@ -149,11 +152,12 @@ wx-login(){
|
||||
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]
|
||||
then
|
||||
wxi-content status "Login" "Failed"
|
||||
wxi-footer
|
||||
wxi-stop
|
||||
fi
|
||||
|
||||
TOKEN=$VAULT_LOGIN
|
||||
wxi-config login
|
||||
wxi-config login write
|
||||
;;
|
||||
token)
|
||||
echo -n "Token: "
|
||||
@@ -163,9 +167,9 @@ wx-login(){
|
||||
then
|
||||
TOKEN=${args['token']}
|
||||
fi
|
||||
elif [[ -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != 'null' && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != '' ]]
|
||||
elif [[ $(wxi-config login read) ]]
|
||||
then
|
||||
TOKEN=$(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token)
|
||||
TOKEN=$(wxi-config login read)
|
||||
else
|
||||
read -s TOKEN
|
||||
fi
|
||||
@@ -193,11 +197,19 @@ wx-login(){
|
||||
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]
|
||||
then
|
||||
wxi-content status "Login" "Failed"
|
||||
wxi-stop
|
||||
wxi-footer
|
||||
|
||||
if [[ $(wxi-config login read) ]]
|
||||
then
|
||||
wx-logout &> /dev/null
|
||||
wx-login
|
||||
else
|
||||
wxi-stop
|
||||
fi
|
||||
fi
|
||||
|
||||
TOKEN=$VAULT_LOGIN
|
||||
wxi-config login
|
||||
wxi-config login write
|
||||
;;
|
||||
*)
|
||||
wxi-content status "Login Type" "Unsupported"
|
||||
|
||||
@@ -4,7 +4,7 @@ wx-init(){
|
||||
|
||||
if [[ ! -z ${args['hostname']} && ${#args['hostname']} -gt 5 ]]
|
||||
then
|
||||
HOSTNAME="${args['hostname']}.$DEVICE_DOMAIN"
|
||||
HOSTNAME="${args['hostname']}.devices.$DOMAIN"
|
||||
elif [[ $(hostname -d) ]]
|
||||
then
|
||||
HOSTNAME=$(hostname --fqdn)
|
||||
@@ -15,9 +15,12 @@ wx-init(){
|
||||
|
||||
if [[ ! -z ${args['device-type']} ]]
|
||||
then
|
||||
if [[ ${args['device-type']} == "server" || ${args['device-type']} == "workstation" ]]
|
||||
if [[ ${args['device-type']} == "server" ]]
|
||||
then
|
||||
DEVICE_TYPE="${args['device-type']}"
|
||||
DEVICE_TYPE="Server"
|
||||
elif [[ ${args['device-type']} == "workstation" ]]
|
||||
then
|
||||
DEVICE_TYPE="Workstation"
|
||||
else
|
||||
wxi-content status "Device Type" "Invalid"
|
||||
wxi-stop
|
||||
@@ -51,7 +54,7 @@ wx-init(){
|
||||
echo "---" > ~/.ansible/vars.yml
|
||||
echo "hostname: $HOSTNAME" >> ~/.ansible/vars.yml
|
||||
echo "info:" >> ~/.ansible/vars.yml
|
||||
echo " type: $TYPE" >> ~/.ansible/vars.yml
|
||||
echo " type: $DEVICE_TYPE" >> ~/.ansible/vars.yml
|
||||
echo "config:" >> ~/.ansible/vars.yml
|
||||
echo " identity:" >> ~/.ansible/vars.yml
|
||||
echo " vault:" >> ~/.ansible/vars.yml
|
||||
@@ -66,7 +69,7 @@ wx-init(){
|
||||
|
||||
/opt/ansible/bin/ansible-galaxy collection install ansible.posix ansible.utils ansible.windows community.crypto community.dns community.docker community.general community.grafana community.hashi_vault community.libvirt community.mongodb community.mysql community.postgresql community.windows containers.podman --upgrade &> /dev/null
|
||||
|
||||
/opt/ansible/bin/ansible-pull -U ssh://git@$GIT_DOMAIN:$GIT_PORT/$GIT_REPOSITORY -d ~/.ansible/pull/infra --accept-host-key --private-key ~/.ssh/keys/init --extra-vars @~/.ansible/vars.yml playbooks/init.yml -t init
|
||||
/opt/ansible/bin/ansible-pull -U ssh://git@$GIT_DOMAIN:$GIT_PORT/$GIT_REPOSITORY -d ~/.ansible/pull/infra --accept-host-key --private-key ~/.ssh/keys/init --extra-vars @~/.ansible/vars.yml init.yml -t init
|
||||
|
||||
unset HVT
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ wx-login(){
|
||||
elif [[ ! -z ${args['token']} ]]
|
||||
then
|
||||
AUTH_METHOD=token
|
||||
elif [[ -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != 'null' && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != '' ]]
|
||||
elif [[ $(wxi-config login read) ]]
|
||||
then
|
||||
AUTH_METHOD=token
|
||||
elif [[ ! -z ${args['username']} ]]
|
||||
@@ -61,11 +61,12 @@ wx-login(){
|
||||
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]
|
||||
then
|
||||
wxi-content status "Login" "Failed"
|
||||
wxi-footer
|
||||
wxi-stop
|
||||
fi
|
||||
|
||||
TOKEN=$VAULT_LOGIN
|
||||
wxi-config login
|
||||
wxi-config login write
|
||||
;;
|
||||
token)
|
||||
echo -n "Token: "
|
||||
@@ -75,9 +76,9 @@ wx-login(){
|
||||
then
|
||||
TOKEN=${args['token']}
|
||||
fi
|
||||
elif [[ -f "$HOME/.warengroup/config.json" && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != 'null' && $(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token) != '' ]]
|
||||
elif [[ $(wxi-config login read) ]]
|
||||
then
|
||||
TOKEN=$(cat $HOME/.warengroup/config.json | jq -r .login.$ORG.token)
|
||||
TOKEN=$(wxi-config login read)
|
||||
else
|
||||
read -s TOKEN
|
||||
fi
|
||||
@@ -105,11 +106,19 @@ wx-login(){
|
||||
if [[ -z $VAULT_LOGIN || ${#VAULT_LOGIN} -lt 95 || ${#VAULT_LOGIN} -gt 95 ]]
|
||||
then
|
||||
wxi-content status "Login" "Failed"
|
||||
wxi-stop
|
||||
wxi-footer
|
||||
|
||||
if [[ $(wxi-config login read) ]]
|
||||
then
|
||||
wx-logout &> /dev/null
|
||||
wx-login
|
||||
else
|
||||
wxi-stop
|
||||
fi
|
||||
fi
|
||||
|
||||
TOKEN=$VAULT_LOGIN
|
||||
wxi-config login
|
||||
wxi-config login write
|
||||
;;
|
||||
*)
|
||||
wxi-content status "Login Type" "Unsupported"
|
||||
|
||||
Reference in New Issue
Block a user