From 269b2cef5935ebf907f1390821e35d7e324e4ef8 Mon Sep 17 00:00:00 2001 From: Jesse Norell <jesse@kci.net> Date: Wed, 5 Oct 2016 11:21:48 -0600 Subject: [PATCH] handle bash script overwrites during update. fixes #4227 --- server/scripts/ispconfig_update.sh | 28 +++++++++--- server/scripts/update_stable.sh | 71 ++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/server/scripts/ispconfig_update.sh b/server/scripts/ispconfig_update.sh index 03c13c9aea..df8a24a900 100644 --- a/server/scripts/ispconfig_update.sh +++ b/server/scripts/ispconfig_update.sh @@ -1,7 +1,25 @@ #!/bin/bash -php -q \ - -d disable_classes= \ - -d disable_functions= \ - -d open_basedir= \ - /usr/local/ispconfig/server/scripts/ispconfig_update.php +_UPD=1 + +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## + +# padding handles script being overwritten during updates +# see https://git.ispconfig.org/ispconfig/ispconfig3/issues/4227 + +{ +if [ -n "${_UPD}" ] +then + exec php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + /usr/local/ispconfig/server/scripts/ispconfig_update.php +fi +} + diff --git a/server/scripts/update_stable.sh b/server/scripts/update_stable.sh index a0566480e5..1ff4cdcfe7 100644 --- a/server/scripts/update_stable.sh +++ b/server/scripts/update_stable.sh @@ -1,30 +1,53 @@ #!/bin/bash -{ -{ - umask 0077 \ - && tmpdir=`mktemp -dt "$(basename $0).XXXXXXXXXX"` \ - && test -d "${tmpdir}" \ - && cd "${tmpdir}" -} || { - echo 'mktemp failed' - exit 1 -} -wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz -if [ -f ISPConfig-3-stable.tar.gz ] +_UPD=1 + +# padding handles script being overwritten during updates +# see https://git.ispconfig.org/ispconfig/ispconfig3/issues/4227 + +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## +################################################## + +{ +if [ -n "${_UPD}" ] then - tar xvfz ISPConfig-3-stable.tar.gz - cd ispconfig3_install/install/ - php -q \ - -d disable_classes= \ - -d disable_functions= \ - -d open_basedir= \ - update.php - cd /tmp - rm -rf "${tmpdir}" -else - echo "Unable to download the update." - exit 1 + { + umask 0077 \ + && tmpdir=`mktemp -dt "$(basename $0).XXXXXXXXXX"` \ + && test -d "${tmpdir}" \ + && cd "${tmpdir}" + } || { + echo 'mktemp failed' + exit 1 + } + + wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz + if [ -f ISPConfig-3-stable.tar.gz ] + then + tar xvfz ISPConfig-3-stable.tar.gz + cd ispconfig3_install/install/ + php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + update.php + cd /tmp + rm -rf "${tmpdir}" + else + echo "Unable to download the update." + exit 1 + fi + fi exit 0 -- GitLab