Skip to content

Instantly share code, notes, and snippets.

@meseta
Last active December 27, 2023 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meseta/533e00299f0a8412b2f383e3f6bf21d9 to your computer and use it in GitHub Desktop.
Save meseta/533e00299f0a8412b2f383e3f6bf21d9 to your computer and use it in GitHub Desktop.
Initialization script for a quick GameMaker linux builder on DigitalOcean, Ubuntu 20.04
#!/bin/bash
echo "deb http://security.ubuntu.com/ubuntu xenial-security main" > /etc/apt/sources.list.d/xenial-security.list
apt-get update
apt-get install --no-install-recommends --yes \
curl \
gnupg \
ca-certificates \
build-essential \
clang \
libssl-dev \
libxrandr-dev \
libxxf86vm-dev \
libopenal-dev \
libgl1-mesa-dev \
libglu1-mesa-dev \
zlib1g-dev \
libcurl4-openssl-dev \
mono-complete \
zip \
unzip \
ffmpeg \
rsync \
git \
libxxf86vm1 \
libgl1 \
libssl1.1 \
libxrandr2 \
libglu1-mesa \
libcurl4 \
libopenal1 \
xvfb \
libssl1.0.0 \
libcurl3-gnutls \
lsb-release \
nginx
STEAMRUNTIME=/opt/steam-runtime/
if ! [ -d "$STEAMRUNTIME" ]; then
mkdir $STEAMRUNTIME
curl -Ls https://repo.steampowered.com/steamrt-images-scout/snapshots/latest-steam-client-general-availability/com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.tar.gz | tar -xzf - -C $STEAMRUNTIME
fi
LINUXDEPLOY=/usr/local/bin/linuxdeploy
if ! [ -f "$LINUXDEPLOY" ]; then
curl -Ls https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -o linuxdeploy-x86_64.AppImage
install -m 0755 linuxdeploy-x86_64.AppImage $LINUXDEPLOY
rm linuxdeploy-x86_64.AppImage
fi
APPIMAGETOOL=/usr/local/bin/appimagetool
if ! [ -f "$APPIMAGETOOL" ]; then
curl -Ls https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -o appimagetool-x86_64.AppImage
install -m 0755 appimagetool-x86_64.AppImage $APPIMAGETOOL
rm appimagetool-x86_64.AppImage
fi
# install the fake display startup script
cat >/etc/systemd/system/gamemaker-fake-display.service <<EOF
[Unit]
Description=GameMaker Server Stuff
[Service]
ExecStart=Xvfb :0 -screen 0 400x400x24
[Install]
WantedBy=default.target
EOF
# process watcher to ensure no two AppRun are running
# this is needed as of IDE v2023.11.0.121 which won't shut down old AppRuns
cat >/usr/local/bin/gamemaker-process-watcher.sh <<'EOF'
#!/bin/bash
while sleep 1; do if [[ $(pgrep -f "AppRun -debugoutput" | wc -l) -gt 1 ]]; then pkill -f "AppRun -debugoutput"; fi; done
EOF
cat >/etc/systemd/system/gamemaker-process-watcher.service <<EOF
[Unit]
Description=GameMaker Server Stuff
[Service]
ExecStart=/usr/local/bin/gamemaker-process-watcher.sh
[Install]
WantedBy=default.target
EOF
# default display for new games
cat >/etc/profile.d/gamemaker-fake-display-0.sh <<'EOF'
export DISPLAY=:0
EOF
chmod 744 /etc/profile.d/gamemaker-fake-display-0.sh
chmod 744 /usr/local/bin/gamemaker-process-watcher.sh
chmod 664 /etc/systemd/system/gamemaker-process-watcher.service
chmod 664 /etc/systemd/system/gamemaker-fake-display.service
systemctl daemon-reload
systemctl enable gamemaker-process-watcher
systemctl enable gamemaker-fake-display
systemctl start gamemaker-process-watcher
systemctl start gamemaker-fake-display
# self-signed certificate and nginx reverse proxy
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj "/C=US/ST=New York/L=New York City/O=Internet/OU=./CN=./emailAddress=."
cat >/etc/nginx/sites-enabled/gamemaker-5000.conf <<'EOF'
server {
listen 443 ssl;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
location / {
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:5000;
}
}
EOF
rm /etc/nginx/sites-enabled/default
systemctl restart nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment