PDA

View Full Version : LMS stop/start/restart on Ubuntu 16.04 LTS - how to do it without root password?



bobertuk
2017-07-11, 02:45
I've just set up LMS on Ubuntu 16.04 LTS (on an Intel NUC) and I'm trying to get LMS to restart after installing plugins. I've been using...

service logitechmediaserver restart

which works fine but it insists on requiring the root password.

Is there any way of stop/start/restart LMS without needing to enter the root password? I've done a lot of 'googling' and there are lots of suggestions about using 'visudo' to add entries to sudoers but none of the variations work. I know it can be done - I have max2play set up on an Odroid-XU4 (again, Ubuntu 16.04 LTS) and that does it without requiring the password but I can't work out how max2play does it.

Any ideas or suggestions appreciated.

Bob

drmatt
2017-07-11, 03:17
Your user account would normally already be in sudoers file after an Ubuntu install so you should be able to do "sudo service LMS restart" and it will prompt for *your* password not root's.


Transcoded from Matt's brain by Tapatalk

bobertuk
2017-07-11, 03:37
Yeah I understand that. I want to restart LMS without needing any password. I know it's possible but can't figure it out.

Jeff07971
2017-07-11, 03:48
https://unix.stackexchange.com/questions/18830/how-to-run-a-specific-program-as-root-without-a-password-prompt

In sudoers file

MYUSERNAME ALL = NOPASSWD: /path/to/my/program

mherger
2017-07-11, 04:21
> Yeah I understand that. I want to restart LMS without needing any
> password. I know it's possible but can't figure it out.

Doesn't LMS give you the restart prompt after updating the plugins?

--

Michael

kidstypike
2017-07-11, 04:34
> Yeah I understand that. I want to restart LMS without needing any
> password. I know it's possible but can't figure it out.

Doesn't LMS give you the restart prompt after updating the plugins?

--

Michael

Funny you should ask that, I've noticed this last few days that LMS does now give a prompt to restart and a button to actually restart LMS.

Always did on Windows.

It never used to (on piCorePlayer).

bobertuk
2017-07-11, 05:11
> Yeah I understand that. I want to restart LMS without needing any
> password. I know it's possible but can't figure it out.

Doesn't LMS give you the restart prompt after updating the plugins?

--

Michael

With Ubuntu it always says LMS will need to be restarted but never prompts for a restart. It's been that way for as long as I can remember and it's been that way, for me at least, on all the other flavours of Linux that I've tried.

Edit...
Windows has always prompted for a restart and OSX does it automatically.

Edit 2...
just checked to make sure. After selecting a new plugin LMS prompts with...

Please restart Logitech Media Server for the changes to take effect.
OK

But never prompts for a restart.

kidstypike
2017-07-11, 05:26
With Ubuntu it always says LMS will need to be restarted but never prompts for a restart. It's been that way for as long as I can remember and it's been that way, for me at least, on all the other flavours of Linux that I've tried.

Edit...
Windows has always prompted for a restart and OSX does it automatically.

Edit 2...
just checked to make sure. After selecting a new plugin LMS prompts with...

Please restart Logitech Media Server for the changes to take effect.
OK

But never prompts for a restart.

... but it does on piCorePlayer, it never used to.

As I said above this is new (a few days) behaviour.

Just installed "What was that tune" .. restart prompt and button below.

23084

paul-
2017-07-11, 05:33
I'm using the same setup, LMS restarts itself just fine. I am running from the git source code, but that shouldn't make a difference.

mherger
2017-07-11, 05:49
> I'm using the same setup, LMS restarts itself just fine. I am running
> from the git source code, but that shouldn't make a difference.

It might be related to the Custom.pm changes I applied. Would have to
look them up in detail...

--

Michael

slartibartfast
2017-07-11, 06:28
> I'm using the same setup, LMS restarts itself just fine. I am running
> from the git source code, but that shouldn't make a difference.

It might be related to the Custom.pm changes I applied. Would have to
look them up in detail...

--

Michael
LMS never prompts for a restart after installing plugins for me on a Pi and hasn't for years.I am pretty sure it used to when I was running a Squeezeplug but it stopped offering a restart at some point while I was still using the Squeezeplug.

Sent from my SM-G900F using Tapatalk

mherger
2017-07-11, 07:19
> LMS never prompts for a restart after installing plugins for me on a Pi
> and hasn't for years.I am pretty sure it used to when I was running a
> Squeezeplug but it stopped offering a restart at some point while I was
> still using the Squeezeplug.

It depends on the Linux flavour you're using. Maybe (can't remember all
details) Debian/Ubuntu/Raspbian can't do it, but pCP can.

--

Michael

paul-
2017-07-11, 07:53
Unix.pm should have set canRestartServer to 1. But if something turned that off, then you won't see it.

