mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-24 07:28:27 +00:00
Allow all commands to take options
This commit is contained in:
parent
2907c51250
commit
6606ed3cd2
@ -1456,12 +1456,51 @@ useConfig() {
|
|||||||
checkConfig
|
checkConfig
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
options=( )
|
||||||
|
args=( )
|
||||||
|
command="$1"
|
||||||
|
shift
|
||||||
|
nrarg=0
|
||||||
|
|
||||||
|
# get the number of arguments for commands that take arguments
|
||||||
|
case "$command" in
|
||||||
|
installmod) nrarg=1; ;;
|
||||||
|
broadcast) nrarg=1; ;;
|
||||||
|
rconcmd) nrarg=1; ;;
|
||||||
|
useconfig) nrarg=1; ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Enumerate the options and arguments
|
||||||
|
while [ $# -ne 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
--args)
|
||||||
|
nrarg=$#
|
||||||
|
;;
|
||||||
|
--*)
|
||||||
|
options+=( "$1" )
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [ $nrarg -gt 0 ]; then
|
||||||
|
args+=( "$1" )
|
||||||
|
(( nrarg-- ))
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
case "$command" in
|
||||||
run)
|
run)
|
||||||
doRun
|
doRun
|
||||||
;;
|
;;
|
||||||
start)
|
start)
|
||||||
if [ "$2" == "--all" ]; then
|
if [ " ${options[*]} " =~ " --all " ]; then
|
||||||
doStartAll
|
doStartAll
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
@ -1469,6 +1508,7 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
|
if [ " ${options[*]} " =~ " --all " ]; then
|
||||||
if [ "$2" == "--all" ]; then
|
if [ "$2" == "--all" ]; then
|
||||||
doStopAll
|
doStopAll
|
||||||
shift
|
shift
|
||||||
@ -1477,6 +1517,7 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
|
if [ " ${options[*]} " =~ " --all " ]; then
|
||||||
if [ "$2" == "--all" ]; then
|
if [ "$2" == "--all" ]; then
|
||||||
doStopAll
|
doStopAll
|
||||||
else
|
else
|
||||||
@ -1484,6 +1525,7 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog"
|
echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
if [ " ${options[*]} " =~ " --all " ]; then
|
||||||
if [ "$2" == "--all" ]; then
|
if [ "$2" == "--all" ]; then
|
||||||
doStartAll
|
doStartAll
|
||||||
shift
|
shift
|
||||||
@ -1497,34 +1539,27 @@ while true; do
|
|||||||
doInstall
|
doInstall
|
||||||
;;
|
;;
|
||||||
update)
|
update)
|
||||||
args=()
|
doUpdate "${options[@]}"
|
||||||
|
|
||||||
while [[ "$2" =~ ^-- ]]; do
|
|
||||||
args=( "${args[@]}" "$2" )
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
doUpdate "${args[@]}"
|
|
||||||
;;
|
;;
|
||||||
checkupdate)
|
checkupdate)
|
||||||
checkForUpdate
|
checkForUpdate
|
||||||
;;
|
;;
|
||||||
installmod)
|
installmod)
|
||||||
doInstallMod "$2"
|
doInstallMod "${args[@]}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
backup)
|
backup)
|
||||||
doBackup
|
doBackup
|
||||||
;;
|
;;
|
||||||
broadcast)
|
broadcast)
|
||||||
doBroadcast "$2"
|
doBroadcast "${args[@]}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
saveworld)
|
saveworld)
|
||||||
doSaveWorld
|
doSaveWorld
|
||||||
;;
|
;;
|
||||||
rconcmd)
|
rconcmd)
|
||||||
rconcmd "$2"
|
rconcmd "${args[@]}"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
@ -1597,7 +1632,6 @@ while true; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
status=$?
|
status=$?
|
||||||
shift
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user