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:
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.
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
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”?
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).
# 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 ?
## 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 ?
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.
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
. /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
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):
#! /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:
PS: Also have a look at “man NetworkManager”.
This says f.e.:
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.
...
I then attacked and pulled the LAN connection but “Jhon” not want to be seen
#! /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 ??
What do you mean with that? Did you run all that in a terminal?
I hope you did not type that ‘#’, otherwise it will just be ignored as it is a comment.
And it’s “systemctl” with a lowercase ‘s’ as first character.
I then attacked and pulled the LAN connection but “Jhon” not want to be seen
#! /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.
I didn’t mean that you should add that red part to the file. You should just read and understand it.
Otherwise the script should be fine now AFAICS.
But the last “md” and “echo” lines will only be reached in the “up” case since exit is called before that in any other case, but I guess you know that.
“. /etc/rc.status” which value should be returned ??
This defines some functions for sysvinit scripts. You could in fact just remove that line, since you removed the sysvinit calls anyway (and you don’t need them either because smb.service is a native systemd unit).
-rwxr-xr-x 1 root root 418 5 gen 17.26 autofs
-rwxr-xr-x 1 root root 326 14 ott 10.21 nfs
-rwxr-xr-x 1 root root 907 5 gen 16.45 smb
-rwxrwxr-x 1 root root 934 5 gen 17.00 smb2
-rwx------ 1 root root 832 5 gen 17.58 smb4
And which one is your file now?
smb and smb4 should be ok, smb2 has the wrong permissions.
But to avoid confusions, stick to one of the files and remove the other 2 I would say.
Oh, and regarding “md”.
“md” is only an alias to “mkdir”, that command doesn’t really exist.
So use “mkdir”, “md” might not be defined when NetworkManager calls the script.
As I said. “md” does not exist as a command.
It is set as alias to “mkdir -p”. I had a look now and this is done in /etc/profile.d/alias.bash and that is not evaluated when your script is called.
or commented lines at the beginning of the script … I have listed only as a reminder
No, that should not have mattered, since that were comments anyway.
I just thought you misunderstood me.
Now I have to mark the post as solved … where is it done?
There’s no means to do that here.
Just add a “SOLVED” or similar to the title.