feat: "server_exists" check

This commit is contained in:
2020-08-08 06:14:17 +03:00
parent d7502e7cbe
commit 2dbd001d3c
28 changed files with 111 additions and 262 deletions

View File

@ -95,6 +95,11 @@ function is_version () # $1: Arg
echo "$1" | grep -Piqo '^(-v|--version|version)$'
}
function server_exists ()
{
test -x "$AppBin"
}
function function_exists () # $1: function name
{
type "$1" &> /dev/null
@ -194,7 +199,11 @@ elif [[ -d "$GroupPathname" ]]; then
fi
else
if function_exists "cmd_main"; then
if function_exists "cmd_need_superuser" && cmd_need_superuser; then
if function_exists "cmd_need_installed_server" && cmd_need_installed_server && ! server_exists; then
echo "You must install server first"
echo "Run \"${ScriptName}${KF2POSTFIX} game update\" to install it"
exit 1
elif function_exists "cmd_need_superuser" && cmd_need_superuser; then
run_as_root "${ScriptFullname}${KF2POSTFIX}" "$Group" "$Command" "$@"
elif function_exists "cmd_need_steamuser" && cmd_need_steamuser; then
run_as_steamuser "${ScriptFullname}${KF2POSTFIX}" "$Group" "$Command" "$@"