Add Xaseco scripts

This commit is contained in:
fanyx 2022-06-26 17:46:55 +02:00
parent e5ec30e564
commit 8cd2157816
3 changed files with 98 additions and 0 deletions

10
xaseco/bin/config.sh Executable file
View File

@ -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

44
xaseco/bin/eval_env.sh Executable file
View File

@ -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

44
xaseco/bin/plugins.sh Executable file
View File

@ -0,0 +1,44 @@
#!/command/with-contenv bash
cd /var/lib/xaseco
XML_HEADER='<?xml version="1.0" encoding="utf-8" ?>\n<aseco_plugins>\n'
XML_FOOTER='</aseco_plugins>'
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>plugin.localdatabase.php</plugin>\n"
for plugin in "${PLUGINS_LIST[@]}"
do
case "${plugin}" in
"plugin.localdatabase.php")
;;
"plugin.records_eyepiece.php")
;;
*)
printf " <plugin>%s</plugin>\n" "${plugin}"
;;
esac
done
[[ "${PLUGINS_LIST[@]}" =~ "plugin.records_eyepiece.php" ]] && printf " <plugin>plugin.records_eyepiece.php</plugin>\n"
}
# finish with footer -- \n interpreted
printf "%b" "$XML_FOOTER"
} > plugins.xml