-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsite
executable file
·50 lines (47 loc) · 1.03 KB
/
site
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
g="\e[32m" # green
d="\e[0m" # default
commands=$(ls _tools | grep ".sh" | sed "s/\.sh$//" | sort)
case $1 in
"help" | "" )
shift
script_name=$(basename $0)
if [ "$1" = "" ]; then
echo "Helper script to administer the site."
echo ""
echo "Usage: $script_name [COMMAND] [<parameter>]"
echo ""
echo "Available Commands:"
echo ""
for tool in $commands; do
echo -e " ${g}$tool${d}"
done
echo ""
echo "Help Command:"
echo ""
echo -e " ${g}help${d} [<command>]"
echo " Print this help when no command is given or a specific"
echo " <command> help if the <command> is given."
else
if echo "$commands" | grep -E "^$1$" > /dev/null; then
tool="_tools/$1.sh"
shift
$tool help
exit $?
else
echo "Error: The command '$1' doesn't exists."
exit 1
fi
fi
;;
* )
if echo "$commands" | grep -E "^$1$" > /dev/null; then
tool="_tools/$1.sh"
shift
$tool $@
exit $?
else
echo "Error: The command '$1' doesn't exists."
exit 1
fi
esac