1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-vps.git synced 2025-02-15 04:42:12 +00:00

Set VPN IP only when possible

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-04-07 16:06:54 +02:00
parent adabff20cb
commit 42c7489c23
3 changed files with 18 additions and 4 deletions

View file

@ -4,5 +4,7 @@
INTF=gt-${DEV} INTF=gt-${DEV}
[ -z "$LOCALIP" ] && LOCALIP="10.255.255.1" [ -z "$LOCALIP" ] && LOCALIP="10.255.255.1"
[ -z "$BROADCASTIP" ] && BROADCASTIP="10.255.255.3" [ -z "$BROADCASTIP" ] && BROADCASTIP="10.255.255.3"
ip link set dev ${INTF} up 2>&1 >/dev/null [ "$(ip addr show dev $INTF | grep -o 'inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*')" != "$LOCALIP" ] && {
ip addr add ${LOCALIP}/30 brd ${BROADCASTIP} dev ${INTF} 2>&1 >/dev/null ip link set dev ${INTF} up 2>&1 >/dev/null
ip addr add ${LOCALIP}/30 brd ${BROADCASTIP} dev ${INTF} 2>&1 >/dev/null
}

View file

@ -4,5 +4,7 @@
INTF=gt-udp-${DEV} INTF=gt-udp-${DEV}
[ -z "$LOCALIP" ] && LOCALIP="10.255.254.1" [ -z "$LOCALIP" ] && LOCALIP="10.255.254.1"
[ -z "$BROADCASTIP" ] && BROADCASTIP="10.255.254.3" [ -z "$BROADCASTIP" ] && BROADCASTIP="10.255.254.3"
ip link set dev ${INTF} up 2>&1 >/dev/null [ "$(ip addr show dev $INTF | grep -o 'inet [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | grep -o '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*')" != "$LOCALIP" ] && {
ip addr add ${LOCALIP}/30 brd ${BROADCASTIP} dev ${INTF} 2>&1 >/dev/null ip link set dev ${INTF} up 2>&1 >/dev/null
ip addr add ${LOCALIP}/30 brd ${BROADCASTIP} dev ${INTF} 2>&1 >/dev/null
}

View file

@ -18,6 +18,15 @@ _glorytun_udp() {
logger -t "OMR-Service" "Restart Glorytun-UDP" logger -t "OMR-Service" "Restart Glorytun-UDP"
systemctl -q restart glorytun-udp@* systemctl -q restart glorytun-udp@*
} }
for intf in /etc/glorytun-udp/*; do
/etc/glorytun-udp/post.sh /etc/glorytun-udp/${intf}
done
}
_glorytun_tcp() {
for intf in /etc/glorytun-tcp/*; do
/etc/glorytun-tcp/post.sh /etc/glorytun-tcp/${intf}
done
} }
_omr_api() { _omr_api() {
@ -29,6 +38,7 @@ _omr_api() {
while true; do while true; do
_glorytun_udp _glorytun_udp
_glorytun_tcp
_multipath _multipath
_omr_api _omr_api
sleep 10 sleep 10