Edit your server.prefs to be sure this is still set to 1

bobertuk
2017-07-11, 11:14
Unix.pm should have set canRestartServer to 1. But if something turned that off, then you won't see it.

Edit your server.prefs to be sure this is still set to 1

I'm not home at the moment so can't check. Is unix.pm and server.prefs part of the LMS installation?

paul-
2017-07-11, 11:50
<path to slimserver>/prefs/server.prefs

I just ran a test on my system. having canRestartServer: 0 in the prefs doesn't stop the server from restating itself..... There is also a command line switch --norestart. You might take a look at the systemd service configuration, and make sure that it is not adding --norestart to the commandline.

mherger
2017-07-11, 11:54
> Unix.pm should have set canRestartServer to 1. But if something turned
> that off, then you won't see it.
>
> Edit your server.prefs to be sure this is still set to 1

It's not a preference set in the prefs file, but a decision taken at
runtime. Unix is the mother of Linux and Debian etc. The method would be
different in any one of them.

--

Michael

paul-
2017-07-11, 12:07
It's not a preference set in the prefs file, but a decision taken at
runtime. Unix is the mother of Linux and Debian etc. The method would be
different in any one of them.


Linux.pm and Debian.pm do not redefine canRestartServer

mherger
2017-07-11, 12:31
> Linux.pm and Debian.pm do not redefine canRestartServer

Oh, you're right. On Debian the --norestart startup parameter is
applied, because there's the _safe watchguard. I guess that could be
improved...

--

Michael

paul-
2017-07-11, 15:02
For what it's worth, debian/ubuntu is now systemd

This is all I have in my lms.service, systemd doesn't care if lms restarts itself.



[Unit]
Description=Logitech Media Server Daemon
After=network-online.target mnt-media.mount
Wants=network-online.target

[Service]
User=lms
Group=lms
PIDFile=/var/run/logitechmediaserver.pid
WorkingDirectory=/opt/slimserver
ExecStart=/opt/slimserver/slimserver.pl --charset utf8
RestartSec=10
TimeoutStartSec=60
Restart=always

[Install]
WantedBy=multi-user.target

bobertuk
2017-07-11, 23:10
> Linux.pm and Debian.pm do not redefine canRestartServer

Oh, you're right. On Debian the --norestart startup parameter is
applied, because there's the _safe watchguard. I guess that could be
improved...

--

Michael

If it's possible to get LMS restart working on Ubuntu/Debian (or other similar flavours) it would be much appreciated. It is a function I've missed for a long while - especially after coming originally from Windows OS's.

Haven't taken the opportunity to thank you Michael for continuing to support and develop LMS. The hard work you put in for the LMS community it much appreciated by us all. Thank you.

Thank you to all the other users that provide assistance as well. You are not forgotten!

Bob

mherger
2017-07-13, 02:06
> For what it's worth, debian/ubuntu is now systemd

Does this conflict with our current package?

--

Michael

paul-
2017-07-13, 03:02
> For what it's worth, debian/ubuntu is now systemd

Does this conflict with our current package?

--

Michael

Not really, systemd handles old init scripts okay. I'm just not sure why --norestart was needed with the older Debian packages.

mherger
2017-07-13, 03:18
> Not really, systemd handles old init scripts okay. I'm just not sure
> why --norestart was needed with the older Debian packages.

Oh, that's LMS specific: there's the squeezebox_safe (or similar)
wrapper script which would automatically restart LMS if it crashed.
Therefore LMS should not be re-started internally. But it could just
exit to get restarted. I'd need to customize the restart related code in
S::U::OS::Debian.

--

Michael

paul-
2017-07-13, 07:01
That's where systemd does help out. It handles restarting a crashed service.

But, I would assume that a wrapper script is checking to see if the PID is still running to detect a crashed service. Currently when LMS restarts itself the main PID of slimserver doesn't change. So how would allowing lms to restart itself interfere?

blackbite
2017-08-31, 00:10
> Not really, systemd handles old init scripts okay. I'm just not sure
> why --norestart was needed with the older Debian packages.

Oh, that's LMS specific: there's the squeezebox_safe (or similar)
wrapper script which would automatically restart LMS if it crashed.
Therefore LMS should not be re-started internally. But it could just
exit to get restarted. I'd need to customize the restart related code in
S::U::OS::Debian.

--

Michael

Hi Michael,

ist this still "under investigation" by you? I would really like to do a restart of lms after a plugin update via the web gui if the old wrapper script or the --norestart option is no longer needed in "newer" debian dists.
Im running LMS (7.9.1 latest nightly) on a RPI3 (stretch) without any problems. If i stop lms and restart it manual via command line without the --norestart option it work flawlessly. Tested myself by disabling and enabling the Amazon plugin. The Restart Option was shown and it did restart the lms as it was supposed to do.
Many thanks.
Thorsten

