forked from pschmitt/pia-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pia-route-up
39 lines (34 loc) · 1.27 KB
/
pia-route-up
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/sh
# Source config file
test "$PIA_CONF" || PIA_CONF='/etc/pia-tools.conf'
[[ -r "$PIA_CONF" ]] && . $PIA_CONF
if [[ -z "$TRANSMISSION_SETTINGS_FILE" ]]; then
TRANSMISSION_SETTINGS_FILE='/home/dl/.config/transmission-daemon/settings.json'
fi
check_transmission() {
systemctl is-active transmission > /dev/null 2>&1
}
if [[ -n "$VPN_USER" ]]; then
ip route add "$trusted_ip"/32 via $route_net_gateway table $VPN_USER
ip route add 0.0.0.0/1 via $route_vpn_gateway table $VPN_USER
ip route add 128.0.0.0/1 via $route_vpn_gateway table $VPN_USER
ip route add "$route_network_1"/32 via $route_vpn_gateway table $VPN_USER
ip route add $ifconfig_remote dev $dev scope link src $ifconfig_local table $VPN_USER
if [[ `ip rule list | grep -c 0x3` == 0 ]]; then
ip rule add from all fwmark 0x3 lookup $VPN_USER
fi
ip route append default via 127.0.0.1 dev lo table $VPN_USER
ip route flush cache
fi
if check_transmission; then
echo -n 'Stopping transmission... '
systemctl stop transmission
echo 'Done!'
fi
sed -i "s/.*bind-address-ipv4.*/ \"bind-address-ipv4\": \"$ifconfig_local\",/g" $TRANSMISSION_SETTINGS_FILE
if check_transmission; then
echo -n 'Starting transmission... '
systemctl start transmission
echo 'Done!'
fi
exit 0