Archived
0

update scritp

This commit is contained in:
dedic-one
2022-01-14 13:27:51 +03:00
parent 7c1a3173a7
commit e0e3659d44
5 changed files with 225 additions and 143 deletions

51
ctl Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# vi: set tabstop=4 shiftwidth=4 expandtab :
ROOTDIR=$(cd "$(dirname "$0")" && pwd)
cd $ROOTDIR
declare -A MAP_COMMAND
# === Log ==================================================================== #
CW="\033[1;37m" # White
CG="\033[0;32m" # Green
CY="\033[0;33m" # Yellow
NC="\033[0m" # Reset
function log {
local II="${CW}╡${CG}ctl${CW}╞${NC}"
echo -e "${II} $@"
}
log "${CY}Container Control Script ${CG}b20220114-0500${NC}"
# === Import ================================================================= #
for V in $(ls $ROOTDIR/ctl.d/*.sh)
do
. $V
done
# === Main =================================================================== #
function main {
local args=($@)
local command=${args[0]}
if [[ -n $command ]]
then
for cmd in $(echo "${!MAP_COMMAND[@]}")
do
if [ $command = $cmd ]
then
${MAP_COMMAND[$cmd]} ${args[@]:1}
return
fi
done
fi
print_help
}
function print_help {
local vvv=$(echo "${!MAP_COMMAND[@]}" | tr ' ' "\n" | sort | tr "\n" ',' | sed 's/,/, /g')
log "Use: ${vvv:: -2}"
}
main $@