From 8cd21578168e81d6e47164d46fd60680c0ad4a50 Mon Sep 17 00:00:00 2001 From: fanyx Date: Sun, 26 Jun 2022 17:46:55 +0200 Subject: [PATCH] Add Xaseco scripts --- xaseco/bin/config.sh | 10 ++++++++++ xaseco/bin/eval_env.sh | 44 ++++++++++++++++++++++++++++++++++++++++++ xaseco/bin/plugins.sh | 44 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100755 xaseco/bin/config.sh create mode 100755 xaseco/bin/eval_env.sh create mode 100755 xaseco/bin/plugins.sh diff --git a/xaseco/bin/config.sh b/xaseco/bin/config.sh new file mode 100755 index 0000000..6146e57 --- /dev/null +++ b/xaseco/bin/config.sh @@ -0,0 +1,10 @@ +#!/command/with-contenv bash + +if ls config/* &>/dev/null; then + echo "INFO | Linking custom configuration files..." + for i in config/* + do + ln -sf $i . + done + echo "INFO | Custom configuration done." +fi diff --git a/xaseco/bin/eval_env.sh b/xaseco/bin/eval_env.sh new file mode 100755 index 0000000..febcb3c --- /dev/null +++ b/xaseco/bin/eval_env.sh @@ -0,0 +1,44 @@ +#!/command/with-contenv bash + +config=( ) +database=( ) + +# Config +MASTERADMIN_LOGIN=${MASTERADMIN_LOGIN:?ERROR | One player needs to be assigned the MasterAdmin role.} && \ + config+=( "MASTERADMIN_LOGIN" ) +SERVER_SA_PASSWORD=${SERVER_SA_PASSWORD:?ERROR | SuperAdminPassword was not given. Please refer to your TMServer configuration.} && \ + config+=( "SERVER_SA_PASSWORD" ) + +# Optional +TMSERVER_HOST=${TMSERVER_HOST:-localhost} && \ + config+=( "TMSERVER_HOST" ) +echo "INFO | TMSERVER_HOST: ${TMSERVER_HOST}" +TMSERVER_PORT=${TMSERVER_PORT:-5000} && \ + config+=( "TMSERVER_PORT" ) +echo "INFO | TMSERVER_PORT: ${TMSERVER_PORT}" + +# Local Database +MYSQL_HOST=${MYSQL_HOST:-db} && \ + database+=( "MYSQL_HOST" ) +echo "INFO | MYSQL_HOST: ${MYSQL_HOST}" +MYSQL_LOGIN=${MYSQL_LOGIN:?ERROR | MySQL username was not given...} && \ + database+=( "MYSQL_LOGIN" ) +echo "INFO | MYSQL_LOGIN: ${MYSQL_LOGIN}" +MYSQL_PASSWORD=${MYSQL_PASSWORD:?ERROR | MySQL password was not given...} && \ + database+=( "MYSQL_PASSWORD" ) +echo "INFO | MYSQL_PASSWORD: ${MYSQL_PASSWORD}" +MYSQL_DATABASE=${MYSQL_DATABASE:-trackmania} && \ + database+=( "MYSQL_DATABASE" ) +echo "INFO | MYSQL_DATABASE: ${MYSQL_DATABASE}" + +# Parse config.xml +for idx in "${!config[@]}"; do + arg=${config[$idx]} + sed -i -e "s/@$arg@/${!arg}/g" config.xml +done + +# Parse localdatabase.xml +for idx in "${!database[@]}"; do + arg=${database[$idx]} + sed -i -e "s/@$arg@/${!arg}/g" localdatabase.xml +done diff --git a/xaseco/bin/plugins.sh b/xaseco/bin/plugins.sh new file mode 100755 index 0000000..86fe1b5 --- /dev/null +++ b/xaseco/bin/plugins.sh @@ -0,0 +1,44 @@ +#!/command/with-contenv bash + +cd /var/lib/xaseco + +XML_HEADER='\n\n' +XML_FOOTER='' + +if ls plugins/custom/* &>/dev/null; then + for i in plugins/custom/* + do + ln -sf ${i#*/} plugins/ + done +fi + +PLUGINS_LIST=($(ls -d plugins/*.php | sed -e 's/plugins\///g')) + +[[ -r ./blacklist ]] && \ + PLUGINS_LIST=($(echo ${PLUGINS_LIST[@]} | tr ' ' '\n' | grep -vFf blacklist)) + +{ + # open with header -- \n interpreted + printf "%b" "$XML_HEADER" + + # main block -- parse plugin list + { + [[ "${PLUGINS_LIST[@]}" =~ "plugin.localdatabase.php" ]] && printf " plugin.localdatabase.php\n" + for plugin in "${PLUGINS_LIST[@]}" + do + case "${plugin}" in + "plugin.localdatabase.php") + ;; + "plugin.records_eyepiece.php") + ;; + *) + printf " %s\n" "${plugin}" + ;; + esac + done + [[ "${PLUGINS_LIST[@]}" =~ "plugin.records_eyepiece.php" ]] && printf " plugin.records_eyepiece.php\n" + } + + # finish with footer -- \n interpreted + printf "%b" "$XML_FOOTER" +} > plugins.xml