Skip to content

Commit

Permalink
Visibly error if the host CPU is specified as Common KVM processor
Browse files Browse the repository at this point in the history
…as this triggers Satisfactory to crash
  • Loading branch information
wolveix committed Nov 24, 2023
1 parent a0019ec commit 71bf219
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
set -e

CURRENTUID=$(id -u)
MSGERROR="$(tput setaf 1)ERROR:$(tput sgr0)"
MSGWARNING="$(tput setaf 3)WARNING:$(tput sgr0)"
NUMCHECK='^[0-9]+$'
RAMAVAILABLE=$(awk '/MemAvailable/ {printf( "%d\n", $2 / 1024000 )}' /proc/meminfo)
USER="steam"
Expand All @@ -23,41 +25,38 @@ HDD: $(df -h | awk '$NF=="/"{printf "%dGB/%dGB (%s used)\n", $3,$2,$5}')"
exit 1
fi

# check that the cpu isn't generic, as Satisfactory will crash
if [[ $(lscpu | grep 'Model name:' | sed 's/Model name:[[:space:]]*//g') = "Common KVM processor" ]]; then
printf "${MSGERROR} Your CPU model is configured as \"Common KVM processor\", which will cause Satisfactory to crash.\\nIf you have control over your hypervisor (ESXi, Proxmox, etc.), you should be able to easily change this.\\nOtherwise contact your host/administrator for assistance.\\n"
exit 1
fi

exit 0

if [[ "$CURRENTUID" -ne "0" ]]; then
printf "Current user is not root (%s)\\nPass your user and group to the container using the PGID and PUID environment variables\\nDo not use the --user flag (or user: field in Docker Compose)\\n" "$CURRENTUID"
printf "${MSGERROR} Current user is not root (%s)\\nPass your user and group to the container using the PGID and PUID environment variables\\nDo not use the --user flag (or user: field in Docker Compose)\\n" "$CURRENTUID"
exit 1
fi

printf "Checking available memory...%sGB detected\\n" "$RAMAVAILABLE"
if [[ "$RAMAVAILABLE" -lt 12 ]]; then
printf "You have less than the required 12GB minmum (%sGB detected) of available RAM to run the game server.\\nIt is likely that the server will fail to load properly.\\n" "$RAMAVAILABLE"
printf "${MSGWARNING} You have less than the required 12GB minmum (%sGB detected) of available RAM to run the game server.\\nIt is likely that the server will fail to load properly.\\n" "$RAMAVAILABLE"
fi

mkdir -p \
/config/backups \
/config/gamefiles \
/config/overrides \
/config/saved/blueprints \
/config/saved/server \
"${GAMECONFIGDIR}/Config/LinuxServer" \
"${GAMECONFIGDIR}/Logs" \
"${GAMESAVESDIR}/server" \
|| exit 1

# check if the user and group IDs have been set
if ! [[ "$PGID" =~ $NUMCHECK ]] ; then
printf "Invalid group id given: %s\\n" "$PGID"
printf "${MSGWARNING} Invalid group id given: %s\\n" "$PGID"
PGID="1000"
elif [[ "$PGID" -eq 0 ]]; then
printf "PGID/group cannot be 0 (root)\\n"
printf "${MSGERROR} PGID/group cannot be 0 (root)\\n"
exit 1
fi

if ! [[ "$PUID" =~ $NUMCHECK ]] ; then
printf "Invalid user id given: %s\\n" "$PUID"
printf "${MSGWARNING} Invalid user id given: %s\\n" "$PUID"
PUID="1000"
elif [[ "$PUID" -eq 0 ]]; then
printf "PUID/user cannot be 0 (root)\\n"
printf "${MSGERROR} PUID/user cannot be 0 (root)\\n"
exit 1
fi

Expand All @@ -73,5 +72,16 @@ else
usermod -u "$PUID" steam
fi

mkdir -p \
/config/backups \
/config/gamefiles \
/config/overrides \
/config/saved/blueprints \
/config/saved/server \
"${GAMECONFIGDIR}/Config/LinuxServer" \
"${GAMECONFIGDIR}/Logs" \
"${GAMESAVESDIR}/server" \
|| exit 1

chown -R "$PUID":"$PGID" /config /home/steam /tmp/dumps
exec gosu "$USER" "/home/steam/run.sh" "$@"

0 comments on commit 71bf219

Please sign in to comment.