0

The file below is the default network-manager.conf upstart job.

$ cat /etc/init/network-manager.conf
# network-manager - network connection manager
#
# The Network Manager daemon manages the system's network connections,
# automatically switching between the best available.

description "network connection manager"

start on (local-filesystems
      and started dbus
      and static-network-up)
stop on stopping dbus

expect fork
respawn

script
    # set $LANG so that messages appearing on the GUI will be translated. See LP: 875017
    if [ -r /etc/default/locale ]; then
        . /etc/default/locale
        export LANG LANGUAGE LC_MESSAGES LC_ALL
    fi

    exec NetworkManager
end script

I want to execute sudo nmcli nm enable false after network-manager is started, but I can't get it to work in an upstart job. I have tried two different ways.

First attempt

$ sudo vi /etc/init/network-manager.override
# network-manager - network connection manager
#
# The Network Manager daemon manages the system's network connections,
# automatically switching between the best available.

description "network connection manager"

start on (local-filesystems
      and started dbus
      and static-network-up)
stop on stopping dbus

expect fork
respawn

script
    # set $LANG so that messages appearing on the GUI will be translated. See LP: 875017
    if [ -r /etc/default/locale ]; then
        . /etc/default/locale
        export LANG LANGUAGE LC_MESSAGES LC_ALL
    fi

    exec NetworkManager
    exec /usr/bin/nmcli nm enable false <-- added this

end script

FAILS

$ sudo cat /var/log/upstart/network-manager.log
** (process:3453): WARNING **: Could not initialize NMClient /org/freedesktop/NetworkManager: The name org.freedesktop.NetworkManager was not provided by any .service files

** (process:3453): WARNING **: Error enabling/disabling networking: The name org.freedesktop.NetworkManager was not provided by any .service files

Second attempt

$ sudo vi /etc/init/network-manager-disable.conf
#start on started network-manager <-- tested as well but doesn't work
start on starting network-manager

task

exec /usr/bin/nmcli nm enable false

FAILS

$ sudo cat /var/log/upstart/network-manager-disable.conf
** (process:2423): WARNING **: Could not initialize NMClient /org/freedesktop/NetworkManager: The name org.freedesktop.NetworkManager was not provided by any .service files

** (process:2423): WARNING **: Error enabling/disabling networking: The name org.freedesktop.NetworkManager was not provided by any .service files

sudo nmcli nm enable false works fine on the command line, but not in upstart. Btw I don't want to remove the network-manager, e.g. echo "manual" > /etc/init/network-manager.override.

Any suggestions?

3
  • You do not need sudo in the upstart job. This is probably not what is causing your issue, but the usage is unnecessary. Jan 16, 2015 at 3:10
  • Thanks yeah I removed it earlier but didn't update it here. Will do now.
    – hydrajump
    Jan 16, 2015 at 4:02
  • Try exec dbus-launch --exit-with-session nmcli ..., like in this post.
    – muru
    Jan 16, 2015 at 5:22

1 Answer 1

0

Perhaps use the second method, but make sure to use the started network-manager event and then add a line with pre-start exec sleep 2.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .