From 26e4646b2e9dc7d66e95c65d1d3b8d00f07c1134 Mon Sep 17 00:00:00 2001 From: Marcel Hanraets Date: Fri, 18 Jul 2014 19:46:40 +0200 Subject: [PATCH] Fixed a lot of bugs, added colors --- craftmin.sh | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/craftmin.sh b/craftmin.sh index 9ab565e..ea6827b 100644 --- a/craftmin.sh +++ b/craftmin.sh @@ -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 " 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 " --help, -h \t Prints this page" + 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 [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