Unable to Start/Stop Hyperion
Closed this issue · 13 comments
Hey there,
I set up a fresh Hyperion on Raspbian and then went on to set up the Web App as described in the Readme. Everything works fine, except starting and stopping the Hyperion service.
After taking a look in the sources if realized, that the web app uses "initctl start/stop hyperion" by default and my fresh install of hyperion automatically set itself up to use init.d as a managing service.
What would the way to go, if I want the Web App to use the ini.d commands ("sudo /etc/init.d hyperion start/stop/restart")?
Or would it be better to somehow switch the managing service (init.d --> initctl)?
And did anyone else experience this behavior on a fresh install of Hyperion on Raspbian?
Hi there,
Yeah I believe someone else had this issue, and that's why in the configuration within the conf directory a setting was added for serverController. Have you tried changing value to '/etc/init.d'?
Hi again,
Just tested this functionality, and there was a bug with the command structure. I have pushed an update to fix this now.
What you will need to do is pull the latest version, then within the configuration.php file update:
'serverController' => '/etc/init.d',
'serverControllerType' => 'postfix',
This should then operate as expected.
Thanks for the fix.
I tested it but still can't get it to work. I have the feeling, that it is a problem with the permissions, because I can start/stop the Hyperion service only with sudo rights.
I don't have any experience with nginx yet, the default error.log in /var/log/nginx is stillt empty, while the access.log seems to log all requests.
Is there any way I can debug to find out what is wrong with my setup?
Hi there,
When I tested I only check that the commands were being built correctly, not that they executed.
Let me do some testing, Ill need to setup a fresh instance of rapsbian and see if somehow we can allow the www-data user access to that certain command using groups. I assume attaching sudo to the start of /etc/init.d didn't work?
As for debugging, you can add a line in executeCommand method in the remote command class at the top with this: "error_log($command);". I'll aim to introduce a debug config too, which will do the same thing and document it too.
Thanks very much for your effort!
and you are right, attaching sudo does not work either.
I will dig into the code tomorrow and debug a little, maybe I'll find a solution.
Hey there,
I just wanted to check if you've made any progress on the issue?
I sadly wasn't able to find a solution.
Starting and the stopping hyperion with /etc/init.d/hyperion start/stop
simply does nothing if executed by the shell_exec command and it doesn't throw any errors, so I really can't say whats going wrong here. Your debug method helped me to understand the code, so thanks for that.
I tried running the start/stop command from a python script and I had success doing so. That would mean that it is almost certainly a issue with the permissions.
I hope this helps a little.
Hi there,
I've been away so not had any time to look into the issue properly. I am convinced that it can be achieved by adding sudo permissions to the www-data user for that service. An interim solution could be to update the start and stop methods to call your phython script until I can document a full fix for the issue.
Hi again,
Finally had time to look into this issue, and I've pushed a commit to both fix an issue with the /etc/init.d calls, and introduced debugging as a configuration option.
I've also spent some time setting up the www-data user with the permissions to execute the start/stop commands and have come up with the following, it seems to work for me, but I've only been testing with the service, and no LED's attached.
sudo vim /etc/sudoers
In the section "# Cmnd alias specification" add:
Cmnd_Alias WEBDAEMONS /etc/init.d/hyperion
In the section "#includedir /etc/sudoers.d" add:
www-data ALL = (root) NOPASSWD: WEBDAEMONS
Let me know how you get on, and if this method works, I'll introduce it into the documentation.
Thanks very much, you are amazing!
Two little things though:
I had problems with the entries in the sudoers file.
- we should use "pkexec visudo" to edit the file, because it does a syntax check.
- I had to add a "=" to the Cmnd_Alias like so: "Cmnd_Alias WEBDAEMONS = /etc/init.d/hyperion"
The only thing that stopped working is that the App doesn't discover if the daemon is running or not. The "Turn Off" Button is always there, even if the daemon is not running.
Furthermore I would like the App to turn all LED's black when turned off, but I will try to figure this out by myself.
Thanks very much for your work!
Hi again,
I'll give those suggestions a whirl later and get them added to the installation docs.
Did the app detect the state before the new update was pushed? Or has it always been a problem? I'll take a look into this too.
So you want to turn the LED's black, then turn off the service? If so add the code below "case 'TurnOff':" in the index.php file.
$com->withServer($config['serverAddress'], $config['serverUsername'], $config['serverPassword'], $config['debug'])
->withAddress($config['hyperionAddress'])
->withPriority(500)
->withColour('000000')
->callColour();
I implemented the changes you suggested to around the visudo, and can confirm they are working, I'll get those added to the documentation.
I've also just looked into the issue around the "Turn Off" button always appearing, and with the current code in the master branch all seems to working as expected. Just out of interest, try re-cloning the repository, and ensure the settings in the conf/Configuration.php are as follows:
'serverController' => '/sbin/initctl',
'serverControllerType' => 'postfix',
I re-installed the whole App and it works now. I have absolutely no clue why it didn't work in the first place.
The problem is solved now, thanks very much for your work, keep on going with the good work!
Glad you got things working. Let me know if you come across any other issues.