From cd2205a32518f01255bd45b968ab141059bbffa0 Mon Sep 17 00:00:00 2001 From: Tom Eastep Date: Sat, 15 Sep 2012 08:09:37 -0700 Subject: [PATCH] Upgrade down-rev rc file during install Signed-off-by: Tom Eastep --- Shorewall-core/install.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Shorewall-core/install.sh b/Shorewall-core/install.sh index 42dd771a1..9f9790959 100755 --- a/Shorewall-core/install.sh +++ b/Shorewall-core/install.sh @@ -164,11 +164,15 @@ else usage 1 fi +update=0 + if [ -z "${VARLIB}" ]; then VARLIB=${VARDIR} VARDIR="${VARLIB}/${PRODUCT}" + update=1 elif [ -z "${VARDIR}" ]; then VARDIR="${VARLIB}/${PRODUCT}" + update=2 fi for var in SHAREDIR LIBEXECDIR PERLLIBDIR CONFDIR SBINDIR VARLIB VARDIR; do @@ -353,9 +357,25 @@ ln -sf lib.base ${DESTDIR}${SHAREDIR}/shorewall/functions echo "$VERSION" > ${DESTDIR}${SHAREDIR}/shorewall/coreversion chmod 644 ${DESTDIR}${SHAREDIR}/shorewall/coreversion -[ $file != "${SHAREDIR}/shorewall/shorewallrc" ] && cp $file ${DESTDIR}${SHAREDIR}/shorewall/shorewallrc +if [ -z "${DESTDIR}" ]; then + if [ $update -ne 0 ]; then + echo "Updating $file - original saved in $file.bak" -[ -z "${DESTDIR}" ] && [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc ~/.shorewallrc + cp $file $file.bak + + echo '#' >> $file + echo "# Updated by Shorewall-core $VERSION -" `date` >> $file + echo '#' >> $file + + [ $update -eq 1 ] && sed -i 's/VARDIR/VARLIB/' $file + + echo 'VARDIR=${VARLIB}/${PRODUCT}' >> $file + fi + + [ ! -f ~/.shorewallrc ] && cp ${SHAREDIR}/shorewall/shorewallrc ~/.shorewallrc +fi + +[ $file != "${DESTDIR}${SHAREDIR}/shorewall/shorewallrc" ] && cp $file ${DESTDIR}${SHAREDIR}/shorewall/shorewallrc if [ ${SHAREDIR} != /usr/share ]; then for f in lib.*; do