From b1ed4de5016e501a4269a98e0eeb4e31d9236c99 Mon Sep 17 00:00:00 2001 From: Furior Date: Fri, 29 Sep 2023 02:15:22 +0700 Subject: [PATCH 1/3] I guess lol --- tgui/tgs_scripts/InstallDeps.sh | 50 ++++++++++++++++++++++++++++++ tgui/tgs_scripts/PreCompile.sh | 40 ++++++++++++++++++++++++ tgui/tgs_scripts/WatchdogLaunch.sh | 6 ++++ 3 files changed, 96 insertions(+) create mode 100644 tgui/tgs_scripts/InstallDeps.sh create mode 100644 tgui/tgs_scripts/PreCompile.sh create mode 100644 tgui/tgs_scripts/WatchdogLaunch.sh diff --git a/tgui/tgs_scripts/InstallDeps.sh b/tgui/tgs_scripts/InstallDeps.sh new file mode 100644 index 000000000000..6b75c49bb086 --- /dev/null +++ b/tgui/tgs_scripts/InstallDeps.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +#find out what we have (+e is important for this) +set +e +has_git="$(command -v git)" +has_curl="$(command -v curl)" +has_cargo="$(command -v ~/.cargo/bin/cargo)" +has_sudo="$(command -v sudo)" +has_youtubedl="$(command -v youtube-dl)" +has_pip3="$(command -v pip3)" +set -e +set -x + +# apt packages, libssl needed by rust-g but not included in TGS barebones install +if ! ( [ -x "$has_git" ] && [ -x "$has_curl" ] && [ -f "/usr/lib/i386-linux-gnu/libssl.so" ] ); then + echo "Installing apt dependencies..." + if ! [ -x "$has_sudo" ]; then + dpkg --add-architecture i386 + apt-get update + apt-get install -y lib32z1 git pkg-config libssl-dev:i386 libssl-dev zlib1g-dev:i386 curl + else + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install -y lib32z1 git pkg-config libssl-dev:i386 libssl-dev zlib1g-dev:i386 curl + fi +fi + +# install cargo if needed +if ! [ -x "$has_cargo" ]; then + echo "Installing rust..." + curl https://sh.rustup.rs -sSf | sh -s -- -y + . ~/.profile +fi + +# install or update youtube-dl when not present, or if it is present with pip3, +# which we assume was used to install it +if ! [ -x "$has_youtubedl" ]; then + echo "Installing youtube-dl with pip3..." + if ! [ -x "$has_sudo" ]; then + apt-get update + apt-get install -y python3 python3-pip + else + sudo apt-get update + sudo apt-get install -y python3 python3-pip + fi + pip3 install youtube-dl +elif [ -x "$has_pip3" ]; then + echo "Ensuring youtube-dl is up-to-date with pip3..." + pip3 install youtube-dl -U +fi diff --git a/tgui/tgs_scripts/PreCompile.sh b/tgui/tgs_scripts/PreCompile.sh new file mode 100644 index 000000000000..ca00cb6e809b --- /dev/null +++ b/tgui/tgs_scripts/PreCompile.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +./InstallDeps.sh + +set -e +set -x + +# Load dep exports +# Need to switch to game dir for Dockerfile weirdness +original_dir=$PWD +cd "$1" +. dependencies.sh +cd "$original_dir" + + +# update rust-g +if [ ! -d "rust-g-tg" ]; then + echo "Cloning rust-g..." + git clone https://github.com/ss220-space/rust-g-tg # Aziz one + cd rust-g-tg + ~/.cargo/bin/rustup target add i686-unknown-linux-gnu +else + echo "Fetching rust-g..." + cd rust-g-tg + git fetch + ~/.cargo/bin/rustup target add i686-unknown-linux-gnu +fi + +echo "Deploying rust-g..." +git checkout "$RUST_G_VERSION" +RUSTFLAGS="-C target-cpu=native" +env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --features all --target=i686-unknown-linux-gnu +mv target/i686-unknown-linux-gnu/release/librust_g_ss220.so "$1/librust_g_ss220.so" +cd .. + +# SS220 TODO: #22629 tg like compile tgui +# compile tgui +# echo "Compiling tgui..." +# cd "$1" +# env TG_BOOTSTRAP_CACHE="$original_dir" TG_BOOTSTRAP_NODE_LINUX=1 CBT_BUILD_MODE="TGS" tools/bootstrap/node tools/build/build.js diff --git a/tgui/tgs_scripts/WatchdogLaunch.sh b/tgui/tgs_scripts/WatchdogLaunch.sh new file mode 100644 index 000000000000..cd400cbb969b --- /dev/null +++ b/tgui/tgs_scripts/WatchdogLaunch.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Special file to ensure all dependencies still exist between server launches. +# Mainly for use by people who abuse docker by modifying the container's system. + +./InstallDeps.sh From 69357a45c5d68bdea5086afcf800b2d9c4ac0058 Mon Sep 17 00:00:00 2001 From: Furior Date: Fri, 29 Sep 2023 02:16:20 +0700 Subject: [PATCH 2/3] tgs.yml --- .tgs.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.tgs.yml b/.tgs.yml index aad9a7b180b1..9384f9d72f92 100644 --- a/.tgs.yml +++ b/.tgs.yml @@ -9,5 +9,11 @@ static_files: populate: true # Data directory must be static - name: data +# String dictionary. The value is the location of the file in the repo to upload to TGS. The key is the name of the file to upload to "/Configuration/EventScripts/" +# This one is for Linux hosted servers +linux_scripts: + PreCompile.sh: tools/tgs_scripts/PreCompile.sh + WatchdogLaunch.sh: tools/tgs_scripts/WatchdogLaunch.sh + InstallDeps.sh: tools/tgs_scripts/InstallDeps.sh # The security level the game should be run at security: Trusted From 8aba2e8e87236587a483a830e1613cd690cb80b3 Mon Sep 17 00:00:00 2001 From: Furior Date: Fri, 29 Sep 2023 02:17:58 +0700 Subject: [PATCH 3/3] I need to sleep more --- {tgui => tools}/tgs_scripts/InstallDeps.sh | 0 {tgui => tools}/tgs_scripts/PreCompile.sh | 0 {tgui => tools}/tgs_scripts/WatchdogLaunch.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {tgui => tools}/tgs_scripts/InstallDeps.sh (100%) rename {tgui => tools}/tgs_scripts/PreCompile.sh (100%) rename {tgui => tools}/tgs_scripts/WatchdogLaunch.sh (100%) diff --git a/tgui/tgs_scripts/InstallDeps.sh b/tools/tgs_scripts/InstallDeps.sh similarity index 100% rename from tgui/tgs_scripts/InstallDeps.sh rename to tools/tgs_scripts/InstallDeps.sh diff --git a/tgui/tgs_scripts/PreCompile.sh b/tools/tgs_scripts/PreCompile.sh similarity index 100% rename from tgui/tgs_scripts/PreCompile.sh rename to tools/tgs_scripts/PreCompile.sh diff --git a/tgui/tgs_scripts/WatchdogLaunch.sh b/tools/tgs_scripts/WatchdogLaunch.sh similarity index 100% rename from tgui/tgs_scripts/WatchdogLaunch.sh rename to tools/tgs_scripts/WatchdogLaunch.sh