Skip to content

Instantly share code, notes, and snippets.

@tbalthazar
Last active June 17, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbalthazar/8d14dba0fdc76bf31f981c94781ec7a3 to your computer and use it in GitHub Desktop.
Save tbalthazar/8d14dba0fdc76bf31f981c94781ec7a3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 1. Download this script in /root/neutrinet-connectivity-fix.sh
# 2. chmod +x neutrinet-connectivity-fix.sh
# 3. echo "*/5 * * * * root /sbin/ifconfig tun0 > /dev/null 2>&1 || /root/neutrinet-connectivity-fix.sh > /dev/null 2>&1" > /etc/cron.d/restart_vpn
# 4. This file should contain:
# * * * * * root /sbin/ifconfig tun0 > /dev/null 2>&1 || /root/neutrinet-connectivity-fix.sh
# Remark: test cron job by doing: run-parts -v /etc/cron.d
echo "stopping firewall..."
systemctl stop yunohost-firewall.service
echo "firewall stopped"
echo "setting nameserver..."
echo "nameserver 80.67.169.40" > /etc/resolv.conf
echo "nameserver set."
echo "restarting ntp..."
systemctl restart ntp
echo "ntp restarted."
echo "synchronise time..."
sntp pool.ntp.org
echo "new time set."
echo "restarting vpn client..."
systemctl restart ynh-vpnclient
echo "vpn client restarted."
echo "waiting 5 seconds..."
sleep 5
echo "starting firewall..."
systemctl start yunohost-firewall.service
echo "firewall started."
Copy link

ghost commented Feb 19, 2018

cool! c'est plus joli comme ça ^_^

Copy link

ghost commented Feb 19, 2018

Tu penses que c'est mieux de mettre sur toutes les briques ou uniquement sur celles qui rencontrent un problème ?

@NicolasPetton
Copy link

Petite question : pourquoi redémarrer ntp?

Copy link

ghost commented Apr 15, 2018

Je suppose que c'est dans l'idée de forcer une synchronisation de l'heure avec le grand Internet.

Ntp serait-il un service qu'il n'est pas néécessaire de redémarrer?

Peut-être qu'on pourrait juste faire # sntp pool.ntp.org au lieu de redémarrer ntp pour rien 😸

Copy link

ghost commented Apr 18, 2018

Ça génère des mail de cron toutes les minutes 🤕 !

Pour y remédier je propose:

De remplacer

# 3. create a file called restart_vpn in /etc/cron.d
# 4. This file should contain: 
#    * * * * * root /sbin/ifconfig tun0 > /dev/null 2>&1 || /root/neutrinet-connectivity-fix.sh

Par

3. echo "*/5 * * * * root /sbin/ifconfig tun0 > /dev/null 2>&1 || /root/neutrinet-connectivity-fix.sh > /dev/null 2>&1" > /etc/cron.d/restart_vpn

Pour ne pas être alerté par mail et réduire la fréquence parce que parfois ça prend plus d'une minute pour être résolu et que c'est pas indispensable de le faire à chaque minute.

Et pour le temps je propose:

echo "synchronise time..."
sntp pool.ntp.org
echo "new time set."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment