DNS_DIR="${BASE_DIR}/dns"
OFVPN_CONFIG="/etc/openfortivpn/config"
+FINISHED='n'
+
if [[ -f "${LIB_DIR}/functions.rc" ]] ; then
. "${LIB_DIR}/functions.rc"
else
}
+#------------------------------------------------------------------------------
+emerge_exit() {
+
+ warn "${YELLOW}Emergency exit${NORMAL}."
+ restore_normal_conf
+
+ debug "Deactivating trap ..."
+ trap - INT TERM EXIT ABRT
+
+ info "Finished."
+ exit 5
+
+}
+
#------------------------------------------------------------------------------
start_vpn() {
debug "Activating trap ..."
- trap restore_normal_conf INT TERM EXIT ABRT
+ trap emerge_exit INT TERM EXIT ABRT
info "Enabling special ${CYAN}/etc/resolv.conf${NORMAL} by ${CYAN}${RESOLV_CONF_DPX}${NORMAL} ..."
CP -p "${RESOLV_CONF_DPX}" /etc/resolv.conf
+ info "Starting openfortivpn ..."
local cmd="openfortivpn --no-dns --pppd-no-peerdns"
- debug "Executing: ${cmd}"
- eval ${cmd}
+ info "Executing: ${cmd}"
+ eval ${cmd} 2>&1 | tee -a "${LOGFILE}"
debug "Deactivating trap ..."
trap - INT TERM EXIT ABRT
restore_normal_conf
+ info "Finished."
+
}
#------------------------------------------------------------------------------
CYAN=""
NORMAL=""
-VERSION="0.3.9"
+VERSION="0.4.0"
STD_SHORT_OPTIONS="sdvhV"
STD_LONG_OPTIONS="simulate,debug,verbose,nocolor,help,version"
fi
local ts=$(my_date)
if [[ -n "${LOGFILE}" ]] ; then
- echo "[${ts}] [${BASE_NAME}DEBUG]: $@" >>"${LOGFILE}"
+ echo -e "[${ts}] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $@" >>"${LOGFILE}"
fi
echo -e " * [${ts}] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $@" >&2
}
info() {
local ts=$(my_date)
if [[ -n "${LOGFILE}" ]] ; then
- echo "[${ts}] [${BASE_NAME}INFO] : $@" >>"${LOGFILE}"
+ echo -e "[${ts}] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >>"${LOGFILE}"
fi
echo -e " ${GREEN}*${NORMAL} [${ts}] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >&2
}
warn() {
local ts=$(my_date)
if [[ -n "${LOGFILE}" ]] ; then
- echo "[${ts}] [${BASE_NAME}WARN] : $@" >>"${LOGFILE}"
+ echo -e "[${ts}] [${BASE_NAME}:${YELLOW}WARN${NORMAL}] : $@" >>"${LOGFILE}"
fi
echo -e " ${YELLOW}*${NORMAL} [${ts}] [${BASE_NAME}:${YELLOW}WARN${NORMAL}] : $@" >&2
}
error() {
local ts=$(my_date)
if [[ -n "${LOGFILE}" ]] ; then
- echo "[${ts}] [${BASE_NAME}ERROR]: $@" >>"${LOGFILE}"
+ echo -e "[${ts}] [${BASE_NAME}:${RED}ERROR${NORMAL}]: $@" >>"${LOGFILE}"
fi
echo -e " ${RED}*${NORMAL} [${ts}] [${BASE_NAME}:${RED}ERROR${NORMAL}]: $@" >&2
}