mirror of
https://github.com/MinecraftServerControl/mscs.git
synced 2024-11-15 06:48:16 -07:00
48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
MINECRAFT_SERVER=/etc/init.d/minecraft_server
|
|
|
|
_minecraft_server() {
|
|
local CUR PREV OPTS WORLDS
|
|
COMPREPLY=()
|
|
CUR=${COMP_WORDS[COMP_CWORD]}
|
|
PREV=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
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"
|
|
|
|
if [ $COMP_CWORD -eq 1 ]; then
|
|
COMPREPLY=($(compgen -W "$OPTS" -- $CUR))
|
|
else
|
|
case $PREV in
|
|
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)
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- $CUR))
|
|
;;
|
|
ls|list)
|
|
COMPREPLY=($(compgen -W "$LIST_OPTS" -- $CUR))
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
fi
|
|
return 0
|
|
}
|
|
complete -F _minecraft_server $MINECRAFT_SERVER
|