From c94c8b1509dbd5f62f77c49c1d878f6e53fa87f5 Mon Sep 17 00:00:00 2001 From: Thijn Geurts Date: Wed, 3 May 2017 12:24:23 +0200 Subject: [PATCH] Fixed dockerfile and changed start.sh --- 04rel64/Dockerfile | 36 +++++++++----------------------- 04rel64/docker-entrypoint.sh | 40 ------------------------------------ 04rel64/vcmp.sh | 20 ------------------ 3 files changed, 10 insertions(+), 86 deletions(-) delete mode 100644 04rel64/docker-entrypoint.sh delete mode 100644 04rel64/vcmp.sh diff --git a/04rel64/Dockerfile b/04rel64/Dockerfile index 6bdd794..e34e5da 100644 --- a/04rel64/Dockerfile +++ b/04rel64/Dockerfile @@ -6,33 +6,17 @@ MAINTAINER Thijn RUN apt-get update && apt-get install -y \ wget \ unzip \ - p7zip + p7zip \ + && adduser --disabled-password --home /home/container container -# Download and extract server files -# Choose a more general directory name which does not contain any version -RUN cd / \ - && wget http://v04.maxorator.com/server/VCMP04_server_v22_linux64.zip \ - && unzip VCMP04_server_v22_linux64.zip \ - && rm -f VCMP04_server_v22_linux64.zip \ - && mkdir /vcmp \ - && mv /mpsvrrel64 /vcmp/ \ - && cd /vcmp \ - && mkdir plugins \ - && cd plugins \ - && wget http://v04.maxorator.com/allplugins_04rel004_patch7.7z \ - && p7zip -d allplugins_04rel004_patch7.7z \ - && chmod 700 * \ - && cd ../ \ - && chmod 700 mpsvrrel64 +USER container +ENV USER container +ENV HOME /home/container +ENV VCMP_VERSION v22 +ENV VCMP_PLUGIN_PATCH patch7 -COPY vcmp.sh /usr/local/bin/vcmp -COPY docker-entrypoint.sh /entrypoint.sh +WORKDIR /home/container -RUN chmod +x /usr/local/bin/vcmp \ - && chmod +x /entrypoint.sh +COPY ./start.sh /start.sh -ENTRYPOINT ["/entrypoint.sh"] - -CMD ["vcmp", "start"] - -EXPOSE 8192/udp +CMD ["/bin/bash", "/start.sh"] diff --git a/04rel64/docker-entrypoint.sh b/04rel64/docker-entrypoint.sh deleted file mode 100644 index 507cb2a..0000000 --- a/04rel64/docker-entrypoint.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -set -e - -if [ "$1" = 'vcmp' ]; then - # 1: Get environment variables -- printenv - # 2: Filter all which start with SAMP_* -- grep '^VCMP_*' - VcmpVars=`env | grep '^VCMP_*'` - - # Hand over environment variables as arguments for easier handling - # As values of environment variables may contain whitespaces the IFS needs to be overwritten - OLDIFS=$IFS - IFS=$'\n' - OLDARGS=$* - set ${VcmpVars:=""} - - # 3: Loop through each of the variables - for config in $*; do - # 4: Split environment variable up in key-value by specifying the '='-char as separator - key=`echo $config | cut -d\= -f1` - value=`echo $config | cut -d\= -f2` - - # 5: Extract the part after "SAMP_" as key - key=${key:5} - - # 6: Transform the key to lowercase - key=`echo $key | tr '[:upper:]' '[:lower:]'` - - # 7: Check if there's already a line with the respective key in the server.cfg - # 7.1 - True: Replace the current value with the new value - # 7.2 - False: Add new line to server.cfg with the key-value pair - grep -q "$key" vcmp/server.cfg && \ - sed -i "s/$key .*/$key $value/" vcmp/server.cfg 2>/dev/null || \ - sed -i "$ a\\$key $value" vcmp/server.cfg 2>/dev/null - done - - IFS=$OLDIFS - set $OLDARGS -fi - -exec "$@" \ No newline at end of file diff --git a/04rel64/vcmp.sh b/04rel64/vcmp.sh deleted file mode 100644 index 07091d2..0000000 --- a/04rel64/vcmp.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -set -e - -cd /vcmp -case "$1" in - 'start') - exec nohup ./mpsvrrel64 - ;; - 'stop') - exec killall mpsvrrel64 - ;; - 'restart') - killall mpsvrrel64 - sleep 1 - exec nohup ./mpsvrrel64 - ;; - *) - echo "Usage: $0 start/stop/restart" - exit 1 -esac \ No newline at end of file