blackbite
2017-08-31, 00:34
> Not really, systemd handles old init scripts okay. I'm just not sure
> why --norestart was needed with the older Debian packages.

Oh, that's LMS specific: there's the squeezebox_safe (or similar)
wrapper script which would automatically restart LMS if it crashed.
Therefore LMS should not be re-started internally. But it could just
exit to get restarted. I'd need to customize the restart related code in
S::U::OS::Debian.

--

Michael

Hi Michael,

ist this still "under investigation" by you? I would really like to do a restart of lms after a plugin update via the web gui if the old wrapper script or the --norestart option is no longer needed in "newer" debian dists.
Im running LMS (7.9.1 latest nightly) on a RPI3 (stretch) without any problems. If i stop lms and restart it manual via command line without the --norestart option it work flawlessly. Tested myself by disabling and enabling the Amazon plugin. The Restart Option was shown and it did restart the lms as it was supposed to do.
Many thanks.
Thorsten

mherger
2017-08-31, 01:29
ist this still "under investigation" by you? I would really like to do a restart of lms after a plugin update via the web gui if the old wrapper script or the --norestart option is no longer needed in "newer" debian dists.
Im running LMS (7.9.1 latest nightly) on a RPI3 (stretch) without any problems. If i stop lms and restart it manual via command line without the --norestart option it work flawlessly. Tested myself by disabling and enabling the Amazon plugin. The Restart Option was shown and it did restart the lms as it was supposed to do.
Many thanks.
Thorsten

I'd say it's still on my to-do list, but not under active investigation. But if you're saying that removing the --norestart from the startup script was all that was needed, then I could certainly give this a try. Could you please test the following:


remove --norestart
update or install a plugin, requiring a restart
let LMS do the restart
then go and try to restart LMS from the shell, using the startup script


Would that still work?

blackbite
2017-08-31, 14:48
Sorry for tripple posting... First posts were delayed.
Will test tomorrow and come back with feedback.
Danke Michael
Gre Thorsten

JohnB
2017-08-31, 15:04
I agree it would be helpful if restart could happen, when required, within the GUI in Ubuntu.

The command line I use to restart (in Ubuntu 14.04) is:


sudo /etc/init.d/logitechmediaserver restart

where the "restart" can also be replaced by "stop" or "start".

As far as I can see, this command hasn't been mentioned in the thread.

HB64
2017-08-31, 22:23
"systemctl restart logitechmediaserver" is even better, but i agree it would be great if this could be doen from within the GUI.

DJanGo
2017-08-31, 23:02
I'd say it's still on my to-do list, but not under active investigation. But if you're saying that removing the --norestart from the startup script was all that was needed, then I could certainly give this a try. Could you please test the following:

Would that still work?


Stop the Server -> service logitechmediaserver stop
Make sure nothing with Perl is running -> killall Perl
Edit /usr/sbin/squeezeboxserver_safe
change line 41 from:
"$@" --norestart > /dev/null 2>&1 &
to:
"$@" > /dev/null 2>&1 &
restart the Server
add/remove any plugin -> now the Restart button in the Gui appears.

mherger
2017-08-31, 23:39
> - Stop the Server -> service logitechmediaserver stop
> - Make sure nothing with Perl is running -> killall Perl
> - Edit /usr/sbin/squeezeboxserver_safe
> - change line 41 from:
> *"$@" --norestart > /dev/null 2>&1 &*
> to:
> *"$@" > /dev/null 2>&1 &*
> - restart the Server
> - add/remove any plugin -> now the Restart button in the Gui
> appears.

But would you still be able to restart LMS using the OS' regular way
(sysctl or whatever) once you've restarted it from within LMS?

--

Michael

drmatt
2017-09-01, 01:51
Systemd uses logind to create a cgroup for the whole shebang, so it keeps track of all the process and child processes that get spawned by the start script. The stop/start actions will still work as they are invoked blind by running /etc/init.d/logitechmediaserver as normal.


Transcoded from Matt's brain by Tapatalk

DJanGo
2017-09-01, 03:12
But would you still be able to restart LMS using the OS' regular way
(sysctl or whatever) once you've restarted it from within LMS?

--

Michael

Why not?

Both Processes are still owned by the User squeezeboxserver.
In this case (your not the User that start the Process) you need to be the privileged User root.
There is no change after removing the --noRestart option.

TbH i have no clue whean and why this option is included there but it seems to be a forgotten feature (squeezeboxserver instead of logitechmediaserver)
cheers

mherger
2017-09-01, 04:42
>> But would you still be able to restart LMS using the OS' regular way
>> (sysctl or whatever) once you've restarted it from within LMS?
>
> Why not?

