Merge pull request #706 from AnEmortalKid/master

Adding bash_complete for server names
This commit is contained in:
Ben Peddell 2017-01-04 18:31:09 +11:00 committed by GitHub
commit b7adf23404
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,33 @@
# a bash_completion for arkmanager with server names
# ARK: survival evolved manager
#
# Original author: AnEmortalKid
_arkmanager()
{
local cur prev opts home_instances etc_instances
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# retrieve the ones in /etc/arkmanager/instances first
etc_instances=$(for f in `ls -1 /etc/arkmanager/instances/*.cfg`; do if [ -f "${f}" ]; then instancename="${f##*/}"; echo "@${instancename%.cfg}"; fi done)
# check that ${HOME}/.config/arkmanager/instances exists
if [ -d "${HOME}/.config/arkmanager/instances/" ] ; then
# check that it also isn't empty if it exists
if [ "$(ls -A ${HOME}/.config/arkmanager/instances/)" ] ; then
home_instances=$(for f in `ls -1 ${HOME}/.config/arkmanager/instances/*.cfg`; do if [ -f "${f}" ]; then instancename="${f##*/}"; echo "@${instancename%.cfg}"; fi done)
fi
fi
# append both results together for the completion
all_instances="@all ${etc_instances} ${home_instances}"
if [[ ${cur} == @* ]] ; then
COMPREPLY=( $(compgen -W "${all_instances}" -- ${cur}) )
return 0
fi
}
complete -F _arkmanager arkmanager

View File

@ -308,6 +308,9 @@ else
# Copy example instance config
cp instance.cfg.example "${INSTALL_ROOT}${INSTANCEDIR}/instance.cfg.example"
# Copy arkmanager bash_completion into /etc/bash_completion.d/
cp bash_completion/arkmanager "${INSTALL_ROOT}/etc/bash_completion.d/arkmanager"
# Copy arkmanager.cfg inside linux configuation folder if it doesn't already exists
mkdir -p "${INSTALL_ROOT}/etc/arkmanager"
chown "$steamcmd_user" "${INSTALL_ROOT}/etc/arkmanager"

View File

@ -35,3 +35,8 @@ if [ -n "$INITSCRIPT" ]; then
fi
done
fi
# remove bash_completion.d
if [ -f "/etc/bash_completion.d/arkmanager" ]; then
rm "/etc/bash_completion.d/arkmanager"
fi