From 768642b92f98a72e0c91e590a36cf134d5455460 Mon Sep 17 00:00:00 2001 From: MarkusMcNugen Date: Mon, 16 Apr 2018 01:15:40 -0400 Subject: [PATCH] Update start.sh --- openvpn/start.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/openvpn/start.sh b/openvpn/start.sh index 0fd42ea..1a77636 100755 --- a/openvpn/start.sh +++ b/openvpn/start.sh @@ -50,13 +50,12 @@ if [[ $VPN_ENABLED == "yes" ]]; then echo "${VPN_USERNAME}" > /config/openvpn/credentials.conf echo "${VPN_PASSWORD}" >> /config/openvpn/credentials.conf - - # Get line number of auth-user-pass - LINE_NUM=$(grep -Fn -m 1 'auth-user-pass' ${VPN_CONFIG} | cut -d: -f 1) # Replace line with one that points to credentials.conf - auth_cred_exist=$(cat ${VPN_CONFIG} | grep -m 1 'auth-user-pass credentials.conf') - if [[ -z "${auth_cred_exist}" ]]; then + auth_cred_exist=$(cat ${VPN_CONFIG} | grep -m 1 'auth-user-pass') + if [[ ! -z "${auth_cred_exist}" ]]; then + # Get line number of auth-user-pass + LINE_NUM=$(grep -Fn -m 1 'auth-user-pass' ${VPN_CONFIG} | cut -d: -f 1) sed -i "${LINE_NUM}s/^/auth-user-pass credentials.conf\n/" ${VPN_CONFIG} fi fi