mirror of
https://github.com/iLLeniumStudios/fivem-resource-watcher
synced 2024-02-26 13:38:52 +01:00
Update
This commit is contained in:
+18
-15
@@ -1,21 +1,21 @@
|
|||||||
#!/bin/sh -l
|
#!/bin/sh -l
|
||||||
|
|
||||||
beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
|
beginswith() { case $2 in "$1"*) true ;; *) false ;; esac }
|
||||||
|
|
||||||
exists_in_array() {
|
exists_in_array() {
|
||||||
local element="$1"
|
local element="$1"
|
||||||
local array_str="$2"
|
local array_str="$2"
|
||||||
for i in $array_str; do
|
for i in $array_str; do
|
||||||
if [ "$i" = "$element" ]; then
|
if [ "$i" = "$element" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
is_array_empty() {
|
is_array_empty() {
|
||||||
local array_str="$1"
|
local array_str="$1"
|
||||||
[ -z "$array_str" ]
|
[ -z "$array_str" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
RESTART_INDIVIDUAL_RESOURCES=$1
|
RESTART_INDIVIDUAL_RESOURCES=$1
|
||||||
@@ -36,12 +36,12 @@ git config --global --add safe.directory /github/workspace
|
|||||||
if [ ${GITHUB_BASE_REF} ]; then
|
if [ ${GITHUB_BASE_REF} ]; then
|
||||||
# Pull Request
|
# Pull Request
|
||||||
git fetch origin ${GITHUB_BASE_REF} --depth=1
|
git fetch origin ${GITHUB_BASE_REF} --depth=1
|
||||||
export DIFF=$( git diff --name-only origin/${GITHUB_BASE_REF} ${GITHUB_SHA} )
|
export DIFF=$(git diff --name-only origin/${GITHUB_BASE_REF} ${GITHUB_SHA})
|
||||||
echo "Diff between origin/${GITHUB_BASE_REF} and ${GITHUB_SHA}"
|
echo "Diff between origin/${GITHUB_BASE_REF} and ${GITHUB_SHA}"
|
||||||
else
|
else
|
||||||
# Push
|
# Push
|
||||||
git fetch origin ${GITHUB_EVENT_BEFORE} --depth=1
|
git fetch origin ${GITHUB_EVENT_BEFORE} --depth=1
|
||||||
export DIFF=$( git diff --name-status ${GITHUB_EVENT_BEFORE} ${GITHUB_SHA} )
|
export DIFF=$(git diff --name-status ${GITHUB_EVENT_BEFORE} ${GITHUB_SHA})
|
||||||
echo "Diff between ${GITHUB_EVENT_BEFORE} and ${GITHUB_SHA}"
|
echo "Diff between ${GITHUB_EVENT_BEFORE} and ${GITHUB_SHA}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -61,7 +61,8 @@ echo "${DIFF}" | while read -r changed; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if ! is_array_empty "$resources_to_restart"; then
|
if ! is_array_empty "$resources_to_restart"; then
|
||||||
if [ "$RESTART_INDIVIDUAL_RESOURCES" = true ] ; then
|
echo "Array is not empty."
|
||||||
|
if [ "$RESTART_INDIVIDUAL_RESOURCES" = true ]; then
|
||||||
echo "Will restart individual resources"
|
echo "Will restart individual resources"
|
||||||
for resource in $resources_to_restart; do
|
for resource in $resources_to_restart; do
|
||||||
echo "Restarting ${resource}"
|
echo "Restarting ${resource}"
|
||||||
@@ -69,6 +70,8 @@ if ! is_array_empty "$resources_to_restart"; then
|
|||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Will restart the whole server"
|
echo "Will restart the whole server"
|
||||||
#rcon -a ${SERVER_IP}:${SERVER_PORT} -p ${RCON_PASSWORD} command 'quit "Restarting server"'
|
#rcon -a ${SERVER_IP}:${SERVER_PORT} -p ${RCON_PASSWORD} command 'quit "Restarting server"'
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Array is empty."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user