Action exécutée lors du redémarrage après mise en veille
Publié le 07/02/2020 Systemd
Ces programmes sont lancés avec deux paramètres : $1 = "pre" ou "post" et $2 = "suspend", "hibernate", "hybrid-sleep", ou "suspend-then-hibernate".
On peut ainsi savoir si le contexte est celui d'arrêt ou de redémarrage, pour une mise en veille ou une hibernation.
On peut ainsi créer des programmes comme :
#!/bin/sh # Remove The existing connections to ssh.fournier38.fr # Put it in /lib/systemd/system-sleep/sshShared # chmod 755 /lib/systemd/system-sleep/sshShared if [ "$1" = "post" ] && [ "$2" = "suspend" ]; then su USER -c 'ssh proxy-ssh -o "ControlPath /tmp/ssh-socket-%C" -O exit' fi
ou
#!/bin/sh # Remove all the existing IPv6 routes to not block the first connections # Put it in /lib/systemd/system-sleep/ipv6defaultroutes # chmod 755 /lib/systemd/system-sleep/ipv6defaultroutes if [ "$1" = "post" ] && [ "$2" = "suspend" ]; then /bin/ip -6 route flush default fi