Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Commit

Permalink
importing and updating of database, get latest hlxce master
Browse files Browse the repository at this point in the history
  • Loading branch information
crinis committed Apr 27, 2017
1 parent 15566dc commit dacd141
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
23 changes: 15 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,30 @@ ENV HLXCE_VERSION=1_6_19 \
DB_NAME=hlxce \
DB_USERNAME=hlxce \
DB_PASSWORD=hlxce \
DB_HOST=db
DB_HOST=db \
UPDATE_DB=false

COPY docker-hlxce-entrypoint /usr/local/bin/
COPY hlxce.ini /usr/local/etc/php/conf.d/

WORKDIR /var/www/html/

RUN set -x \
&& apt-get update && apt-get -y install mysql-client sed libfreetype6-dev libjpeg62-turbo-dev \
RUN set -xe \
&& buildDeps=" \
git \
" \
&& apt-get update && apt-get -y install $buildDeps mysql-client sed libfreetype6-dev libjpeg62-turbo-dev --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install mysql gd \
&& chmod +x /usr/local/bin/docker-hlxce-entrypoint \
&& curl -L https://bitbucket.org/Maverick_of_UC/hlstatsx-community-edition/downloads/hlxce_${HLXCE_VERSION}.tar.gz -o hlxce.tar.gz \
&& tar -zxvf hlxce.tar.gz --strip-components=1 web/ \
&& rm -R updater/ \
&& rm -rf hlxce.tar.gz \
&& chown -R www-data:www-data .
&& git clone https://[email protected]/Maverick_of_UC/hlstatsx-community-edition.git hlstatsx \
&& mv hlstatsx/web/* . \
&& mv hlstatsx/sql/ . \
&& rm -R hlstatsx/ \
&& chown -R www-data:www-data . \
&& docker-php-source delete \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $buildDeps

ENTRYPOINT ["docker-hlxce-entrypoint"]

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ You need a working installation of Docker and Docker compose to follow the insta
For a basic setup use my pre-configured [docker-compose.yml](docker-compose.yml). Make sure to change all passwords before running this in production.

Run the following command in the same folder as the docker-compose.yml file to get the containers running.

If you run this container for the first time or want to update the database, make sure to add UPDATE_DB: 'true' to the environment variables of the "web" service. When you are done remove it and restart the service. This will also remove the updater/ and sql/ directories.
```
docker-compose up
```
Now you should have your HLstatsX: CE web interface running at port 80, the Perl daemon at port 27500 and an instance of phpMyAdmin at port 8080.
Before you try to use the web interface at port 80 you should get the sql/install.sql file from the official [HLstatsX: CE repository](https://bitbucket.org/Maverick_of_UC/hlstatsx-community-edition/) and import it into the hlxce table of the database using phpMyAdmin at port 8080 of your server.


Now add the following commands to the server.cfg file of your gameserver.
```
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
DB_USERNAME: hlxce
DB_PASSWORD: hlxce
DB_NAME: hlxce
# this is only required to import or update the database
UPDATE_DB: 'true'
links:
- db:db
- daemon:daemon
Expand Down
23 changes: 20 additions & 3 deletions docker-hlxce-entrypoint
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
#!/bin/sh
#!/bin/bash

sed -i "/DB_NAME/s/\"\([^\"]*\)\"/\"${DB_NAME}\"/2g" /var/www/html/config.php
sed -i "/DB_USER/s/\"\([^\"]*\)\"/\"${DB_USERNAME}\"/2g" /var/www/html/config.php
sed -i "/DB_PASS/s/\"\([^\"]*\)\"/\"${DB_PASSWORD}\"/2g" /var/www/html/config.php
sed -i "/DB_ADDR/s/\"\([^\"]*\)\"/\"${DB_HOST}\"/2g" /var/www/html/config.php

# mysql -h ${DB_ADDR} -u${DB_USER} -p${DB_PASS} ${DB_NAME} < /var/www/html/sql/install.sql
if [ "true" == "$UPDATE_DB" ]
then
while ! mysqladmin ping --host="${DB_HOST}" --user="${DB_USERNAME}" --password="${DB_PASSWORD}" --silent; do
echo 'Waiting for database to come up...'
sleep 2
done
if [ $(mysql -N -s --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} -e \
"select count(*) from information_schema.tables where \
table_schema='${DB_NAME}' and table_name='hlstats_Servers';") -eq 1 ]; then
echo 'Database is already filled'
else
echo 'Importing database tables'
mysql --host=${DB_HOST} --user=${DB_USER} --password=${DB_PASSWORD} ${DB_NAME} < /var/www/html/sql/install.sql
fi
rm -R sql/
else
rm -R updater/ sql/
fi

exec "docker-php-entrypoint" $@
exec "docker-php-entrypoint" $@

0 comments on commit dacd141

Please sign in to comment.