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
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/netns.sh
|
||||
. ./lib/colors.sh
|
||||
|
||||
function check_vpc_exist {
|
||||
vpc_name=${1}
|
||||
|
||||
echo "#check if the vpc ${vpc} exist"
|
||||
echo " -> check in file"
|
||||
echo " -> check in linux"
|
||||
|
||||
print_in_color "${COLOR_GREY}" "Check in db if ${vpc_name} exist"
|
||||
check_in_db vpc "${vpc_name}"
|
||||
[ "$?" -eq "0" ] || return 1
|
||||
print_in_color "${COLOR_GREY}" "Check in linux if ${vpc_name} exist"
|
||||
check_netns "${vpc_name}"
|
||||
[ "$?" -eq "0" ] || return 1
|
||||
return 0
|
||||
|
|
@ -22,10 +21,14 @@ function create_vpc {
|
|||
vpc_name="${2}"
|
||||
|
||||
check_vpc_exist "${vpc_name}"
|
||||
[ "$?" -eq "0" ] || \
|
||||
[ "$?" -eq "0" ] && \
|
||||
{
|
||||
print_in_color "${COLOR_ORANGE}" "Create ${vpc_name}"
|
||||
} || \
|
||||
{
|
||||
add_in_db "vpc" "${vpc_name}"
|
||||
create_netns "${vpc_name}"
|
||||
print_in_color "${COLOR_GREEN}" "Create ${vpc_name}"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,6 +37,8 @@ function delete_vpc {
|
|||
dryrun="${1}"
|
||||
vpc_name="${2}"
|
||||
|
||||
|
||||
print_in_color "${COLOR_RED}" "Delete ${vpc_name}"
|
||||
delete_in_db "vpc" "${vpc_name}"
|
||||
delete_netns "${vpc_name}"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue