Actualiser server

Mylloon 2023-12-23 20:38:38 +01:00
parent 16d863e504
commit 48396128be
Signed by: Forgejo
GPG key ID: E72245C752A07631

@ -1,10 +1,31 @@
only reboot if vpn isn't used # only reboot if vpn isn't used
```bash ```bash
if [ $(ifstat -i tun0 1s 1 | awk 'NR==3 {print $1}' | sed 's#\..*##') -eq 0 ]; then systemctl reboot; fi if [ $(ifstat -i tun0 1s 1 | awk 'NR==3 {print $1}' | sed 's#\..*##') -eq 0 ]; then systemctl reboot; fi
``` ```
fix routing # fix routing
> replace `<localip>` by the IP > replace `<localip>` by the IP
## `routing.sh`
```bash
#!/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
```bash ```bash
if [ $(ip route | grep <localip> | wc -l) -ne 1 ]; then /root/openvpn/routing.sh; fi if [ $(ip route | grep <localip> | wc -l) -ne 1 ]; then /root/openvpn/routing.sh; fi
``` ```