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

View File

@ -1,9 +1,13 @@
wx-help() {
echo -n ">>> Help <<<";
echo "
echo -n "$wxItalic"
echo " >> Help << "
echo -n "$wxNormal";
echo "------------------------------"
echo -n "
Usage: $0 COMMAND [OPTIONS]
Common Commands:
init Init
ssh SSH
config Config
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() {
echo -n ">>> Settings <<<";
wx-login
echo -n "$wxItalic"
echo " >> Settings << "
echo -n "$wxNormal";
echo "------------------------------"
}

View File

@ -1,3 +1,8 @@
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(){
echo -n ">>> SSH: Config <<<"
echo -n "$wxItalic"
echo " >> SSH : Config << "
echo -n "$wxNormal"
echo "------------------------------"
}

View File

@ -1,3 +1,6 @@
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() {
echo -n ">>> Welcome <<<"
echo -n "$wxItalic"
echo " >> Welcome << "
echo -n "$wxNormal"
echo "------------------------------"
}

View File

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

View File

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

76
wx
View File

@ -5,8 +5,25 @@ if [ ! "$BASH_VERSION" ] ; then
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)
wxItalic=$(tput sitm)
wxBold=$(tput bold)
wxNormal=$(tput sgr0)
wx-login() {
echo ">>> Login <<<"
echo -n "$wxItalic"
echo " >> Login << "
echo -n "$wxNormal";
echo "------------------------------"
ORG=$2
if [[ -z "$HOSTNAME" || ${#HOSTNAME} -lt 5 ]]; then
@ -100,6 +117,7 @@ wx-login() {
wx-stop
fi
echo ""
wx-start
else
echo "Organization: $ORG"
echo "Status: IDM Offline"
@ -154,7 +172,9 @@ wx-start() {
echo ""
echo ""
echo "=============================="
echo -n "$wxBold"
echo " Warén CLI "
echo -n "$wxNormal"
echo "=============================="
}
@ -179,11 +199,15 @@ wx-stop () {
}
wx-help() {
echo -n ">>> Help <<<";
echo "
echo -n "$wxItalic"
echo " >> Help << "
echo -n "$wxNormal";
echo "------------------------------"
echo -n "
Usage: $0 COMMAND [OPTIONS]
Common Commands:
init Init
ssh SSH
config Config
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() {
echo -n ">>> Settings <<<";
wx-login
echo -n "$wxItalic"
echo " >> Settings << "
echo -n "$wxNormal";
echo "------------------------------"
}
wx-ssh() {
echo -n ">>> SSH <<<";
wx-login
echo -n "$wxItalic"
echo " >> SSH << "
echo -n "$wxNormal";
echo "------------------------------"
}
wx-welcome() {
echo -n ">>> Welcome <<<"
echo -n "$wxItalic"
echo " >> Welcome << "
echo -n "$wxNormal"
echo "------------------------------"
}
wx-ssh-config(){
echo -n ">>> SSH: Config <<<"
echo -n "$wxItalic"
echo " >> SSH : Config << "
echo -n "$wxNormal"
echo "------------------------------"
}
wx-ssh-sign(){
echo -n ">>> SSH: Certificates <<<"
echo -n "$wxItalic"
echo " >> SSH : Certificates << "
echo -n "$wxNormal"
echo "------------------------------"
}
wx-start
if [[ ! -z $1 ]] && [[ $(type -t wx-$1) == function ]]
then
wx-login
wx-start
wx-$1 $2 $3 $4 $5 $6 $7 $8 $9
else
wx-welcome