From be2695732dea88af7b62be20bfdb1604c63170a9 Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Sun, 17 Jan 2016 14:55:43 -0600 Subject: [PATCH] Check for install results at the end of script --- vpnupgrade_Libreswan.sh | 8 +++++--- vpnupgrade_Libreswan_centos.sh | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/vpnupgrade_Libreswan.sh b/vpnupgrade_Libreswan.sh index 7f5e9da..8032b61 100644 --- a/vpnupgrade_Libreswan.sh +++ b/vpnupgrade_Libreswan.sh @@ -106,6 +106,11 @@ tar xvzf "$SWAN_FILE" && rm -f "$SWAN_FILE" cd "libreswan-${SWAN_VER}" || { echo "Failed to enter Libreswan source directory. Aborting."; exit 1; } make programs && make install +# Restart services +/usr/sbin/service ipsec restart +/usr/sbin/service xl2tpd restart + +# Check if Libreswan install was successful /usr/local/sbin/ipsec --version 2>/dev/null | grep -qs "${SWAN_VER}" if [ "$?" != "0" ]; then echo @@ -115,9 +120,6 @@ if [ "$?" != "0" ]; then exit 1 fi -service ipsec restart -service xl2tpd restart - echo echo "Congratulations! Libreswan ${SWAN_VER} was installed successfully!" diff --git a/vpnupgrade_Libreswan_centos.sh b/vpnupgrade_Libreswan_centos.sh index 081e012..ce91cbc 100644 --- a/vpnupgrade_Libreswan_centos.sh +++ b/vpnupgrade_Libreswan_centos.sh @@ -113,7 +113,7 @@ yum -y install nss-devel nspr-devel pkgconfig pam-devel \ fipscheck-devel unbound-devel gmp gmp-devel xmlto yum -y install ppp xl2tpd -# Installed Libevent 2. Use backported version for CentOS 6. +# Installed Libevent2. Use backported version for CentOS 6. if grep -qs "release 6" /etc/redhat-release; then LE2_URL="https://people.redhat.com/pwouters/libreswan-rhel6" RPM1="libevent2-2.0.21-1.el6.x86_64.rpm" @@ -136,6 +136,16 @@ tar xvzf "$SWAN_FILE" && rm -f "$SWAN_FILE" cd "libreswan-${SWAN_VER}" || { echo "Failed to enter Libreswan source directory. Aborting."; exit 1; } make programs && make install +# Restore SELinux contexts +restorecon /etc/ipsec.d/*db 2>/dev/null +restorecon /usr/local/sbin -Rv 2>/dev/null +restorecon /usr/local/libexec/ipsec -Rv 2>/dev/null + +# Restart services +/sbin/service ipsec restart +/sbin/service xl2tpd restart + +# Check if Libreswan install was successful /usr/local/sbin/ipsec --version 2>/dev/null | grep -qs "${SWAN_VER}" if [ "$?" != "0" ]; then echo @@ -145,14 +155,6 @@ if [ "$?" != "0" ]; then exit 1 fi -# Restore SELinux contexts -restorecon /etc/ipsec.d/*db 2>/dev/null -restorecon /usr/local/sbin -Rv 2>/dev/null -restorecon /usr/local/libexec/ipsec -Rv 2>/dev/null - -service ipsec restart -service xl2tpd restart - echo echo "Congratulations! Libreswan ${SWAN_VER} was installed successfully!"