From a26361c79f33c4fe736c246cb0d74dda7fc54ed0 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 26 Jul 2020 13:07:30 -0500 Subject: [PATCH 1/3] misc: Renamed start-deployCF to align with multiarch branch --- start-configuration | 2 +- start-deployFTB => start-deployCF | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename start-deployFTB => start-deployCF (100%) diff --git a/start-configuration b/start-configuration index efb837aa..ea1e5cb8 100644 --- a/start-configuration +++ b/start-configuration @@ -109,7 +109,7 @@ case "${TYPE^^}" in ;; FTB|CURSEFORGE) - exec ${SCRIPTS:-/}start-deployFTB "$@" + exec ${SCRIPTS:-/}start-deployCF "$@" ;; VANILLA) diff --git a/start-deployFTB b/start-deployCF similarity index 100% rename from start-deployFTB rename to start-deployCF From aebe35c9d43a98d7591ea98a568b8591f126f7f7 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 26 Jul 2020 13:19:45 -0500 Subject: [PATCH 2/3] misc: Refactor writeEula --- start-configuration | 10 ++-------- start-utils | 9 +++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/start-configuration b/start-configuration index ea1e5cb8..57a48b67 100644 --- a/start-configuration +++ b/start-configuration @@ -8,8 +8,7 @@ shopt -s nullglob export HOME=/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" @@ -19,12 +18,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 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 +} From 49d9f4a89d505c519d88821f7adc48c8dde24122 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 26 Jul 2020 13:22:07 -0500 Subject: [PATCH 3/3] Separated autopause config file location to keep scripts read-only --- files/autopause/autopause-daemon.sh | 2 +- start | 5 ----- start-autopause | 14 ++++++++------ 3 files changed, 9 insertions(+), 12 deletions(-) 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 f6d467e7..43aff1e5 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