DarkflameServer/docker/setup.sh

42 lines
1.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# fail on first error
set -e
function update_ini() {
FILE="/docker/configs/$1"
KEY=$2
NEW_VALUE=$3
sed -i "s~$2=.*~$2=$3~" $FILE
}
function update_database_ini_values_for() {
INI_FILE=$1
update_ini $INI_FILE mysql_host $DATABASE_HOST
update_ini $INI_FILE mysql_database $DATABASE
update_ini $INI_FILE mysql_username $DATABASE_USER
update_ini $INI_FILE mysql_password $DATABASE_PASSWORD
update_ini $INI_FILE client_net_version $BUILD_VERSION
update_ini $INI_FILE external_ip $EXTERNAL_IP
}
function update_ini_values() {
echo "Copying and updating config files"
mkdir -p /docker/configs
cp resources/masterconfig.ini /docker/configs/
cp resources/authconfig.ini /docker/configs/
cp resources/chatconfig.ini /docker/configs/
cp resources/worldconfig.ini /docker/configs/
2022-11-07 23:04:20 +00:00
cp resources/sharedconfig.ini /docker/configs/
2021-12-08 13:57:16 +00:00
# always use the internal docker hostname
update_ini masterconfig.ini master_ip "darkflame"
update_ini sharedconfig.ini client_location "/client"
2021-12-08 13:57:16 +00:00
2022-11-07 23:04:20 +00:00
update_database_ini_values_for sharedconfig.ini
}
update_ini_values