feat: "server_exists" check

This commit is contained in:
GenZmeY 2020-08-08 06:14:17 +03:00
parent 30b35fa24e
commit bfc5e000f7
28 changed files with 111 additions and 262 deletions

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "<id>..."
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main () # $*: ban list
{
include "$LibDir/ban.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "<id>..."
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main () # $*: ban list
{
include "$LibDir/ban.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo ""
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/ban.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo ""
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/ban.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/game.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { true ;}
function cmd_usage ()
{
echo "[<args>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/game.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo ""
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/game.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { true ;}
function cmd_usage ()
{
echo ""
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/game.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { true ;}
function cmd_usage ()
{
echo "<name>..."
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { true ;}
function cmd_usage ()
{
echo "<message> [<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { true ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { true ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { true ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { true ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
true
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/instance.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main () # $*: Instance[s]
{
include "$LibDir/maprotate.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main () # $*: Instance[s]
{
include "$LibDir/maprotate.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "<password> [<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/password.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "<password> [<instance>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/password.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<workshop_id>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/workshop.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo "[<workshop_id>...]"
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/workshop.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { false ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo ""
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
false
}
function cmd_main ()
{
include "$LibDir/workshop.lib"

View File

@ -19,6 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
cmd_need_superuser () { false ;}
cmd_need_steamuser () { true ;}
cmd_need_installed_server () { false ;}
function cmd_usage ()
{
echo ""
@ -34,16 +38,6 @@ function cmd_help ()
echo "TODO: description"
}
function cmd_need_superuser ()
{
false
}
function cmd_need_steamuser ()
{
true
}
function cmd_main ()
{
include "$LibDir/workshop.lib"

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" "$@"

View File

@ -18,7 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
function game_fix_permissions () # $*: Instance[s]
{
local InstanceList="$*"
@ -100,12 +100,6 @@ function game_validate ()
instance_start
}
function server_exists ()
{
test -x "$AppBin"
return $?
}
function first_install ()
{
include /etc/steamcmd/steamcmd.conf

View File

@ -65,10 +65,6 @@ function instance_add () # $*: InstanceName[s]
if [[ -z "$*" ]]; then
echo "Name of instance[s] must be set"
exit 1
elif ! server_exists; then
echo "You must install server first"
echo "Run \"${ScriptName}${KF2POSTFIX} game update\" to install it"
exit 1
fi
local MaxGamePort='7777'