Source Update

This commit is contained in:
Christer Warén 2024-04-27 23:32:06 +03:00
parent 91ae087bd4
commit b2d3908d6f
11 changed files with 133 additions and 22 deletions

View File

@ -5,14 +5,25 @@ if [ ! "$BASH_VERSION" ] ; then
exit 1 exit 1
fi 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)
wxItalic=$(tput sitm)
wxBold=$(tput bold)
wxNormal=$(tput sgr0)
{{ FUNCTIONS }} {{ FUNCTIONS }}
{{ COMMANDS }} {{ COMMANDS }}
wx-start wx-start
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]] if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then then
wx-login
wx-start
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9 wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
else else
wx-welcome wx-welcome

View File

@ -1,9 +1,13 @@
wx-help() { wx-help() {
echo -n ">>> Help <<<"; echo -n "$wxItalic"
echo " echo " >> Help << "
echo -n "$wxNormal";
echo "------------------------------"
echo -n "
Usage: $0 COMMAND [OPTIONS] Usage: $0 COMMAND [OPTIONS]
Common Commands: Common Commands:
init Init
ssh SSH ssh SSH
config Config config Config
sign Certificates sign Certificates

14
src/commands/init.sh Normal file
View File

@ -0,0 +1,14 @@
wx-init () {
wx-login
echo -n "$wxItalic"
echo " >> Init << "
echo -n "$wxNormal";
echo "------------------------------"
mkdir -p ~/.ssh &> /dev/null
apt-get install -y python3-pip python3-venv jq git curl &> /dev/null
python3 -m venv /opt/ansible &> /dev/null
/opt/ansible/bin/pip3 install ansible hvac netaddr jmespath pexpect &> /dev/null
}

View File

@ -1,3 +1,8 @@
wx-settings() { wx-settings() {
echo -n ">>> Settings <<<"; wx-login
echo -n "$wxItalic"
echo " >> Settings << "
echo -n "$wxNormal";
echo "------------------------------"
} }

View File

@ -1,3 +1,8 @@
wx-ssh() { wx-ssh() {
echo -n ">>> SSH <<<"; wx-login
echo -n "$wxItalic"
echo " >> SSH << "
echo -n "$wxNormal";
echo "------------------------------"
} }

View File

@ -1,3 +1,6 @@
wx-ssh-config(){ wx-ssh-config(){
echo -n ">>> SSH: Config <<<" echo -n "$wxItalic"
echo " >> SSH : Config << "
echo -n "$wxNormal"
echo "------------------------------"
} }

View File

@ -1,3 +1,6 @@
wx-ssh-sign(){ wx-ssh-sign(){
echo -n ">>> SSH: Certificates <<<" echo -n "$wxItalic"
echo " >> SSH : Certificates << "
echo -n "$wxNormal"
echo "------------------------------"
} }

View File

@ -1,3 +1,6 @@
wx-welcome() { wx-welcome() {
echo -n ">>> Welcome <<<" echo -n "$wxItalic"
echo " >> Welcome << "
echo -n "$wxNormal"
echo "------------------------------"
} }

View File

@ -1,5 +1,9 @@
wx-login() { wx-login() {
echo ">>> Login <<<" echo -n "$wxItalic"
echo " >> Login << "
echo -n "$wxNormal";
echo "------------------------------"
ORG=$2 ORG=$2
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then
@ -93,6 +97,7 @@ wx-login() {
wx-stop wx-stop
fi fi
echo "" echo ""
wx-start
else else
echo "Organization: $ORG" echo "Organization: $ORG"
echo "Status: IDM Offline" echo "Status: IDM Offline"

View File

@ -3,6 +3,8 @@ wx-start() {
echo "" echo ""
echo "" echo ""
echo "==============================" echo "=============================="
echo -n "$wxBold"
echo " Warén CLI " echo " Warén CLI "
echo -n "$wxNormal"
echo "==============================" echo "=============================="
} }

76
wx
View File

@ -5,8 +5,25 @@ if [ ! "$BASH_VERSION" ] ; then
exit 1 exit 1
fi 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)
wxItalic=$(tput sitm)
wxBold=$(tput bold)
wxNormal=$(tput sgr0)
wx-login() { wx-login() {
echo ">>> Login <<<" echo -n "$wxItalic"
echo " >> Login << "
echo -n "$wxNormal";
echo "------------------------------"
ORG=$2 ORG=$2
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then
@ -100,6 +117,7 @@ wx-login() {
wx-stop wx-stop
fi fi
echo "" echo ""
wx-start
else else
echo "Organization: $ORG" echo "Organization: $ORG"
echo "Status: IDM Offline" echo "Status: IDM Offline"
@ -154,7 +172,9 @@ wx-start() {
echo "" echo ""
echo "" echo ""
echo "==============================" echo "=============================="
echo -n "$wxBold"
echo " Warén CLI " echo " Warén CLI "
echo -n "$wxNormal"
echo "==============================" echo "=============================="
} }
@ -179,11 +199,15 @@ wx-stop () {
} }
wx-help() { wx-help() {
echo -n ">>> Help <<<"; echo -n "$wxItalic"
echo " echo " >> Help << "
echo -n "$wxNormal";
echo "------------------------------"
echo -n "
Usage: $0 COMMAND [OPTIONS] Usage: $0 COMMAND [OPTIONS]
Common Commands: Common Commands:
init Init
ssh SSH ssh SSH
config Config config Config
sign Certificates sign Certificates
@ -193,32 +217,64 @@ Management Commands:
"; ";
} }
wx-init () {
wx-login
echo -n "$wxItalic"
echo " >> Init << "
echo -n "$wxNormal";
echo "------------------------------"
mkdir -p ~/.ssh &> /dev/null
apt-get install -y python3-pip python3-venv jq git curl &> /dev/null
python3 -m venv /opt/ansible &> /dev/null
/opt/ansible/bin/pip3 install ansible hvac netaddr jmespath pexpect &> /dev/null
}
wx-settings() { wx-settings() {
echo -n ">>> Settings <<<"; wx-login
echo -n "$wxItalic"
echo " >> Settings << "
echo -n "$wxNormal";
echo "------------------------------"
} }
wx-ssh() { wx-ssh() {
echo -n ">>> SSH <<<"; wx-login
echo -n "$wxItalic"
echo " >> SSH << "
echo -n "$wxNormal";
echo "------------------------------"
} }
wx-welcome() { wx-welcome() {
echo -n ">>> Welcome <<<" echo -n "$wxItalic"
echo " >> Welcome << "
echo -n "$wxNormal"
echo "------------------------------"
} }
wx-ssh-config(){ wx-ssh-config(){
echo -n ">>> SSH: Config <<<" echo -n "$wxItalic"
echo " >> SSH : Config << "
echo -n "$wxNormal"
echo "------------------------------"
} }
wx-ssh-sign(){ wx-ssh-sign(){
echo -n ">>> SSH: Certificates <<<" echo -n "$wxItalic"
echo " >> SSH : Certificates << "
echo -n "$wxNormal"
echo "------------------------------"
} }
wx-start wx-start
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]] if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then then
wx-login
wx-start
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9 wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
else else
wx-welcome wx-welcome