#!/bin/bash
# Collection of scripts to deploy a server hosting several open-source games
# Copyright (C) 2022 Jarno van der Kolk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
set -e
if [ -e /etc/systemd/system/cortexcommand.service ]; then
systemctl stop cortexcommand
fi
apt-get -y install build-essential libsdl2-dev libloadpng4-dev libflac++-dev luajit-5.1-dev liblua5.1-dev libminizip-dev liblz4-dev libpng++-dev libtbb-dev ninja-build xvfb
# Install Cortex Command
mkdir -p ${TMPDIR:-/tmp}/cortexcommand-build
cd ${TMPDIR:-/tmp}/cortexcommand-build
if [ -d cortexcommand ]; then
rm -rf cortexcommand
fi
git clone --depth=1 https://github.com/cortex-command-community/Cortex-Command-Community-Project-Source.git
git clone --depth=1 https://github.com/cortex-command-community/Cortex-Command-Community-Project-Data.git
cd Cortex-Command-Community-Project-Source
virtualenv mesonenv
pip install meson
source mesonenv/bin/activate
meson setup --prefix=/opt/cortexcommand --buildtype=debug build
ninja -C build
ninja install -C build
deactivate
cd ..
rm -rf ${TMPDIR:-/tmp}/cortexcommand-build
# Patch startup script to get rid of weird directories
cd /opt/cortexcommand/bin
patch -l < "\${user_data}/Metagames.rte/Index.ini"
- fi
-
- if ! [[ -d "\${user_data}/Scenes.rte" ]]; then
- mkdir -p "\${user_data}/Scenes.rte"
- echo -e "DataModule\n\tModuleName = Saves" > "\${user_data}/Scenes.rte/Index.ini"
- fi
-
for directory in \${user_directories[@]}; do
if ! [[ -d "\${user_data}/\${directory}" ]]; then
mkdir -p "\${user_data}/\${directory}"
EOF
sudo -u ${systemuser} mkdir -p "${systemuserhome}/.local/share/Cortex Command"
echo -e "ServerSleepWhenIdle = 1\nServerSimSleepWhenIdle = 1" | sudo -u ${systemuser} tee "${systemuserhome}/.local/share/Cortex Command/Settings.ini"
# Create SystemD unit
cat > /etc/systemd/system/cortexcommand.service < /etc/systemd/system/cortexcommand-fakex.service <