diff --git a/files/autopause/autopause-daemon.sh b/files/autopause/autopause-daemon.sh index 3150740c..e46fdffa 100644 --- a/files/autopause/autopause-daemon.sh +++ b/files/autopause/autopause-daemon.sh @@ -4,7 +4,7 @@ . /start-utils -sudo /usr/sbin/knockd -c /autopause/knockd-config.cfg -d +sudo /usr/sbin/knockd -c /tmp/knockd-config.cfg -d if [ $? -ne 0 ] ; then while : do diff --git a/start b/start index f50e0672..c7660ada 100644 --- a/start +++ b/start @@ -36,11 +36,6 @@ if [ $(id -u) = 0 ]; then chown -R ${runAsUser}:${runAsGroup} /data fi - if [[ $(stat -c "%u" /autopause) != $UID ]]; then - log "Changing ownership of /autopause to $UID ..." - chown -R ${runAsUser}:${runAsGroup} /autopause - fi - if [[ ${SKIP_NSSWITCH_CONF^^} != TRUE ]]; then echo 'hosts: files dns' > /etc/nsswitch.conf fi diff --git a/start-autopause b/start-autopause index 32c5e64a..51acfc5e 100755 --- a/start-autopause +++ b/start-autopause @@ -4,18 +4,20 @@ log "Autopause functionality enabled" +cp /autopause/knockd-config.cfg /tmp/knockd-config.cfg + # update server port to listen to regseq="^\s*sequence\s*=\s*$SERVER_PORT\s*$" -linenum=$(grep -nm1 sequence /autopause/knockd-config.cfg | cut -d : -f 1 | tail -n1) -if ! [[ $(awk "NR==$linenum" /autopause/knockd-config.cfg) =~ $regseq ]]; then - sed -i "${linenum}s/sequence.*/sequence = $SERVER_PORT/" /autopause/knockd-config.cfg +linenum=$(grep -nm1 sequence /tmp/knockd-config.cfg | cut -d : -f 1 | tail -n1) +if ! [[ $(awk "NR==$linenum" /tmp/knockd-config.cfg) =~ $regseq ]]; then + sed -i "${linenum}s/sequence.*/sequence = $SERVER_PORT/" /tmp/knockd-config.cfg log "Updated server port in knockd config" fi # update rcon port to listen to regseq="^\s*sequence\s*=\s*$RCON_PORT\s*$" -linenum=$(grep -nm2 sequence /autopause/knockd-config.cfg | cut -d : -f 1 | tail -n1) -if ! [[ $(awk "NR==$linenum" /autopause/knockd-config.cfg) =~ $regseq ]]; then - sed -i "${linenum}s/sequence.*/sequence = $RCON_PORT/" /autopause/knockd-config.cfg +linenum=$(grep -nm2 sequence /tmp/knockd-config.cfg | cut -d : -f 1 | tail -n1) +if ! [[ $(awk "NR==$linenum" /tmp/knockd-config.cfg) =~ $regseq ]]; then + sed -i "${linenum}s/sequence.*/sequence = $RCON_PORT/" /tmp/knockd-config.cfg log "Updated rcon port in knockd config" fi diff --git a/start-configuration b/start-configuration index 0c84d5c5..33672054 100644 --- a/start-configuration +++ b/start-configuration @@ -10,8 +10,7 @@ export HOME=/data log "Running as uid=$(id -u) gid=$(id -g) with /data as '$(ls -lnd /data)'" if [ ! -e /data/eula.txt ]; then - EULA="${EULA,,}" - if [ "$EULA" != "true" ]; then + if ! isTrue "$EULA"; then log "" log "Please accept the Minecraft EULA at" log " https://account.mojang.com/documents/minecraft_eula" @@ -21,12 +20,7 @@ if [ ! -e /data/eula.txt ]; then exit 1 fi - echo "# Generated via Docker on $(date)" > /data/eula.txt - - if ! echo "eula=$EULA" >> /data/eula.txt; then - log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}" - exit 2 - fi + writeEula fi @@ -102,7 +96,7 @@ case "${TYPE^^}" in ;; FTBA) - exec ${SCRIPTS:-/}start-deployFTB "$@" + exec ${SCRIPTS:-/}start-deployFTBA "$@" ;; CURSEFORGE|FTB) diff --git a/start-deployFTB b/start-deployFTBA similarity index 100% rename from start-deployFTB rename to start-deployFTBA diff --git a/start-utils b/start-utils index ffbdec29..a46d1a28 100644 --- a/start-utils +++ b/start-utils @@ -113,3 +113,12 @@ requireVar() { exit 1 fi } + +function writeEula() { +if ! echo "# Generated via Docker on $(date) +eula=${EULA,,} +" > /data/eula.txt; then + log "ERROR: unable to write eula to /data. Please make sure attached directory is writable by uid=${UID}" + exit 2 +fi +}