Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try restart openvpn if interface is missing #204

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion files/usr/local/bin/check-gateway
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ if [[ $MAINTENANCE -eq 0 ]]; then
/sbin/ip rule add from all fwmark 0x1 unreachable preference 32001
fi

# check for interface
# try restart openvpn if interface is missing
/sbin/ip link show dev "${GW_INTERFACE}" > /dev/null 2>&1
if [[ $? -gt 0 ]]
then
logger -t check-gatway -p daemon.info -s "Interface $GW_INTERFACE does not exist, try restart"
/usr/sbin/service openvpn restart
fi

# check again for interface
/sbin/ip link show dev "${GW_INTERFACE}" > /dev/null 2>&1
if [[ $? -gt 0 ]]
then
# count missing states and restart after $INTERFACE_MISSING minutes
INTERFACE_MISSING=$(cat "$INTERFACE_MISSING_STATE" 2>/dev/null || echo 0)
echo $(( INTERFACE_MISSING + 1)) > "$INTERFACE_MISSING_STATE"
logger -t check-gateway -p daemon.info "Interface $GW_INTERFACE does not exist, for $INTERFACE_MISSING minutes."
Expand Down