mirror of
https://github.com/iLLeniumStudios/fivem-resource-watcher
synced 2024-02-26 13:38:52 +01:00
Add support for ignoring certain resources
This commit is contained in:
+13
@@ -22,6 +22,17 @@ inputs:
|
||||
description: "Resources folder name"
|
||||
required: false
|
||||
default: "resources"
|
||||
restartServerWhen0Players:
|
||||
description: "Restart the server instead when there are no players on the server"
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
ignoreResources:
|
||||
description: "List of resources that you want to ignore separated by spaces and not restart when changes are made to them"
|
||||
required: false
|
||||
default: ""
|
||||
type: string
|
||||
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
@@ -31,3 +42,5 @@ runs:
|
||||
- ${{ inputs.serverPort }}
|
||||
- ${{ inputs.rconPassword }}
|
||||
- ${{ inputs.resourcesFolder }}
|
||||
- ${{ inputs.restartServerWhen0Players }}
|
||||
- ${{ inputs.ignoreResources }}
|
||||
|
||||
+6
-11
@@ -13,17 +13,6 @@ exists_in_array() {
|
||||
return 1
|
||||
}
|
||||
|
||||
exists_in_array() {
|
||||
local element="$1"
|
||||
local array_str="$2"
|
||||
for i in $array_str; do
|
||||
if [ "$i" = "$element" ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
append_if_not_exists() {
|
||||
local element="$1"
|
||||
local array_str="$2"
|
||||
@@ -45,6 +34,8 @@ SERVER_IP=$2
|
||||
SERVER_PORT=$3
|
||||
RCON_PASSWORD=$4
|
||||
RESOURCES_FOLDER=$5
|
||||
RESTART_SERVER_WHEN_0_PLAYERS=$6
|
||||
IGNORED_RESOURCES=$7
|
||||
|
||||
git config --global --add safe.directory /github/workspace
|
||||
|
||||
@@ -77,8 +68,12 @@ if ! is_array_empty "$resources_to_restart"; then
|
||||
if [ "$RESTART_INDIVIDUAL_RESOURCES" = true ]; then
|
||||
echo "Will restart individual resources"
|
||||
for resource in $resources_to_restart; do
|
||||
if exists_in_array "${resource}" "${IGNORED_RESOURCES}"; then
|
||||
echo "Ignoring restart of the resource ${resource}"
|
||||
else
|
||||
echo "Restarting ${resource}"
|
||||
icecon --command "ensure ${resource}" ${SERVER_IP}:${SERVER_PORT} ${RCON_PASSWORD}
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Will restart the whole server"
|
||||
|
||||
Reference in New Issue
Block a user