From 49d9f4a89d505c519d88821f7adc48c8dde24122 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 26 Jul 2020 13:22:07 -0500 Subject: [PATCH] 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