Add verifiable atomic server updates
This commit is contained in:
parent
2d135acab7
commit
a68d6157be
8 changed files with 371 additions and 24 deletions
|
|
@ -1,15 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
echo "Usage: $0 /path/to/server-linux-x86_64" >&2
|
||||
if [[ $# -ne 3 ]]; then
|
||||
echo "Usage: $0 /path/to/server-linux-x86_64 GAME_VERSION GAME_COMMIT" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
source_dir="${1%/}"
|
||||
game_version="$2"
|
||||
game_commit="${3,,}"
|
||||
repository_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
destination_dir="${repository_dir}/dist"
|
||||
|
||||
if [[ ! "${game_version}" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then
|
||||
echo "GAME_VERSION must contain only letters, numbers, dots, underscores, or hyphens." >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ ! "${game_commit}" =~ ^[0-9a-f]{40}$ ]]; then
|
||||
echo "GAME_COMMIT must be the full 40-character Git commit." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
for filename in NETfishingServer.x86_64 NETfishingServer.pck; do
|
||||
if [[ ! -f "${source_dir}/${filename}" ]]; then
|
||||
echo "Missing ${source_dir}/${filename}" >&2
|
||||
|
|
@ -23,5 +34,20 @@ install -m 0644 "${source_dir}/NETfishingServer.pck" \
|
|||
"${destination_dir}/NETfishingServer.pck"
|
||||
|
||||
cd -- "${destination_dir}"
|
||||
sha256sum NETfishingServer.x86_64 NETfishingServer.pck > SHA256SUMS
|
||||
executable_sha256="$(sha256sum NETfishingServer.x86_64 | awk '{print $1}')"
|
||||
pck_sha256="$(sha256sum NETfishingServer.pck | awk '{print $1}')"
|
||||
|
||||
apply_umask="$(umask)"
|
||||
umask 022
|
||||
printf '%s\n' \
|
||||
"manifest_version=1" \
|
||||
"game_version=${game_version}" \
|
||||
"game_commit=${game_commit}" \
|
||||
"export_preset=Linux Dedicated Server" \
|
||||
"platform=linux-x86_64" \
|
||||
"executable_sha256=${executable_sha256}" \
|
||||
"pck_sha256=${pck_sha256}" \
|
||||
> BUILD_INFO
|
||||
umask "${apply_umask}"
|
||||
sha256sum NETfishingServer.x86_64 NETfishingServer.pck BUILD_INFO > SHA256SUMS
|
||||
echo "Staged dedicated server build in ${destination_dir}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue