]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Checking existence of necessary files in bin/start-openfortivpn
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 22 Apr 2020 09:49:44 +0000 (11:49 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 22 Apr 2020 09:49:44 +0000 (11:49 +0200)
bin/start-openfortivpn

index d7607a9b8ffb5762c77258411955a774acb0663e..4df1dd6a7880d8a026f8905991528467b5fab783 100755 (executable)
@@ -9,6 +9,7 @@ BIN_DIR=$( dirname "${MY_REAL_NAME}" )
 BASE_DIR=$( dirname "${BIN_DIR}" )
 LIB_DIR="${BASE_DIR}/lib"
 CONF_DIR="${BASE_DIR}/etc"
+DNS_DIR="${BASE_DIR}/dns"
 
 if [[ -f "${LIB_DIR}/functions.rc" ]] ; then
     . "${LIB_DIR}/functions.rc"
@@ -93,6 +94,9 @@ check_preferences() {
 
     info "Checking preferences ..."
     local all_ok="y"
+    local rfile=
+    local file_ok="y"
+    local sample_file=
 
     debug "Checking for openfortivpn ..."
     if type -p openfortivpn >/dev/null ; then
@@ -102,6 +106,26 @@ check_preferences() {
         error "Did not found openfortivpn. Maybe not installed?"
     fi
 
+    for rfile in "${RESOLV_CONF_DPX}" "${RESOLV_CONF_NON_DPX}" ; do
+        debug "Checking '${CYAN}${rfile}${NORMAL}' ..."
+        file_ok="y"
+        if [[ ! -e "${rfile}" ]] ; then
+            error "File '${RED}${rfile}${NORMAL}' does not exists."
+            file_ok="n"
+        elif [[ ! -r "${rfile}" ]] ; then
+            error "File '${RED}${rfile}${NORMAL}' exists, but is not a regular file."
+            file_ok="n"
+        elif [[ ! -s "${rfile}" ]] ; then
+            error "File '${RED}${rfile}${NORMAL}' exists, but is emty."
+            file_ok="n"
+        fi
+        if [[ "${file_ok}" != 'y' ]] ; then
+            sample_file="${DNS_DIR}/$( basename "${rfile}" )"
+            warn "You may copy '${CYAN}${sample_file}${NORMAL}' to '${CYAN}${rfile}${NORMAL}' and modify it for your needs."
+            all_ok="n"
+        fi
+    done
+
     if [[ "${all_ok}" != "y" ]] ; then
         exit 5
     fi