Opennet Firmware
 Alle Dateien Funktionen Variablen Gruppen Seiten
mig_openvpn_updown.sh
gehe zur Dokumentation dieser Datei
1 #!/bin/sh
2 #
3 # Opennet Firmware
4 #
5 # Copyright 2010 Rene Ejury <opennet@absorb.it>
6 # Copyright 2014 Lars Kruse <devel@sumpfralle.de>
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 
15 
16 set -eu
17 
18 MSG_FILE=/tmp/openvpn_msg.txt
19 # die PATH-Umgebungsvariable beim Ausfuehren des openvpn-Skripts beinhaltet leider nicht die sbin-Verzeichnisse
20 IP_BIN=$(PATH=$PATH:/sbin:/usr/sbin which ip)
21 
22 
23 # Allgemeine openvpn-Ereignisbehandlung
24 on-function log_openvpn_events_and_disconnect_if_requested "mig-openvpn-connections"
25 
26 # Sonder-Aktionen für mig-Verbindungen
27 case "$script_type" in
28  up)
29  echo "vpn-tunnel active" >"$MSG_FILE" # a short message for the web frontend
30  uplink_table=$(on-function get_variable "ROUTING_TABLE_ON_UPLINK")
31  "$IP_BIN" route add default via "$route_vpn_gateway" table "$uplink_table" || true
32  ;;
33  down)
34  rm -f "$MSG_FILE"
35  ;;
36 esac 2>&1 | logger -t mig-updown
37 
38 exit 0
39