diff --git a/vpnsetup.sh b/vpnsetup.sh index 3a6ad7f..f87bc0e 100644 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -119,7 +119,7 @@ SWAN_VER=3.17 SWAN_FILE="libreswan-${SWAN_VER}.tar.gz" SWAN_URL="https://download.libreswan.org/$SWAN_FILE" wget -t 3 -T 30 -nv -O "$SWAN_FILE" "$SWAN_URL" -[ ! -f "$SWAN_FILE" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } +[ "$?" != "0" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } /bin/rm -rf "/opt/src/libreswan-$SWAN_VER" tar xvzf "$SWAN_FILE" && /bin/rm -f "$SWAN_FILE" cd "libreswan-$SWAN_VER" || { echo "Failed to enter Libreswan source dir. Aborting."; exit 1; } diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index a1eb24f..4dddee0 100644 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -150,8 +150,9 @@ if grep -qs "release 6" /etc/redhat-release; then RPM1=libevent2-2.0.22-1.el6.x86_64.rpm RPM2=libevent2-devel-2.0.22-1.el6.x86_64.rpm wget -t 3 -T 30 -nv -O "$RPM1" "$LE2_URL/$RPM1" + [ "$?" != "0" ] && { echo "Cannot retrieve Libevent2 RPM file(s). Aborting."; exit 1; } wget -t 3 -T 30 -nv -O "$RPM2" "$LE2_URL/$RPM2" - [ ! -f "$RPM1" ] || [ ! -f "$RPM2" ] && { echo "Cannot retrieve Libevent2 RPM file(s). Aborting."; exit 1; } + [ "$?" != "0" ] && { echo "Cannot retrieve Libevent2 RPM file(s). Aborting."; exit 1; } rpm -ivh --force "$RPM1" "$RPM2" && /bin/rm -f "$RPM1" "$RPM2" elif grep -qs "release 7" /etc/redhat-release; then yum -y install libevent-devel @@ -162,7 +163,7 @@ SWAN_VER=3.17 SWAN_FILE="libreswan-${SWAN_VER}.tar.gz" SWAN_URL="https://download.libreswan.org/$SWAN_FILE" wget -t 3 -T 30 -nv -O "$SWAN_FILE" "$SWAN_URL" -[ ! -f "$SWAN_FILE" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } +[ "$?" != "0" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } /bin/rm -rf "/opt/src/libreswan-$SWAN_VER" tar xvzf "$SWAN_FILE" && /bin/rm -f "$SWAN_FILE" cd "libreswan-$SWAN_VER" || { echo "Failed to enter Libreswan source dir. Aborting."; exit 1; } diff --git a/vpnupgrade_Libreswan.sh b/vpnupgrade_Libreswan.sh index 80ff982..d434a1c 100644 --- a/vpnupgrade_Libreswan.sh +++ b/vpnupgrade_Libreswan.sh @@ -103,7 +103,7 @@ apt-get -y --no-install-recommends install xmlto SWAN_FILE="libreswan-${SWAN_VER}.tar.gz" SWAN_URL="https://download.libreswan.org/$SWAN_FILE" wget -t 3 -T 30 -nv -O "$SWAN_FILE" "$SWAN_URL" -[ ! -f "$SWAN_FILE" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } +[ "$?" != "0" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } /bin/rm -rf "/opt/src/libreswan-$SWAN_VER" tar xvzf "$SWAN_FILE" && /bin/rm -f "$SWAN_FILE" cd "libreswan-$SWAN_VER" || { echo "Failed to enter Libreswan source dir. Aborting."; exit 1; } diff --git a/vpnupgrade_Libreswan_centos.sh b/vpnupgrade_Libreswan_centos.sh index 3e17eee..6244f6a 100644 --- a/vpnupgrade_Libreswan_centos.sh +++ b/vpnupgrade_Libreswan_centos.sh @@ -120,8 +120,9 @@ if grep -qs "release 6" /etc/redhat-release; then RPM1=libevent2-2.0.22-1.el6.x86_64.rpm RPM2=libevent2-devel-2.0.22-1.el6.x86_64.rpm wget -t 3 -T 30 -nv -O "$RPM1" "$LE2_URL/$RPM1" + [ "$?" != "0" ] && { echo "Cannot retrieve Libevent2 RPM file(s). Aborting."; exit 1; } wget -t 3 -T 30 -nv -O "$RPM2" "$LE2_URL/$RPM2" - [ ! -f "$RPM1" ] || [ ! -f "$RPM2" ] && { echo "Cannot retrieve Libevent2 RPM file(s). Aborting."; exit 1; } + [ "$?" != "0" ] && { echo "Cannot retrieve Libevent2 RPM file(s). Aborting."; exit 1; } rpm -ivh --force "$RPM1" "$RPM2" && /bin/rm -f "$RPM1" "$RPM2" elif grep -qs "release 7" /etc/redhat-release; then yum -y install libevent-devel @@ -131,7 +132,7 @@ fi SWAN_FILE="libreswan-${SWAN_VER}.tar.gz" SWAN_URL="https://download.libreswan.org/$SWAN_FILE" wget -t 3 -T 30 -nv -O "$SWAN_FILE" "$SWAN_URL" -[ ! -f "$SWAN_FILE" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } +[ "$?" != "0" ] && { echo "Cannot retrieve Libreswan source file. Aborting."; exit 1; } /bin/rm -rf "/opt/src/libreswan-$SWAN_VER" tar xvzf "$SWAN_FILE" && /bin/rm -f "$SWAN_FILE" cd "libreswan-$SWAN_VER" || { echo "Failed to enter Libreswan source dir. Aborting."; exit 1; }