]> Frank Brehm's Git Trees - pixelpark/admin-tools.git/commitdiff
Notification on shutting down VPN
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 15 Jun 2021 07:09:57 +0000 (09:09 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 15 Jun 2021 07:09:57 +0000 (09:09 +0200)
bin/start-openfortivpn
lib/functions.rc

index 196ab710eae83f96c474eb7a9f4bd33cbd474a3e..dfb90457821e671c2187f6ebaed4663ce686e3ce 100755 (executable)
@@ -104,13 +104,16 @@ check_preferences() {
     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."
@@ -173,8 +176,13 @@ restore_normal_conf() {
 #------------------------------------------------------------------------------
 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
@@ -184,11 +192,34 @@ emerge_exit() {
 
 }
 
+#------------------------------------------------------------------------------
+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
index d124156140ddc4320b0916b7f3e88003ec34d7ae..045f5a7aade3e9379b2434fa00044f1376b5b464 100644 (file)
@@ -10,7 +10,7 @@ BLUE=""
 CYAN=""
 NORMAL=""
 
-VERSION="0.4.1"
+VERSION="0.4.2"
 
 STD_SHORT_OPTIONS="sdvqhV"
 STD_LONG_OPTIONS="simulate,debug,verbose,quiet,nocolor,help,version"