2013-12-02 19:29:18 -07:00
|
|
|
MINECRAFT_SERVER=/etc/init.d/minecraft_server
|
|
|
|
|
2013-11-15 19:49:01 -07:00
|
|
|
_minecraft_server() {
|
2013-12-02 14:13:18 -07:00
|
|
|
local CUR PREV OPTS WORLDS
|
|
|
|
COMPREPLY=()
|
|
|
|
CUR=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
PREV=${COMP_WORDS[COMP_CWORD-1]}
|
2013-11-14 20:25:01 -07:00
|
|
|
|
2013-12-07 09:44:13 -07:00
|
|
|
OPTS="
|
|
|
|
backup create delete disable enable force-restart force-stop list
|
|
|
|
logrotate map new overviewer remove restart screen send show start status
|
|
|
|
stop sync update watch
|
|
|
|
"
|
|
|
|
|
|
|
|
LIST_OPTS="enabled disabled running stopped"
|
2013-11-14 20:25:01 -07:00
|
|
|
|
2013-12-02 14:13:18 -07:00
|
|
|
if [ $COMP_CWORD -eq 1 ]; then
|
|
|
|
COMPREPLY=($(compgen -W "$OPTS" -- $CUR))
|
|
|
|
else
|
|
|
|
case $PREV in
|
2013-12-07 09:44:13 -07:00
|
|
|
start)
|
|
|
|
WORLDS=$($MINECRAFT_SERVER list stopped)
|
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- $CUR))
|
|
|
|
;;
|
|
|
|
stop|force-stop|restart|force-restart|send)
|
|
|
|
WORLDS=$($MINECRAFT_SERVER list running)
|
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- $CUR))
|
|
|
|
;;
|
|
|
|
delete|remove|disable|status|show|sync|send|screen|watch|logrotate| \
|
|
|
|
backup|map|overviewer)
|
|
|
|
WORLDS=$($MINECRAFT_SERVER list enabled)
|
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- $CUR))
|
|
|
|
;;
|
|
|
|
enable)
|
|
|
|
WORLDS=$($MINECRAFT_SERVER list disabled)
|
2013-12-02 14:13:18 -07:00
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- $CUR))
|
|
|
|
;;
|
2013-12-07 09:44:13 -07:00
|
|
|
ls|list)
|
|
|
|
COMPREPLY=($(compgen -W "$LIST_OPTS" -- $CUR))
|
|
|
|
;;
|
2013-12-02 14:13:18 -07:00
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
return 0
|
2013-11-14 20:25:01 -07:00
|
|
|
}
|
2013-12-02 19:29:18 -07:00
|
|
|
complete -F _minecraft_server $MINECRAFT_SERVER
|