dg9vh / MMDVMHost-Dashboard

Dashboard for MMDVMHost (by G4KLX)
Creative Commons Zero v1.0 Universal
60 stars 45 forks source link

Dashboard buttons don`t work #171

Closed yo8rze closed 6 years ago

yo8rze commented 6 years ago

Hi Kim, Only View Log button working from dashboard.... I make the: sudo chown -R www-data:www-data /var/www/html sudo chmod -R 775 /var/www/html but same problem... Config is: date_default_timezone_set('UTC'); define("MMDVMLOGPATH", "/var/log/mmdvm"); define("MMDVMINIPATH", "/opt/MMDVMHost"); define("MMDVMINIFILENAME", "MMDVM.ini"); define("MMDVMHOSTPATH", "/opt/MMDVMHost/"); define("TALKERALIAS", "on"); define("DMRIDDATPATH", "/opt/MMDVMHost/DMRIds.dat"); define("YSFGATEWAYLOGPATH", ""); define("YSFGATEWAYLOGPREFIX", ""); define("YSFGATEWAYINIPATH", ""); define("YSFGATEWAYINIFILENAME", ""); define("YSFHOSTSPATH", ""); define("YSFHOSTSFILENAME", ""); define("DMRGATEWAYLOGPATH", ""); define("DMRGATEWAYLOGPREFIX", ""); define("DMRGATEWAYINIPATH", ""); define("DMRGATEWAYPATH", ""); define("DMRGATEWAYINIFILENAME", ""); define("LINKLOGPATH", ""); define("IRCDDBGATEWAY", ""); define("TIMEZONE", "Europe/Bucharest"); define("LOCALE", "en_US"); define("LOGO", ""); define("DMRPLUSLOGO", ""); define("BRANDMEISTERLOGO", ""); define("REFRESHAFTER", "60"); define("SHOWMODES", "on"); define("SHOWLH", "on"); define("SHOWLOCALTX", "on"); define("SHOWPROGRESSBARS", "on"); define("TEMPERATUREALERT", "on"); define("TEMPERATUREHIGHLEVEL", "60"); define("SWITCHNETWORKUSER", ""); define("SWITCHNETWORKPW", ""); define("ENABLEMANAGEMENT", "on"); define("VIEWLOGUSER", ""); define("VIEWLOGPW", ""); define("HALTUSER", ""); define("HALTPW", ""); define("REBOOTUSER", ""); define("REBOOTPW", ""); define("RESTARTUSER", ""); define("RESTARTPW", ""); define("REBOOTYSFGATEWAY", "sudo systemctl restart ysfgateway"); define("REBOOTMMDVM", "sudo systemctl restart mmdvmhost.service"); define("REBOOTSYS", "sudo reboot"); define("HALTSYS", "sudo shutdown now"); define("POWERONLINEPIN", ""); define("POWERONLINESTATE", ""); define("RSSI", "all"); ?>

Thank you!

dg9vh commented 6 years ago

Did you create the necessary entries in /etc/sudoers?

yo8rze commented 6 years ago

Hi Kim,Thank you for the answer.How should I do this?Regards,Cristian, YO8RZE73! Pe duminică, 11 martie 2018, 10:42:38 EET, Kim - DG9VH notifications@github.com a scris:

Did you create the necessary entries in /etc/sudoers?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dg9vh commented 6 years ago

take a look at https://github.com/dg9vh/MMDVMHost-Dashboard/blob/master/switching-networks.md

yo8rze commented 6 years ago

I have add the line: www-data ALL=(ALL) NOPASSWD: /bin/cp,/usr/local/bin/MMDVMHost,/usr/bin/killall,/sbin/halt,/sbin/reboot But buttons still not working...

darrell24015 commented 6 years ago

I'm having the same problem. My first thought was to simply add www-user (the account that the web server is running under) to the sudo users group: usermod -aG sudo www-user

In the setup steps, what's the purpose for adding the pi username and password for the restart, reboot and halt buttons? Note: this was NOT the correct solution - see later post below.

darrell24015 commented 6 years ago

Also, in the README there is this line

Buttons toolbar, security-hint: to make this function secure, please enable htpasswd-function for folder "scripts"!

Is that also related to the button functionality?

Thanks in advance - this is an awesome application and your hard work is greatly appreciated!

dg9vh commented 6 years ago

You do not enter the pi username and password - you could add any username and password you like - for example you could use another username/password-combination for switching networks than for rebooting the system. With this possibility you are able to give permissions to specific users doing one specific thing.

The Security hint is a bit obsolete (and could be removed in future from the howto) - by setting username/password-combination in setup.php you enable exactly this mechanism on the webserver.

darrell24015 commented 6 years ago

Thanks! I'm a bit confused because I don't know what you mean by "switching networks" but that's probably a functionality that I'm not seeking to use. I just need the Restart and Shutdown buttons to work so I can reboot or gracefully shutdown the Raspberry Pi without having to SSH in to the server.

dg9vh commented 6 years ago

Yes ok, so you can use different usernames/passwords for shutting down and for reboot (for example giving a co-sys ability to reboot but not to shut-down)... all clear?

darrell24015 commented 6 years ago

I do see what you're saying, but in my case there is only one user account, pi (I'm using MMDVMHost on a personal hot-spot, no other users will be logging in). I've been reading through your PHP code and getting a better idea how things are connected. I'll post again if I get the Restart and Shutdown buttons working if that will help anyone else later. Thanks again.

darrell24015 commented 6 years ago

Ok, got the Dashboard buttons working. Although, I followed a slightly different path since it was not recommended to edit the sudoers file directly, but rather add a file and amend to it. So, using visudo, I created a new file in this directory /etc/sudoers.d sudo visudo -f /etc/sudoers.d/www-data and I put in this line (you'll need to edit to match the path on your machine):

www-data ALL=(ALL) NOPASSWD: /bin/cp,/usr/bin/killall,/sbin/halt,/sbin/reboot,/path/to/MMDVMHost

Saved the new file and rebooted. Once the Dashboard came back up, everything worked! Hope this helps.

yo8rze commented 6 years ago

Thank you Darrell. Working! 73`s