Compare commits
2 commits
c3ac5effc9
...
bb43c0d539
Author | SHA1 | Date | |
---|---|---|---|
bb43c0d539 | |||
412f124413 |
1 changed files with 11 additions and 66 deletions
|
@ -35,40 +35,19 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load the last downloaded Factorio version from config.sh, if available
|
# This handles automatically updating the Factorio binary.
|
||||||
if [ "$configpath" = "config.sh" ]; then
|
echo "Fetching Factorio binary..."
|
||||||
last_downloaded_version=$(grep -oP 'last_downloaded_version=\K[^"]*' "$configpath")
|
wget "https://factorio.com/get-download/${version}/headless/linux64" -O factorio_headless.tar.xz
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
last_download_version="None"
|
echo "FATAL: There is not a headless linux64 build available for the version you've selected in your ${configpath} file."
|
||||||
fi
|
echo "FATAL: See this website for a list of all Factorio versions: https://factorio.com/download/archive/"
|
||||||
else
|
|
||||||
last_downloaded_version="None"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the last downloaded version matches the current version
|
|
||||||
if [ "$last_downloaded_version" != "$version" ] || [ "$version" = "stable" ] || [ "$version" = "latest" ]; then
|
|
||||||
echo "Fetching Factorio binary..."
|
|
||||||
wget "https://factorio.com/get-download/${version}/headless/linux64" -O factorio_headless.tar.xz
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "FATAL: There is not a headless linux64 build available for the version you've selected in your ${configpath} file."
|
|
||||||
echo "FATAL: See this website for a list of all Factorio versions: https://factorio.com/download/archive/"
|
|
||||||
rm -f factorio_headless.tar.xz
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Extracting Factorio binary..."
|
|
||||||
tar -xf factorio_headless.tar.xz --strip-components=1 --overwrite
|
|
||||||
echo "Factorio binary updated!"
|
|
||||||
rm -f factorio_headless.tar.xz
|
rm -f factorio_headless.tar.xz
|
||||||
else
|
exit 1
|
||||||
echo "Not updating Factorio binary, as the existing version matches the version stated in the configuration file."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update the last downloaded version in the config.sh file
|
|
||||||
if [ "$configpath" = "config.sh" ]; then
|
|
||||||
sed -i "/last_downloaded_version=.*/i # This parameter is used for auto-updating the Factorio binary." "$configpath"
|
|
||||||
sed -i "/last_downloaded_version=.*/i # Do not change this parameter unless you know what you're doing!" "$configpath"
|
|
||||||
sed -i "s/last_downloaded_version=.*/last_downloaded_version=\"$version\"/" "$configpath"
|
|
||||||
fi
|
fi
|
||||||
|
echo "Extracting Factorio binary..."
|
||||||
|
tar -xf factorio_headless.tar.xz --strip-components=1 --overwrite
|
||||||
|
echo "Factorio binary updated!"
|
||||||
|
rm -f factorio_headless.tar.xz
|
||||||
|
|
||||||
# This checks if the ./saves/$save_name.zip save file exists or not...
|
# This checks if the ./saves/$save_name.zip save file exists or not...
|
||||||
if [ ! -f "./saves/${save_name}.zip" ]; then
|
if [ ! -f "./saves/${save_name}.zip" ]; then
|
||||||
|
@ -82,37 +61,3 @@ byobu new-session -d -s factorio "./bin/x64/factorio ${extra_params_start_server
|
||||||
# This attaches the current terminal to the byobu session.
|
# This attaches the current terminal to the byobu session.
|
||||||
# Comment this out if you don't want this functionality.
|
# Comment this out if you don't want this functionality.
|
||||||
byobu attach -t factorio
|
byobu attach -t factorio
|
||||||
|
|
||||||
|
|
||||||
# Load the last downloaded Factorio version from config.sh, if available
|
|
||||||
if [ "$configpath" = "config.sh" ]; then
|
|
||||||
last_downloaded_version=$(grep -oP 'last_downloaded_version=\K[^"]*' "$configpath")
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
last_download_version="None"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
last_downloaded_version="None"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the last downloaded version matches the current version
|
|
||||||
if [ "$last_downloaded_version" != "$version" ] || [ "$last_downloaded_version" = "stable" ] || [ "$last_downloaded_version" = "latest" ]; then
|
|
||||||
echo "Fetching Factorio binary..."
|
|
||||||
wget "https://factorio.com/get-download/${version}/headless/linux64" -O factorio_headless.tar.xz
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "FATAL: There is not a headless linux64 build available for the version you've selected in your ${configpath} file."
|
|
||||||
echo "FATAL: See this website for a list of all Factorio versions: https://factorio.com/download/archive/"
|
|
||||||
rm -f factorio_headless.tar.xz
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Extracting Factorio binary..."
|
|
||||||
tar -xf factorio_headless.tar.xz --strip-components=1 --overwrite
|
|
||||||
echo "Factorio binary updated!"
|
|
||||||
rm -f factorio_headless.tar.xz
|
|
||||||
else
|
|
||||||
echo "Not updating Factorio binary, as the existing version matches the version stated in the configuration file."
|
|
||||||
|
|
||||||
# Update the last downloaded version in the config.sh file
|
|
||||||
if [ -f "$configpath" ]; then
|
|
||||||
sed -i "s/last_downloaded_version=.*/last_downloaded_version=\"$version\"/" "$configpath"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in a new issue