N
N
Nikolay Baranenko2019-05-12 14:47:45
linux
Nikolay Baranenko, 2019-05-12 14:47:45

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

in general, there are enough rights, BUT when vpn is activated, it does not work ; I
check the logs in this way:
journalctl -u NetworkManager --since "15 min ago"
it is clear that a VPN connection is being established, nothing more.
Why doesn't the script in /etc/NetworkManager/dispatcher.d/ work?
and how else is it possible to make a correct debug?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolay Baranenko, 2019-05-16
@drno-reg

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

x.z.
why didn’t it catch like that, BUT maybe it’s a feature of Ubuntu 19.04
#!/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"

G
ggruno, 2019-05-13
@ggruno

Does the script run as root? try to give the file to the user from under which you want to start the script

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question