Set Gain from Browser

a.txt says

[sudo] password for www-data: www-data is not in the sudoers file.  This incident will be reported.
[sudo] password for www-data: www-data is not in the sudoers file.  This incident will be reported.
[sudo] password for www-data: www-data is not in the sudoers file.  This incident will be reported.
[sudo] password for www-data: www-data is not in the sudoers file.  This incident will be reported.

I am away from home, cannot access Pi. Will try when back home. Your code is python script, which will require installation of python.

I am trying to find a bash script for reading gain setting from file /etc/default/dump1090-mutability. This will basically use grep.

This seems to old log. Open /tmp/a.txt in nano and delete ALL lines and save. Then try open IP/setgain/index.php in browser, change gain, and check again cat /tmp/a.txt

well I deleted all lines in a.txt and saved it. i cleared the browser in windows (using vivaldi)
and run ip-of-mypi/etc… current gain found ok. without pressing the ‘set gain’ button returned to
a.txt which already had 2 lines same as above. then i cleared all lines findgain.sh and
re-run.
still a.txt produces error message which points to sudo / www-data.

Strange. I never find this either in Piaware SD card img or Raspbian Stretch image.

@evangelyul
Can you try following? It is a bash script command and does not require installation of python.

sed -n '/GAIN.*/p'  /etc/default/dump1090-mutability   

root@traSD32:/home/pi# sed -n ‘/GAIN.*/p’ /var/www/html/setgain/dump1090-mutability
GAIN=“44.5”

made a copy for convenience to the setgain dir. so this works (extracting gain)

so will replace findgain.sh but the sudo problem remains.


if you dont mind - will continue editing this post to avoid more clutter -


ed-1

cleared a.txt
uncommented the line in sudoers
nano new error in a.txt

>>> /etc/sudoers: syntax error near line 27 <<<
sudo: parse error in /etc/sudoers near line 27
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

ED-2

modified the /etc/sudoers as follows…

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
www-data        ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

in /etc/sudoers.d made a file www-data with one line
www-data ALL=(ALL) NOPASSWD: ALL

and now findgain.sh works an no error in a.txt
still not settind gain…

.

Updated item (2) Edit file findgain.sh in my post for stretch+mutability.

yes using that already but with a …typo :wink: so now fixed
everything works for the dump1090-mutability !

thank you abcd567 :grin:

so all the problem was the sudoers that required manual editing

Was the typo by you or by me? If it was by me, please let me know what and in which post, so that I can correct it.

no by me /etc/defAault/ iso /etc/default
it is almost 02:00 here…:wink:

confirmed by a.txt
sed: can't read /etc/defaault/dump1090-mutability: No such file or directory

:smile: Glad it is working now.

I am still surprised why you faced sudo problem.
I have tested my method on 2 Piaware SD card installs + 1 Stretch+dump1090-mut installs. Never faced this problem once I gave command sudo adduser www-data sudo and then rebooted.

well, I can only speculate, maybe something with the admin user/pwd for the mutability web server ?
(Joe’s script)
also, not using stretch but jessie-lite.

.

That is what i suspect. I suggest you try a fresh install. Burn Stretch lite (or Jessie lite), and install ONLY dump1090-mutability. No “salad” :smile:

Since I did not want “salad” to disturb my experiment, after writing Stretch Lite image, I did not use JP script for installing dump1090-mutability. I used manual install.

Note:
If you choose Stretch and Manual install of mutab, then AFTER manually installing dump1090-mutability v 1.15~dev, you will have to do following workaround. I think Joe’s script performs this workaround if it detect OS is Stretch.

sudo wget -O /etc/udev/rules.d/rtl-sdr.rules "https://raw.githubusercontent.com/osmocom/rtl-sdr/master/rtl-sdr.rules"  
sudo reboot  

.

The Piaware SD Card image is also Jessie lite, and it did not give me any problem.

.

In step 2 you may wish to consider specifying your script by name instead of giving access to all root commands to www-data. This is generally considered more secure as long as you limit who can write to your script.

Good idea. Can you please tell how to do this?

username ALL=(ALL) NOPASSWD: /path/to/script I think! :slight_smile:

@Jranderson777

Thanks, will give it a try.

hi abcd567
re-imaged the SD and installed dump1090-mutability per above instructions.
updated + upgraded stretch-lite.
mutability works, albeit message ‘unknown version’
started working on the gain and get stuck here

root@raspberrypi:/home/pi# apt-get install -y php5-cgi
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5-cgi is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php5-cgi' has no installation candidate

The package php5-cgi is for Jessie.
The package php7.0-cgi is for Stretch.

sudo apt-get install php7.0-cgi