Public bug reported:

Binary package hint: samba

When my laptop boots network is not yet configured since NM didnĀ“t start it 
yet. Samba however tries to start since it is in S20 on rc2-5.d but it fails 
immediately because no network is configured yet. Running - sudo 
/etc/init.d/samba restart - is fine.
In the log file I can find the following pair of errors:
[2009/04/18 11:22:48,  0] lib/interface.c:load_interfaces(540)
  WARNING: no network interfaces found
[2009/04/18 11:22:49,  0] smbd/server.c:open_sockets_smbd(548)
  open_sockets_smbd: No sockets available to bind to.

Trying to resolve the problem, I wrote an updown script in 
/etc/NetworkManager/dispatcher.d naming it 02samba:
$ ls -l  /etc/NetworkManager/dispatcher.d
total 12K
-rwxr-xr-x 1 root root 1.3K 2008-10-21 05:17 01ifupdown
-rwxr-xr-x 1 root root 1.9K 2009-05-08 11:35 02samba

If this solution makes sense I would recommend that it would be added to Ubuntu 
samba server package.
Here is the script I wrote:
#!/bin/sh -e
# Script to dispatch NetworkManager events
#
# Runs ifupdown scripts when NetworkManager fiddles with interfaces.

if [ -z "$1" ]; then
    echo "$0: called with no interface" 1>&2
    exit 1;
fi

# Fake ifupdown environment
export IFACE="$1"
export LOGICAL="$1"
export ADDRFAM="NetworkManager"
export METHOD="NetworkManager"
export VERBOSITY="0"
notRunningCont=`/etc/init.d/samba status | grep -c not`  # count "not running"

# Run the right scripts
case "$2" in
    up)
        export MODE="start"
        export PHASE="up"
        if [ -e /var/run/network/ifstate ]
        then
                if grep --silent eth /var/run/network/ifstate
                then
                        case $notRunningCont in # count "not running"
                        2) # both smbd and nmbd are down. start them
                                exec /etc/init.d/samba start
                                ;;
                        1) # probably smbd faild. 
                                exec /etc/init.d/samba restart
                                ;;
                        0) # samba seems running
                                ;;
                        *) # unknown situation. try to restart anyways
                                exec /etc/init.d/samba restart
                        esac
                fi
        fi
        ;;
    down)
        export MODE="stop"
        export PHASE="down"
        if [ -e /var/run/network/ifstate ]
        then
                if grep --silent eth /var/run/network/ifstate
                then # network is still up. Make sure samba is also up. 
                        case  $notRunningCont in
                        2) # both smbd and nmbd are down. start them
                                exec /etc/init.d/samba start
                                ;;
                        1) # probably smbd faild. 
                                exec /etc/init.d/samba restart
                                ;;
                        0) # samba seems running
                                ;;
                        *) # unknown situation. try to restart anyways
                                exec /etc/init.d/samba restart
                        esac
                else # shut samba down
                        exec /etc/init.d/samba stop
                fi
        else # same here. Shut it down
                exec /etc/init.d/samba stop
        fi
        ;;
   pre-up)
        export MODE="start"
        export PHASE="pre-up"
        exec run-parts /etc/network/if-pre-up.d
        ;;
    post-down)
        export MODE="stop"
        export PHASE="post-down"
        exec run-parts /etc/network/if-post-down.d
        ;;
    *)
        echo "$0: called with unknown action \`$2'" 1>&2
        exit 1
        ;;
esac

** Affects: samba (Ubuntu)
     Importance: Undecided
         Status: New

-- 
samba server fails to start on boot time when laptop is not connected to any 
network.
https://bugs.launchpad.net/bugs/374589
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to samba in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs

Reply via email to