Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Restart samba service

  1. #1

    Default Restart samba service

    Hi (openSUSE 13.1,kde 4.12)
    Often when I start the PC, I can not, then, open the samba shares, ...to restore the navigation between the shares I have to give the command:
    Code:
    systemctl restart smb
    I've tried to automatically restart the service,
    adding this lines in:
    "/etc/init.d/boot.local"
    ... but unfortunately not function

    but if, i restart the service after the kde log-on, everything works fine.
    where do I place the command to avoid the manual service restart ?

    Ciaooo a tutti

  2. #2

    Default Re: Restart samba service

    Quote Originally Posted by NeverGiveUp01 View Post
    Hi (openSUSE 13.1,kde 4.12)
    Often when I start the PC, I can not, then, open the samba shares, ...to restore the navigation between the shares I have to give the command:
    Code:
    systemctl restart smb
    I've tried to automatically restart the service,
    adding this lines in:
    "/etc/init.d/boot.local"
    ... but unfortunately not function

    but if, i restart the service after the kde log-on, everything works fine.
    where do I place the command to avoid the manual service restart ?
    Maybe there's no network connection when smb starts during boot?

    Hint: If you configured a wireless connection with KDE's networkmanagement applet, it will only be connected when the user logs in.

    So if you are using NetworkManager I would suggest two things to try:
    - Click on "Manage connections" in the networkmanagement applet, edit your connection and set it to a "System connection"
    - Switch to "Traditional method with ifup" in YaST->Network Devices->Network Settings->Global Options. Note: in that case you have to set up your connection in YaST as well, if it is a wireless one (wired should work out-of-the-box). KDE's networkmanagement applet will not work at all then.

  3. #3

    Default Re: Restart samba service

    Quote Originally Posted by wolfi323 View Post
    Maybe there's no network connection when smb starts during boot?

    Hint: If you configured a wireless connection with KDE's networkmanagement applet, it will only be connected when the user logs in.

    So if you are using NetworkManager I would suggest two things to try:
    - Click on "Manage connections" in the networkmanagement applet, edit your connection and set it to a "System connection"
    - Switch to "Traditional method with ifup" in YaST->Network Devices->Network Settings->Global Options. Note: in that case you have to set up your connection in YaST as well, if it is a wireless one (wired should work out-of-the-box). KDE's networkmanagement applet will not work at all then.





    I tried to edit my LAN connection on my applets "NetkorkManager," No, but I have no foud any setting
    like "System connction"
    ...Ok now I understand, the setting that you say, is on the old applets "plasmoid-networkmanagement"
    but, I'm using "plasma-NM", which I find more complete

    in any case, as you say, go and find a connection to the system is not the correct way, perhaps, it may happen that my connection to be available a long time after the start.
    Regarding "ifup", I do not like and would like to continue to use NetworkManager

    ...but I can not go to intercept the event "activated connection" and associate it to "restart smb", in some way


    Ciaooo e grazie 1000 per il tuo aiuto

  4. #4

    Default Re: Restart samba service

    Quote Originally Posted by NeverGiveUp01 View Post
    ...Ok now I understand, the setting that you say, is on the old applets "plasmoid-networkmanagement"
    but, I'm using "plasma-NM", which I find more complete
    Well, the last time I tried it, I didn't find plasma-nm complete (or even ready) at all. But that's a matter of taste I guess...

    The option may be called "Share this connection with other users" there or similar (like in GNOME).

    But a wired LAN connection should be setup as "System connection" by default anyway.

    in any case, as you say, go and find a connection to the system is not the correct way, perhaps, it may happen that my connection to be available a long time after the start.
    Have you enabled the "NetworkManager-wait-online.service"?
    Code:
    systemctl status NetworkManager-wait-online.service
    (or use YaST->System->Services Manager)

    Try to set "NM_ONLINE_TIMEOUT" to a higher value in /etc/sysconfig/network/config.

    Regarding "ifup", I do not like and would like to continue to use NetworkManager
    Hm. I don't see any reason to use NetworkManager with only a wired connection, but well. (especially if you want to have network services running)

    At least you could try to see if that is indeed the issue.

    ...but I can not go to intercept the event "activated connection" and associate it to "restart smb", in some way
    Actually smb.service is configured to start _after_ network.service finished, so this should not be necessary.
    "NetworkManager-wait-online.service" should solve your problem I think.

    Automatically restarting the service when the state of a connection changes should be possible with a NetworkManager dispatcher script I think.
    Maybe have a look at /etc/NetworkManager/dispatcher.d/autofs (should be installed by default I guess).

  5. #5

    Default Re: Restart samba service

    What about it ? ...it is right ?
    Code:
    # systemctl status NetworkManager-wait-online.service
    NetworkManager-wait-online.service - Network Manager Wait Online
       Loaded: loaded (/usr/lib/systemd/system/NetworkManager-wait-online.service; enabled)
       Active: inactive (dead) since dom 2014-01-05 09:37:30 CET; 4h 4min ago
       Process: 1091 ExecStart=/bin/bash -c if [ ${NM_ONLINE_TIMEOUT} -gt 0 ];  then /usr/bin/nm-online -q --timeout=${NM_ONLINE_TIMEOUT} ; else  /bin/true ; fi (code=exited, status=0/SUCCESS)
     Main PID: 1091 (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/NetworkManager-wait-online.service
    
    gen 05 09:37:30 NetbookVaio systemd[1]: Starting Network Manager Wait Online...
    gen 05 09:37:30 NetbookVaio systemd[1]: Started Network Manager Wait Online.

    what could be the correct parameter value ? If I change in "100" it means 100ms ?
    Code:
    ## Type:    int
    ## Default:    0
    #
    # When using NetworkManager you may define a timeout to wait for NetworkManager
    # to connect in /etc/init.d/network(-remotefs) script.  Other network services
    # may require the system to have a valid network setup in order to succeed.
    # 
    # This variable has no effect if NETWORKMANAGER=no.
    #
    NM_ONLINE_TIMEOUT="0"
    It is right, in "/etc/sysconfig/NetworkManager/dspatcher.d/ " there is e script called "autofs" ...do you mean that i can edit it adding a command ?

  6. #6

    Default Re: Restart samba service

    Quote Originally Posted by NeverGiveUp01 View Post
    What about it ? ...it is right ?
    Code:
    # systemctl status NetworkManager-wait-online.service
    NetworkManager-wait-online.service - Network Manager Wait Online
       Loaded: loaded (/usr/lib/systemd/system/NetworkManager-wait-online.service; enabled)
       Active: inactive (dead) since dom 2014-01-05 09:37:30 CET; 4h 4min ago
       Process: 1091 ExecStart=/bin/bash -c if [ ${NM_ONLINE_TIMEOUT} -gt 0 ];  then /usr/bin/nm-online -q --timeout=${NM_ONLINE_TIMEOUT} ; else  /bin/true ; fi (code=exited, status=0/SUCCESS)
     Main PID: 1091 (code=exited, status=0/SUCCESS)
       CGroup: /system.slice/NetworkManager-wait-online.service
    
    gen 05 09:37:30 NetbookVaio systemd[1]: Starting Network Manager Wait Online...
    gen 05 09:37:30 NetbookVaio systemd[1]: Started Network Manager Wait Online.
    Yes, it is enabled and run at boot.

    what could be the correct parameter value ? If I change in "100" it means 100ms ?
    No, the timeout is specified in seconds, so "100" means 100s.
    What the correct value is you have to decide yourself. It will wait that long in the worst case during boot for a connection to be established.
    If the timeout value is 100 and no connection can be established (f.e. because no cable is connected), you will have a 100s hang during boot.
    OTOH, if the value is too small, the connection may not be up yet, so it won't help you.

    It is right, in "/etc/sysconfig/NetworkManager/dspatcher.d/ " there is e script called "autofs" ...do you mean that i can edit it adding a command ?
    No. Copy it and edit the copy (name it "samba" or similar for clarity). First the "autofs" script is of course intended for autofs, so just editing it may cause confusions.
    Second, if you edit that, your changes will get lost if there ever is an update to autofs.

  7. #7

    Default Re: Restart samba service

    for better understand i've add the command "md /home/pippo/jhon"
    and than connect the LAN ....but nothing happens
    the script should be edited differently?
    I have to save it in some particular folder or in dispatcher.d


    Code:
    . /etc/rc.status
    
    case "$2" in
        up)
            if test -x /bin/systemctl && systemctl -q is-enabled autofs.service; then
                    systemctl restart autofs.service
            elif rc_active autofs; then
                    /etc/init.d/autofs restart
            fi
            ;;
        *)
            exit 0
            ;;
    esac
    
    md /home/pippo/jhon

  8. #8

    Default Re: Restart samba service

    Quote Originally Posted by NeverGiveUp01 View Post
    for better understand i've add the command "md /home/pippo/jhon"
    and than connect the LAN ....but nothing happens
    the script should be edited differently?
    I have to save it in some particular folder or in dispatcher.d
    Of course it has to be in /etc/NetworkManager/dispatcher.d/, yes.
    And you should replace all occurences of "autofs.service" with "smb.service" if you want to restart smb.service, otherwise nothing will change on your system obviously.

    So copy /etc/NetworkManager/dispatcher.d/autofs to /etc/NetworkManager/dispatcher.d/smb (f.e., the name does not really matter).
    Then edit that to look like this (or don't copy it and just create a new file with this content):
    Code:
    #! /bin/sh
    . /etc/rc.status
    
    case "$2" in
        up)
            if test -x /bin/systemctl && systemctl -q is-enabled smb.service; then
                    systemctl restart smb.service
            elif rc_active autofs; then
                    /etc/init.d/smb restart
            fi
            ;;
        *)
            exit 0
            ;;
    esac
    
    md /home/pippo/jhon
    What I forgot to say is that it should be made executable:
    Code:
    sudo chmod +x /etc/NetworkManager/dispatcher.d/smb
    If it works, don't forget to remove that "md" line then of course...

    Oh, and maybe you should also restart nmb.service as well.

  9. #9

    Default Re: Restart samba service

    PS: Also have a look at "man NetworkManager".
    This says f.e.:
    Code:
           NetworkManager  will  execute  scripts  in the /etc/NetworkManager/dis-
           patcher.d directory  in  alphabetical  order  in  response  to  network
           events.  Each script should be:
    
    
           (a) a regular file
    
    
           (b) owned by root
    
    
           (c) not writable by group or other
    
    
           (d) not set-uid
    
    
           (e) and executable by the owner
    
    
           Each  script receives two arguments, the first being the interface name
           of the device just activated, and second an action.
    ...

  10. #10

    Default Re: Restart samba service

    nothing to do :
    the script is executed as "root: root"
    I gave:
    Code:
    "# Systemctl restart NetworkManager-dispatcher.service"
    "# Systemctl restart NetworkManager.service"
    "# Systemctl restart nmb.service"
    "# Systemctl restart smb.service"
    I then attacked and pulled the LAN connection but "Jhon" not want to be seen
    Code:
    #! /bin/sh
    # autofs dispatcher script for NetworkManager#
    #       NetworkManager  will  execute  scripts  in the /etc/NetworkManager/dis-
    #       patcher.d directory  in  alphabetical  order  in  response  to  network
    #       events.  Each script should be:
    #       (a) a regular file
    #       (b) owned by root
    #       (c) not writable by group or other
    #       (d) not set-uid
    #       (e) and executable by the owner
    #       Each  script receives two arguments, the first being the interface name
    #       of the device just activated, and second an action.
    . /etc/rc.status
    
    case "$2" in
         up)
            systemctl restart smb.service
            rm -rf /home/pippo/jhon
            ;;
        down)
             md /home/pippo/jhon
          exit 0
            ;;
           *)
           # md /home/pippo/jhon
            exit 0
            ;;
    esac
    md /home/pippo/jhon
    echo "$2"
    ". /etc/rc.status" which value should be returned ??

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •