only reboot if vpn isn't used
if [ $(ifstat -i tun0 1s 1 | awk 'NR==3 {print $1}' | sed 's#\..*##') -eq 0 ]; then systemctl reboot; fi
fix routing
replace <localip>
by the IP
routing.sh
#!/bin/bash
# supression d'une ancienne route
ip route del <localip> 2> /dev/null
# ajoute de la nouvelle route avec la bonne IP
ip route add <localip> via $(ip -4 -br addr show tun0 | awk '{split($3,a,"/"); print a[1]}') dev tun0
echo "Done :)"
# vérification
# ip route
run the script
if [ $(ip route | grep <localip> | wc -l) -ne 1 ]; then /path/to/script/routing.sh; fi
rsync
at the client side, aka the receiver, add this option: --exclude 'directory'
to exclude something