From: Frank Brehm Date: Wed, 22 Apr 2020 09:49:44 +0000 (+0200) Subject: Checking existence of necessary files in bin/start-openfortivpn X-Git-Tag: 0.1.2~5^2~3 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=cb6e9abefb1455515d5f90707a2e620114484706;p=pixelpark%2Fadmin-tools.git Checking existence of necessary files in bin/start-openfortivpn --- diff --git a/bin/start-openfortivpn b/bin/start-openfortivpn index d7607a9..4df1dd6 100755 --- a/bin/start-openfortivpn +++ b/bin/start-openfortivpn @@ -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