update scritp
This commit is contained in:
51
ctl
Executable file
51
ctl
Executable 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 $@
|
||||
Reference in New Issue
Block a user