Archived
0
This repository has been archived on 2022-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
project-ctl/ctl
2022-02-17 13:27:51 +03:00

52 lines
1.1 KiB
Bash
Executable File

#!/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 $@