Answer the question
In order to leave comments, you need to log in
Why doesn't the script in /etc/NetworkManager/dispatcher.d/ work?
Hello
, the day before yesterday I switched to Ubuntu 19.04
while the flight is normal: not a single freeze)
in general, in the previous Debian, I
had a file in /etc/NetworkManager/dispatcher.d/ that, when connected to a vpn, reconfigures network routes
[email protected]:~# ls -las /etc/NetworkManager/dispatcher.d/
итого 28
4 drwxr-xr-x 5 root root 4096 мая 10 01:59 .
4 drwxr-xr-x 7 root root 4096 мая 9 16:02 ..
4 -rwxr-xr-x 1 root root 2293 апр 2 18:53 01-ifupdown
4 -rwxrwxrwx 1 root root 1798 янв 28 18:05 nm-vpn-routes
4 drwxr-xr-x 2 root root 4096 апр 2 18:53 no-wait.d
4 drwxr-xr-x 2 root root 4096 апр 2 18:53 pre-down.d
4 drwxr-xr-x 2 root root 4096 апр 2 18:53 pre-up.d
journalctl -u NetworkManager --since "15 min ago"
Answer the question
In order to leave comments, you need to log in
in fact, it was the same script, because it did not catch $1 and $2 from NetworkManager
#!/bin/sh -e
# Script to dispatch NetworkManager events
#
# Runs ifupdown scripts when NetworkManager fiddles with interfaces.
# See NetworkManager(8) for further documentation of the dispatcher events.
if [ -z "$1" ]; then
echo "$0: called with no interface" 1>&2
exit 1;
fi
# Run the right scripts
case "$2" in
vpn-up)
logger -s "HELLO THIS IS YOUR SCRIPT"
touch "/home/vpn-up.txt
#преобразования маршрутов и иные действия
set -x
;;
vpn-down)
touch "/home/vpn-down.txt"
#преобразования маршрутов и иные действия
;;
hostname|dhcp4-change|dhcp6-change)
# Do nothing
;;
*)
echo "$0: called with unknown action \`$2'" 1>&2
exit 1
;;
esac
#!/bin/bash
#
tag=$(basename "$0")
if [ "$2" = vpn-up ]; then
set -x
# Modify dns
set -x
fi |& logger -i -t "$tag"
if [ "$2" = vpn-down ]; then
# echo "vpn-down" >> /tmp/iface
fi |& logger -i -t "$tag"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question