local sample_file=
local gateway_ip=
- debug "Checking for openfortivpn ..."
- if type -p openfortivpn >/dev/null ; then
- debug "Found openfortivpn in '$( type -p openfortivpn )'."
- else
- all_ok="n"
- error "Did not found openfortivpn. Maybe not installed?"
- fi
+ local -a tools=('openfortivpn' 'zenity' )
+ for tool in "${tools[@]}" ; do
+ debug "Checking for '${CYAN}${tool}${NORMAL}' ..."
+ if type -p ${tool} >/dev/null ; then
+ debug "Found '${CYAN}${tool}${NORMAL} in '${CYAN}$( type -p ${tool} )${NORMAL}'."
+ else
+ all_ok="n"
+ error "Did not found '${RED}${tool}${NORMAL}'. Maybe not installed?"
+ fi
+ done
if [[ ! -f "${OFVPN_CONFIG}" ]] ; then
error "Config file '${RED}${OFVPN_CONFIG}${NORMAL}' not found."
#------------------------------------------------------------------------------
emerge_exit() {
- warn "${YELLOW}Emergency exit${NORMAL}."
+ local signal="$1"
+
+ local msg="Emergency exit by signal '${signal}'."
+
+ warn "${YELLOW}${msg}${NORMAL}"
restore_normal_conf
+ zenity --warning --title "${BASE_NAME}" --no-wrap --text "${msg}"
debug "Deactivating trap ..."
trap - INT TERM EXIT ABRT
}
+#------------------------------------------------------------------------------
+exit_abrt() {
+ emerge_exit 'ABRT'
+}
+
+#------------------------------------------------------------------------------
+exit_exit() {
+ emerge_exit 'EXIT'
+}
+
+#------------------------------------------------------------------------------
+exit_int() {
+ emerge_exit 'INT'
+}
+
+#------------------------------------------------------------------------------
+exit_term() {
+ emerge_exit 'TERM'
+}
+
#------------------------------------------------------------------------------
start_vpn() {
- debug "Activating trap ..."
- trap emerge_exit INT TERM EXIT ABRT
+ debug "Activating traps ..."
+ trap exit_abrt ABRT
+ trap exit_exit EXIT
+ trap exit_int INT
+ trap exit_term TERM
info "Enabling special ${CYAN}/etc/resolv.conf${NORMAL} by ${CYAN}${RESOLV_CONF_DPX}${NORMAL} ..."
CP -p "${RESOLV_CONF_DPX}" /etc/resolv.conf