2025-01-03 15:04:32 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2025-01-03 23:22:25 +01:00
|
|
|
|
|
|
|
# Function used to run initialization commands.
|
|
|
|
run_init_command() {
|
|
|
|
local stage="$1"
|
|
|
|
shift
|
|
|
|
if ! [ -f state/init-$stage ]; then
|
|
|
|
echo "Running initialization stage $stage"
|
2025-01-03 23:35:45 +01:00
|
|
|
echo " --> $*"
|
2025-01-03 23:22:25 +01:00
|
|
|
if /app/entrypoint.sh tool "$*"
|
|
|
|
then
|
|
|
|
touch state/init-$stage
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-01-03 15:04:32 +01:00
|
|
|
cd /app
|
|
|
|
|
|
|
|
if ! [ -z "$LW_CONFIGURE" ]; then
|
2025-01-03 16:58:18 +01:00
|
|
|
if [ -z "$LW_DB_PASSWORD_FILE" ]; then
|
|
|
|
password="$LW_DB_PASSWORD"
|
2025-01-03 15:04:32 +01:00
|
|
|
else
|
2025-01-03 16:58:18 +01:00
|
|
|
password="`cat $LW_DB_PASSWORD_FILE`"
|
2025-01-03 15:04:32 +01:00
|
|
|
fi
|
|
|
|
cat >data-source.xml <<EOF
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
|
|
|
<bean name="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
|
|
|
<property name="driverClassName" value="org.postgresql.Driver" />
|
2025-01-03 16:58:18 +01:00
|
|
|
<property name="url" value="jdbc:postgresql://${LW_DB_HOST}:5432/${LW_DB_NAME}" />
|
|
|
|
<property name="username" value="${LW_DB_USER}" />
|
2025-01-03 15:04:32 +01:00
|
|
|
<property name="password" value="${password}" />
|
|
|
|
</bean>
|
|
|
|
</beans>
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
cmd="$1"
|
|
|
|
shift
|
|
|
|
if [ "$cmd" == server ]; then
|
2025-01-03 23:22:25 +01:00
|
|
|
run_init_command import-text ImportText data/i18n-text.xml
|
|
|
|
run_init_command import-techs ImportTechs data/techs.xml
|
|
|
|
run_init_command import-buildables ImportBuildables data/buildables.xml
|
2025-01-03 15:04:32 +01:00
|
|
|
exec /usr/bin/java \
|
|
|
|
-Dlog4j.configuration=log4j.properties \
|
|
|
|
-jar server.jar
|
|
|
|
elif [ "$cmd" == shell ]; then
|
|
|
|
exec /bin/sh
|
|
|
|
elif [ "$cmd" == tool ]; then
|
2025-01-03 23:35:45 +01:00
|
|
|
tool="$1"
|
|
|
|
shift
|
2025-01-03 15:04:32 +01:00
|
|
|
exec /usr/bin/java \
|
2025-01-03 23:22:25 +01:00
|
|
|
-Dlog4j.configuration=log4j.properties \
|
|
|
|
-jar server.jar \
|
2025-01-03 23:35:45 +01:00
|
|
|
--run-tool "$tool" "$*"
|
2025-01-03 15:04:32 +01:00
|
|
|
else
|
|
|
|
echo "Invalid command '$cmd'" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|