mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-26 16:28:28 +00:00
Enumerate all instances in @all; add list-instances command
This commit is contained in:
parent
f7e8b1ada9
commit
95cd1002e1
@ -1471,6 +1471,41 @@ printStatus(){
|
|||||||
echo -e "$NORMAL" "Server version: " "$GREEN" $instver "$NORMAL"
|
echo -e "$NORMAL" "Server version: " "$GREEN" $instver "$NORMAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAllInstanceNames(){
|
||||||
|
declare -A instancenames
|
||||||
|
for varname in "${!configfile_@}"; do
|
||||||
|
instancename="${varname#configfile_}"
|
||||||
|
instancenames[${instancename}]="${instancename}"
|
||||||
|
done
|
||||||
|
for f in /etc/arkmanager/instances/*.cfg; do
|
||||||
|
if [ -f "${f}" ]; then
|
||||||
|
instancename="${f##*/}"
|
||||||
|
instancename="${instancename%.cfg}"
|
||||||
|
instancenames[${instancename}]="${instancename}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for f in ${HOME}/.config/arkmanager/instances/*.cfg; do
|
||||||
|
if [ -f "${f}" ]; then
|
||||||
|
instancename="${f##*/}"
|
||||||
|
instancename="${instancename%.cfg}"
|
||||||
|
instancenames[${instancename}]="${instancename}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "${instancenames[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
doListAllInstances(){
|
||||||
|
echo "The following instances are available:"
|
||||||
|
for n in $(getAllInstanceNames); do
|
||||||
|
(
|
||||||
|
echo -n " @${n}: "
|
||||||
|
useConfig "$n"
|
||||||
|
echo "${arkserverroot}"
|
||||||
|
)
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
useConfig() {
|
useConfig() {
|
||||||
if [ -f "/etc/arkmanager/instances/${1}.cfg" ]; then
|
if [ -f "/etc/arkmanager/instances/${1}.cfg" ]; then
|
||||||
source "/etc/arkmanager/instances/${1}.cfg"
|
source "/etc/arkmanager/instances/${1}.cfg"
|
||||||
@ -1501,6 +1536,7 @@ showUsage() {
|
|||||||
echo "upgrade-tools Check for a new ARK Server Tools version and upgrades it if needed"
|
echo "upgrade-tools Check for a new ARK Server Tools version and upgrades it if needed"
|
||||||
echo "uninstall-tools Uninstall the ARK Server Tools"
|
echo "uninstall-tools Uninstall the ARK Server Tools"
|
||||||
echo "useconfig <name> Sets the default instance for the commands that follow"
|
echo "useconfig <name> Sets the default instance for the commands that follow"
|
||||||
|
echo "list-instances Lists all available instances"
|
||||||
echo "--help Show this help"
|
echo "--help Show this help"
|
||||||
echo "--version Show the version info of ARK Server Tools"
|
echo "--version Show the version info of ARK Server Tools"
|
||||||
echo
|
echo
|
||||||
@ -1601,6 +1637,10 @@ while true; do
|
|||||||
defaultinstance="${args[0]}"
|
defaultinstance="${args[0]}"
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
|
list-instances)
|
||||||
|
doListAllInstances
|
||||||
|
exit
|
||||||
|
;;
|
||||||
--version)
|
--version)
|
||||||
echo "Version: ${arkstVersion}"
|
echo "Version: ${arkstVersion}"
|
||||||
echo "Channel: ${arkstChannel}"
|
echo "Channel: ${arkstChannel}"
|
||||||
@ -1638,10 +1678,7 @@ while true; do
|
|||||||
|
|
||||||
# Handle all instances being requested
|
# Handle all instances being requested
|
||||||
if [[ "$allinstances" == "yes" ]]; then
|
if [[ "$allinstances" == "yes" ]]; then
|
||||||
instances=( )
|
instances=( $(getAllInstanceNames) )
|
||||||
for varname in "${!configfile_@}"; do
|
|
||||||
instances+=( "${varname#configfile_}" )
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the command for each instance requested
|
# Run the command for each instance requested
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user