Because shit happens.

> Both Processes are still owned by the User squeezeboxserver.
> In this case (your not the User that start the Process) you need to be
> the privileged User root.
> There is no change after removing the --noRestart option.

I'm not interested in being lectured about the theoretical aspects of my
question. Really. Just tell me whether it works or not. Thanks!

--

Michael

drmatt
2017-09-01, 05:09
It's a fair question. Quite often the PID of a Daemon is tracked in /var/run/thingy and changing the PID of the process without using the official start/stop scripts means they lose track of which process to kill or check the status of.


Transcoded from Matt's brain by Tapatalk

DJanGo
2017-09-01, 07:14
I'm not interested in being lectured about the theoretical aspects of my
question. Really. Just tell me whether it works or not. Thanks!

--

Michael

Hi Michael,

?

Of curse its "tested" on my side and other than "first test and then wrote here" i wouldnt be able to tell "nothings changed".

cheers

mherger
2017-09-01, 08:19
> Of curse its "tested" on my side and other than "first test and then
> wrote here" i wouldnt be able to tell "nothings changed".

Thanks!

--

Michael

karlek
2017-09-01, 11:25
> - Stop the Server -> service logitechmediaserver stop
> - Make sure nothing with Perl is running -> killall Perl
> - Edit /usr/sbin/squeezeboxserver_safe
> - change line 41 from:
> *"$@" --norestart > /dev/null 2>&1 &*
> to:
> *"$@" > /dev/null 2>&1 &*
> - restart the Server
> - add/remove any plugin -> now the Restart button in the Gui
> appears.

But would you still be able to restart LMS using the OS' regular way
(sysctl or whatever) once you've restarted it from within LMS?

--

Michael

I did as @DJanGo tried (no running Perl was detected). Afterwards I updated some Plugins and indeed LMS showed me the Dialog with option to restart, which I selected.
I then restarted LMS via console an both worked flawless.


Logitech Media Server Version: 7.9.1 - 1503129892 @ Sat Aug 19 09:11:02 UTC 2017
Hostname: raspberrypi
IP-Adresse des Servers: 192.168.178.37
Server-HTTP-Portnummer: 9000
Betriebssystem: Debian - DE - utf8
Plattformarchitektur: armv7l-linux
Perl-Version: 5.20.2 - arm-linux-gnueabihf-thread-multi-64int

Thanks!

mherger
2017-09-01, 19:01
Ok, I removed that flag. Please give the next update another try. Thanks!

--

Michael

blackbite
2017-09-02, 01:03
Ok, I removed that flag. Please give the next update another try. Thanks!

--

Michael

Hi Michael,

just to give you one more feedback...
Did the test with 7.9.1 - 15003129892 (as @DJanGo described it perfectly. TNX).
And here its also positive. So thank you for the update. Will try out...


Logitech Media Server Version: 7.9.1 - 1503129892 @ Sat Aug 19 09:29:31 UTC 2017
Hostname: raspberrypi3
IP-Adresse des Servers: 192.168.69.198
Server-HTTP-Portnummer: 9001
Betriebssystem: Debian - DE - utf8
Plattformarchitektur: armv7l-linux
Perl-Version: 5.24.1 - arm-linux-gnueabihf-thread-multi-64int

Thorsten

karlek
2017-09-02, 03:02
Ok, I removed that flag. Please give the next update another try. Thanks!

--

Michael

For arm there is no new deb-package, yet. (Others are already online.)
I'll try as soon it is available.

mherger
2017-09-03, 11:48
> For arm there is no new deb-package, yet. (Others are already online.)
> I'll try as soon it is available.

I'm sorry, yes, the build systems are down. I'll look into this.

--

Michael

karlek
2017-09-03, 12:13
Take your time. :)

karlek
2017-09-04, 04:53
I tried it with the new 7.9.1 - 1504317335:


installed a plugin.
chose "Restart.." from within the dialog
waited until the new scan was finished
restarted via sudo systemctl restart logitechmediaserver


Works! :)

blackbite
2017-09-04, 11:10
Ok, I removed that flag. Please give the next update another try. Thanks!

--

Michael

Hi there,
did the test on 7.9.1 - 1504317335:
-forced plugin change so restart message appeared
-did restart from within gui
-waited for lms to come up, checked ps -ax
-restarted lms via ssh: sudo service logitechmediaserver restart
-ps -ax showed lms pid and lms wrapper pid as it should

Everything fine!

Did a restart from ssh for a few more times just to see if something will fail. But it looks good.
Think were done!

Great, tnx Michael

mherger
2017-09-04, 12:59
> Works! :)

Thanks for the testing!

--

Michael

SlimChances
2017-09-04, 18:34
Works fine for Linux Mint;)