Fixed a lot of bugs, added colors

This commit is contained in:
Marcel Hanraets 2014-07-18 19:46:40 +02:00
parent 58a66b13d1
commit 26e4646b2e

View File

@ -7,6 +7,7 @@
red='\033[0;31m'
orange='\033[0;33m'
green='\033[0;32m'
cyan='\033[0;36m'
NC='\033[0m'
server_running() {
@ -22,7 +23,7 @@ case "$1" in
if server_running; then
sudo -u ${USER} tmux attach -t craftbukkit-console
else
echo -e "${orange}[warn]${NC} No server running ... ${orange}(warning).${NC}"
echo -e "[]${orange}warn${NC}] No server running ... ${orange}(warning).${NC}"
exit 7
fi
;;
@ -35,52 +36,54 @@ case "$1" in
# @TODO
;;
whitelist-add)
wl-add)
if server_running; then
if [ $# -gt 1 && $# -lt 3 ]; then
if [ $# -gt 1 ] && [ $# -lt 3 ]; then
shift
sudo -u ${USER} -H tmux send-keys -t craftbukkit-console "whitelist add $2" C-m >/dev/null 2>&1
sudo -u ${USER} -H tmux send-keys -t craftbukkit-console "whitelist add ${1}" C-m >/dev/null 2>&1
sudo -u ${USER} -H tmux send-keys -t craftbukkit-console "whitelist reload" C-m >/dev/null 2>&1
else
echo "Usage: $0 $1 [username]"
echo -e "[${cyan}info${NC}] Usage: $0 $1 [USER]"
exit 1
fi
else
echo -e "${orange}[warn]${NC} No server running ... ${orange}(warning).${NC}"
echo -e "[${orange}warn${NC}] No server running ... ${orange}(warning).${NC}"
exit 7
fi
;;
whitelist-remove)
wl-rm)
if server_running; then
if [ $# -gt 1 && $# -lt 3 ]; then
if [ $# -gt 1 ] && [ $# -lt 3 ]; then
shift
sudo -u ${USER} -H tmux send-keys -t craftbukkit-console "whitelist remove $2" C-m >/dev/null 2>&1
sudo -u ${USER} -H tmux send-keys -t craftbukkit-console "whitelist remove ${1}" C-m >/dev/null 2>&1
sudo -u ${USER} -H tmux send-keys -t craftbukkit-console "whitelist reload" C-m >/dev/null 2>&1
else
echo "Usage: $0 $1 [username]"
echo -e "[${cyan}info${NC}] Usage: $0 $1 [USER]"
exit 1
fi
else
echo -e "${orange}[warn]${NC} No server running ... ${orange}(warning).${NC}"
echo -e "[${orange}warn${NC}] No server running ... ${orange}(warning).${NC}"
exit 7
fi
;;
--help|-h)
echo "Usage: $0 COMMAND"
echo -e "[${cyan}info${NC}] Usage: $0 COMMAND"
echo
echo "Available commands:"
echo -e " console \t\t Connects to the console"
echo -e " console \t Connects to the console"
echo -e " backup \t\t Creates a world backup"
echo -e " full-backup \t Creates a full backup"
echo -e " wl-add \t\t Creates a full backup"
echo -e " wl-rm \t\t Creates a full backup"
echo -e " wl-add [USER]\t\t Creates a full backup"
echo -e " wl-rm [USER]\t\t Creates a full backup"
echo -e " --help, -h \t Prints this page"
;;
*)
echo "No such command"
echo "Usage: $0 {console|backup|full-backup|wl-add|wl-rm}"
echo "Or try $0 --help for help"
echo -e "[${cyan}info${NC}] No such command"
echo -e "[${cyan}info${NC}] Usage: $0 {console|backup|full-backup|wl-add|wl-rm}"
echo -e "[${cyan}info${NC}] Or try $0 --help for help"
exit 1
;;
esac