From c0c0b189287ba23c7787a08fa147b52aafefd227 Mon Sep 17 00:00:00 2001 From: Ajee <93165947+ajee10x@users.noreply.github.com> Date: Wed, 30 Nov 2022 23:51:13 -0500 Subject: [PATCH] Use 'cd ... || exit' or 'cd ... || return' in case cd fails. Line 243 cd /etc/openvpn/server/easy-rsa/ || exit Line 463 cd /etc/openvpn/server/easy-rsa/ || exit Line 496 cd /etc/openvpn/server/easy-rsa/ || exit --- openvpn-install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 4235723..6feacb5 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -240,7 +240,7 @@ LimitNPROC=infinity" > /etc/systemd/system/openvpn-server@server.service.d/disab mkdir -p /etc/openvpn/server/easy-rsa/ { wget -qO- "$easy_rsa_url" 2>/dev/null || curl -sL "$easy_rsa_url" ; } | tar xz -C /etc/openvpn/server/easy-rsa/ --strip-components 1 chown -R root:root /etc/openvpn/server/easy-rsa/ - cd /etc/openvpn/server/easy-rsa/ + cd /etc/openvpn/server/easy-rsa/ || exit # Create the PKI, set up the CA and the server and client certificates ./easyrsa --batch init-pki ./easyrsa --batch build-ca nopass @@ -460,7 +460,7 @@ else read -p "Name: " unsanitized_client client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client") done - cd /etc/openvpn/server/easy-rsa/ + cd /etc/openvpn/server/easy-rsa/ || exit ./easyrsa --batch --days=3650 build-client-full "$client" nopass # Generates the custom client.ovpn new_client @@ -493,7 +493,7 @@ else read -p "Confirm $client revocation? [y/N]: " revoke done if [[ "$revoke" =~ ^[yY]$ ]]; then - cd /etc/openvpn/server/easy-rsa/ + cd /etc/openvpn/server/easy-rsa/ || exit ./easyrsa --batch revoke "$client" ./easyrsa --batch --days=3650 gen-crl rm -f /etc/openvpn/server/crl.pem