-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_check.sh
executable file
·48 lines (39 loc) · 1.48 KB
/
update_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
set -m
FACTORIO_VERSION="${FACTORIO_VERSION:-stable}"
# Get the old build id (default to 0)
OLD_BUILDID=0
if [ -f "/factorio/build.id" ]; then
OLD_BUILDID="$(cat /factorio/build.id)"
fi
# Get the new build id
NEW_BUILDID=$(curl -s --head -L https://www.factorio.com/get-download/${FACTORIO_VERSION}/headless/linux64 | grep ETag | tr -d '\n');
# Check that we actually got a new build id
STRING_SIZE=${#NEW_BUILDID}
if [ "$STRING_SIZE" -lt "6" ]; then
echo "Error getting latest server version, automatic updates disabled.."
echo "Response was: $NEW_BUILDID"
exit
fi
# Check if the builds match and quit if so
if [ "$OLD_BUILDID" = "$NEW_BUILDID" ]; then
echo "Version $OLD_BUILDID is already the latest, skipping update.."
exit
else
echo "Latest server version ($NEW_BUILDID) is newer than the current one ($OLD_BUILDID), updating.."
if [ -z "$1" ]
then
# If Factorio is already running (This isn't the startup run), we simply close it, which restarts the container
kill 1
else
#This is the startup run
#LATEST_LINK=$(node /scraper/app.js url);
LATEST_LINK=https://www.factorio.com/get-download/${FACTORIO_VERSION}/headless/linux64
#wget -q --show-progress --no-check-certificate $LATEST_LINK -O /factorio.tar.xz && \
wget -q --no-check-certificate $LATEST_LINK -O /factorio.tar.xz && \
tar -xJf /factorio.tar.xz -C / && \
chmod +x /factorio/bin/x64/factorio && \
rm -fr /factorio.tar.xz
echo $NEW_BUILDID > /factorio/build.id
fi
fi