Actualiser vpn-deluge-daemon.sh

This commit is contained in:
Thibault Heckel 2024-04-15 13:37:18 +02:00
parent 78fda8c051
commit 314c9efbd3

View File

@ -18,7 +18,7 @@ function start() {
# access the real network, and configure the interface in the namespace (vpn1)
# to use the interface out of the namespace (vpn0) as its default gateway
ip link add vpn0 type veth peer name vpn1
ip link set vpn0 up
ip link set vpn0 up
ip link set vpn1 netns vpnns up
ip addr add 10.200.200.1/24 dev vpn0
@ -42,8 +42,8 @@ function start() {
ip netns exec vpnns openvpn --config /home/cruiser/openvpn-files/delugevpn.ovpn &!
while ! ip netns exec vpnns ip a show dev tun0 up; do
sleep .5
done
sleep .5
done
# Start the deluge-deamon
ip netns exec vpnns sudo -u deluge deluged &!
@ -57,18 +57,18 @@ function start() {
}
function stop() {
ip netns pids vpnns | xargs -rd'\n' sudo kill
ip netns pids vpnns | xargs -rd'\n' sudo kill
ip netns del vpnns
lsof -i tcp:8112 | grep "*:8112" | awk '{print $2}' | xargs kill
lsof -i tcp:58846 | grep "*:58846" | awk '{print $2}' | xargs kill
rm -rf /etc/netns/vpnns
rm -rf /etc/netns/vpnns
sysctl -q net.ipv4.ip_forward=0
iptables -D INPUT \! -i vpn0 -s 10.200.200.0/24 -j DROP
iptables -t nat -D POSTROUTING -s 10.200.200.0/24 -o en+ -j MASQUERADE
iptables -D INPUT \! -i vpn0 -s 10.200.200.0/24 -j DROP
iptables -t nat -D POSTROUTING -s 10.200.200.0/24 -o en+ -j MASQUERADE
ip link delete vpn0
}
@ -83,4 +83,3 @@ case "${1}" in
exit 1
;;
esac