add text in colors
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
6b9c5e64b8
commit
e398a50337
4 changed files with 38 additions and 7 deletions
6
agent.sh
6
agent.sh
|
|
@ -1,8 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# red delete
|
||||||
|
# orange check-no-delete
|
||||||
|
# orange check-no-create
|
||||||
|
# green create
|
||||||
|
|
||||||
[[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)"
|
[[ -f ./libs/shflags ]] && . ./libs/shflags || eval "$(curl --silent https://git.g3e.fr/H6N/tools/raw/branch/main/libs/shflags)"
|
||||||
|
|
||||||
. ./lib/vpc.sh
|
. ./lib/vpc.sh
|
||||||
|
. ./lib/colors.sh
|
||||||
|
|
||||||
DRY_RUN="1"
|
DRY_RUN="1"
|
||||||
SIMULATION="1"
|
SIMULATION="1"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
. ./lib/vpc.sh
|
export TERM=xterm-256color
|
||||||
|
|
||||||
delete_vpc "${1}"
|
for i in {0..255}; do
|
||||||
|
echo -e "\033[38;5;${i}m$i\t"
|
||||||
|
if (( ($i + 1) % 10 == 0 )); then echo; fi
|
||||||
|
done
|
||||||
|
echo -e "\e[0m"
|
||||||
|
|
||||||
|
printf "\033[38;5;208mTexte en orange (code 208)\033[0m\n"
|
||||||
14
lib/colors.sh
Normal file
14
lib/colors.sh
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
COLOR_RED="196"
|
||||||
|
COLOR_ORANGE="208"
|
||||||
|
COLOR_GREEN="154"
|
||||||
|
COLOR_GREY="246"
|
||||||
|
|
||||||
|
function print_in_color {
|
||||||
|
color="${1}"
|
||||||
|
text="${2}"
|
||||||
|
|
||||||
|
echo -e "\033[38;5;${color}m${text}\e[0m"
|
||||||
|
|
||||||
|
}
|
||||||
15
lib/vpc.sh
15
lib/vpc.sh
|
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
. ./lib/db.sh
|
. ./lib/db.sh
|
||||||
. ./lib/netns.sh
|
. ./lib/netns.sh
|
||||||
|
. ./lib/colors.sh
|
||||||
|
|
||||||
function check_vpc_exist {
|
function check_vpc_exist {
|
||||||
vpc_name=${1}
|
vpc_name=${1}
|
||||||
|
|
||||||
echo "#check if the vpc ${vpc} exist"
|
print_in_color "${COLOR_GREY}" "Check in db if ${vpc_name} exist"
|
||||||
echo " -> check in file"
|
|
||||||
echo " -> check in linux"
|
|
||||||
|
|
||||||
check_in_db vpc "${vpc_name}"
|
check_in_db vpc "${vpc_name}"
|
||||||
[ "$?" -eq "0" ] || return 1
|
[ "$?" -eq "0" ] || return 1
|
||||||
|
print_in_color "${COLOR_GREY}" "Check in linux if ${vpc_name} exist"
|
||||||
check_netns "${vpc_name}"
|
check_netns "${vpc_name}"
|
||||||
[ "$?" -eq "0" ] || return 1
|
[ "$?" -eq "0" ] || return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -22,10 +21,14 @@ function create_vpc {
|
||||||
vpc_name="${2}"
|
vpc_name="${2}"
|
||||||
|
|
||||||
check_vpc_exist "${vpc_name}"
|
check_vpc_exist "${vpc_name}"
|
||||||
[ "$?" -eq "0" ] || \
|
[ "$?" -eq "0" ] && \
|
||||||
|
{
|
||||||
|
print_in_color "${COLOR_ORANGE}" "Create ${vpc_name}"
|
||||||
|
} || \
|
||||||
{
|
{
|
||||||
add_in_db "vpc" "${vpc_name}"
|
add_in_db "vpc" "${vpc_name}"
|
||||||
create_netns "${vpc_name}"
|
create_netns "${vpc_name}"
|
||||||
|
print_in_color "${COLOR_GREEN}" "Create ${vpc_name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -34,6 +37,8 @@ function delete_vpc {
|
||||||
dryrun="${1}"
|
dryrun="${1}"
|
||||||
vpc_name="${2}"
|
vpc_name="${2}"
|
||||||
|
|
||||||
|
|
||||||
|
print_in_color "${COLOR_RED}" "Delete ${vpc_name}"
|
||||||
delete_in_db "vpc" "${vpc_name}"
|
delete_in_db "vpc" "${vpc_name}"
|
||||||
delete_netns "${vpc_name}"
|
delete_netns "${vpc_name}"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue