Jump to content


Photo

Modifying enigma2\settings from shell


  • Please log in to reply
22 replies to this topic

#1 digib

  • Member
  • 14 posts

0
Neutral

Posted 23 March 2020 - 13:26

Hi,

 

I'm trying to remotely changing a setting from \etc\enigma2\settings file which is not available via webinterface, like when changing powerstate which is easily done as showed in some wikis

 

the setting I would like to change is:

config.av.downmix_ac3=False   (change from True to False)

 

note that when it is True, activated in menu with remotecontrol, it is not visible in settings, the line is deleted when True.

 

I try to build syntax, I don't know if it is supported, I try to guess syntax but it doesn't change value, it will just post full settings file content.

curl "http://boxIP/web/settings?e2settingname=config.av.downmix_ac3 newvalue=False"
curl "http://boxIP/web/settings?<e2settings><e2setting><e2settingname>config.av.downmix_ac3=False</e2settingname><e2settingvalue>False</e2settingvalue></e2setting</e2settings>"

If it is supported can anyone help me creating the syntax? is there a full list of shell specific enigma2 commands? (not full busybox commands, just enigma2 up to date commands to remotely change settings that are not available from webinterface)

 

Best regards

 

 



Re: Modifying enigma2\settings from shell #2 WanWizard

  • PLi® Core member
  • 70,546 posts

+1,813
Excellent

Posted 23 March 2020 - 13:39

Enigma only saves it's config when it is stopped or restarted, there is a webif link to reload E2 config, perhaps that may help.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: Modifying enigma2\settings from shell #3 digib

  • Member
  • 14 posts

0
Neutral

Posted 23 March 2020 - 13:52

Thank you

 

yes... the init command is required, but first I would need to know the correct syntax to edit the setting



Re: Modifying enigma2\settings from shell #4 digib

  • Member
  • 14 posts

0
Neutral

Posted 23 March 2020 - 13:58

Thank you

 

yes... the init command is required, but first I would need to know the correct syntax to edit the setting

EDIT: well, I think that is wrong, if enigma2 is stopped with init 2 or init 4, then shell enigma2 commands are not processed. The point of using enigma2 shell commands is precisely that they should be processed like if you were editing from OSD Menu from remote control, without having to stop enigma2.

 

The parameters "config.av.downmix_ac3" and "config.av.downmix_DTS" from settings file are editted on the fly from audio menu, don't requiere reboot or enigma2 to stop, at least from remote control. I would expect the same if we can send the shell command.


Edited by digib, 23 March 2020 - 14:01.


Re: Modifying enigma2\settings from shell #5 WanWizard

  • PLi® Core member
  • 70,546 posts

+1,813
Excellent

Posted 23 March 2020 - 14:24

I didn't say "init", I said the webif has an API endpoint to force Enigma to reload the config. This is for example used by channel editors, after a new list has been sent to the box...


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: Modifying enigma2\settings from shell #6 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 23 March 2020 - 14:31

init 4
sleep 5
sed -i -e 's/config.av.downmix_ac3=true/config.av.downmix_ac3=false/I' /etc/enigma2/settings
init 3


Re: Modifying enigma2\settings from shell #7 digib

  • Member
  • 14 posts

0
Neutral

Posted 23 March 2020 - 14:52

init 4
sleep 5
sed -i -e 's/config.av.downmix_ac3=true/config.av.downmix_ac3=false/I' /etc/enigma2/settings
init 3

Thank you! I will test when at home.

 

Another option would be to integrate the checkbox like many other options in webinterface www configuration module, but I only see compiled python files, which I don't how to manage. Are there plain text files to try to modify to add the checkbox to modfity the audio setting I'm looking forward to manage?


Edited by digib, 23 March 2020 - 14:55.


Re: Modifying enigma2\settings from shell #8 betacentauri

  • PLi® Core member
  • 7,185 posts

+323
Excellent

Posted 23 March 2020 - 15:02

Here is the git repository
https://github.com/E...lugin-OpenWebif
You can also create an issue there.
Xtrend ET-9200, ET-8000, ET-10000, OpenPliPC on Ubuntu 12.04

Re: Modifying enigma2\settings from shell #9 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 23 March 2020 - 15:23

https://github.com/E...tion#saveconfig

 

OpenWebif usage:

curl --noproxy '*' --data value="false" "http://127.0.0.1/api/saveconfig?key=config.av.downmix_ac3"

I don't know why, but using the wget command doesn't work when adding or changing a configuration item. I mean this:

wget -q -O - "http://127.0.0.1/api/saveconfig?key=config.av.downmix_ac3&value=true"

To check if the value was added or changed:

init 4        # stop the Enigma, to save the "settings" file
cat /etc/enigma2/settings | grep downmix

A note:

 

The default value is not stored in the file /etc/enigma2/settings because it is a default value.

This means that there is no need to keep this configuration item in the "settings" file.

So if you save the value as "true", which is the default value for "downmix_ac3", then this item will completely disappear from the "settings" file.
 


Edited by s3n0, 23 March 2020 - 15:26.


Re: Modifying enigma2\settings from shell #10 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 23 March 2020 - 16:24

So, as I found out on the internet, that "wget" doesn't work, because besides the "key" and "value" parameters, a third parameter "_" with generated open session number is required (for security reasons). This should probably also be obtained from cookies (but using "curl"). Even a working method with "curl" is probably just an exploit bug in OpenWebif :). However, it works.

P.S.:
Since I can only edit my post back in about 5-10 minutes, I have to write a million messages under myself :). It really irritates me. Why can't I edit your post at least 1 hour late? Why only 5-10 minutes? I think a better interval would be 1 hour. Grrr...



Re: Modifying enigma2\settings from shell #11 WanWizard

  • PLi® Core member
  • 70,546 posts

+1,813
Excellent

Posted 23 March 2020 - 16:39

Since I can only edit my post back in about 5-10 minutes, I have to write a million messages under myself :). It really irritates me. Why can't I edit your post at least 1 hour late? Why only 5-10 minutes? I think a better interval would be 1 hour. Grrr...

 

As always, the good suffer because of the bad. We have had users that retroactively modified posts, even after people had replied, completely destroying topics.

 

We've put in a feature request to make the the last post in a topic exempt (i.e. you can edit that until someone replies).


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Ultimate (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


Re: Modifying enigma2\settings from shell #12 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 23 March 2020 - 18:36

I don't know English well and I often have to modify my own misspellings and grammar mistakes. I also come across new facts for a few more minutes as I study the discussion thread up. Then I want to react / complete my post with new information, adapt it to a better understanding, but I can't. Although there is no mish-mas between the individual posts in the discussion forum, there will be many more under them :-P. And it is also not good (this creates a "flood" effect). Please change it for at least 30 minutes :).



Re: Modifying enigma2\settings from shell #13 digib

  • Member
  • 14 posts

0
Neutral

Posted 24 March 2020 - 10:30

https://github.com/E...tion#saveconfig

 

OpenWebif usage:

curl --noproxy '*' --data value="false" "http://127.0.0.1/api/saveconfig?key=config.av.downmix_ac3"

I don't know why, but using the wget command doesn't work when adding or changing a configuration item. I mean this:

wget -q -O - "http://127.0.0.1/api/saveconfig?key=config.av.downmix_ac3&value=true"

To check if the value was added or changed:

init 4        # stop the Enigma, to save the "settings" file
cat /etc/enigma2/settings | grep downmix

A note:

 

The default value is not stored in the file /etc/enigma2/settings because it is a default value.

This means that there is no need to keep this configuration item in the "settings" file.

So if you save the value as "true", which is the default value for "downmix_ac3", then this item will completely disappear from the "settings" file.
 

You're a king mate, it works!

For anybody willing to execute or script this, note that for activating the True value, that is, downmix enabled, the "true" value is case sensitive:

 

WORKS:

curl --noproxy '*' --data value="true" "http://boxIP/api/saveconfig?key=config.av.downmix_ac3"

doesn't work:

curl --noproxy '*' --data value="True" "http://boxIP/api/saveconfig?key=config.av.downmix_ac3"

However, for the "False" value it is not case sensitive it works either with "False" or "false"

 

If anyone wonders why I wanted to script this, the transcoding on Hisilicon boxes like octagon sf8008 or gigablue trio 4k only works with downmix enabled. If downmix is disabled, only the untouched stream is working.

 

With scripts I can enable/disable downmix without need to enter and navigate webinterface and change audio settings remotely which is a pain.

 

cheers
 

 



Re: Modifying enigma2\settings from shell #14 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 24 March 2020 - 10:39

Of course, because Linux (file-system, shell variables, ...) and even the Python language in which Enigma is programmed are CASE SENSITIVE.

;)

 

The value "true" is ignored because it is the default. If you use "true" or "True" it does not matter, because it is the default value. In the first case, Enigma captures it and in the second case it ignores it (the default value is always used - ie true). In the case of false, however, CASE SENSITIVE already matters. You must specify "false". While the value "false" is enough to delete from the configuration (if you do not delete it, then it will be deleted by Enigma after saving the config, because Enigma does not store defaulnt values as I wrote).


Edited by s3n0, 24 March 2020 - 10:44.


Re: Modifying enigma2\settings from shell #15 digib

  • Member
  • 14 posts

0
Neutral

Posted 24 March 2020 - 12:14

in fact it's the opposite, "false" is not case sensistive, "true" does



Re: Modifying enigma2\settings from shell #16 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 24 March 2020 - 13:34

Nope.

 

If you use the string value "True" or the string value "False", the Enigma may not recognize it (reading the value will result in an error) and thus ignore it. This means that if Enigma fails to evaluate the correct value because CASE SENSITIVE is not treated in the code, the default value for the "downminx_ac3" configuration item will still be valid - this will change as if no value was written to the "settings" file at all.

 

In Python code, the Boolean value is referred to as True and False with a capital letter. Therefore, it would be illogical to use a retained string value in the "settings" file also with an uppercase letter. There is a risk of reading this value. It is logical to store a string with a lowercase initial. Only the correctness of "False" - "false" is decisive.

 

The Python OpenPLi code stores these variables as a string with a lowercase letter:
https://github.com/O.../config.py#L391

 

Especially, check please the following function def fromstring(self, val) - assigned for reading and recognizing a variable (if the recognized string value is "true", returns True from the function, but if there is anything else then the logical value False):
https://github.com/O.../config.py#L423

 

;)


Edited by s3n0, 24 March 2020 - 13:44.


Re: Modifying enigma2\settings from shell #17 digib

  • Member
  • 14 posts

0
Neutral

Posted 24 March 2020 - 14:00

Don't missunderstood me, I am eternally grateful to you, but I just tested empirically and by sending the "True" value the API answers but the downmix setting remains the same. Whilst if I send the value "true" it is updated (I check in the OSD audio menu that indeed the setting has been changed, the home audio receiver changes audio mode from AC3 to PCM)

 

With the opposite action, no matter if I send the value "False" or "false", the downmix is changed to disabled in the OSD menu. Home receiver switchs back to DOLBY mode.

 

For me is not a problem, just a clarification in case anybody finds case sensitive trouble.

 

Note that I'm sending the commands from a raspberry shell, from where I created a very basic WWW php frontend to operate home relays, enigma2 wake up, standby, and other common commands to ease remote tweaks from smartphone. I don't expect it would change anything from talking from the own box shell, but who knows!

 

Again, eternally thanks!


Edited by digib, 24 March 2020 - 14:04.


Re: Modifying enigma2\settings from shell #18 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 24 March 2020 - 14:42

Well, all right. :) You're welcome. :) I know what you mean.

Regarding the API response, this response means "the operation was successful" and not the content of the currently set value. To find the current value, use a simple shell ... for example:

grep 'config.av.downmix_ac3' /etc/enigma2/settings | cut -d '=' -f 2

Edited by s3n0, 24 March 2020 - 14:43.


Re: Modifying enigma2\settings from shell #19 digib

  • Member
  • 14 posts

0
Neutral

Posted 24 March 2020 - 17:53

Script to activate downmix for AC3 and DTS and echo+log the result:

#!/bin/bash
#change 127.0.0.1 for the box IP if this script is executed remotely from other linux system
curl -o /tmp/downmix_result.txt --noproxy '*' --data value="true" "http://127.0.0.1/api/saveconfig?key=config.av.downmix_ac3"
echo AC3 downmix is enabled
curl -o /tmp/downmix_result.txt --noproxy '*' --data value="true" "http://127.0.0.1/api/saveconfig?key=config.av.downmix_dts"
echo DTS downmix is enabled
exit 0

Script to disable downmix for AC3 and DTS and echo+log the result:

#!/bin/bash
#change 127.0.0.1 for the box IP if this script is executed remotely from other linux system
curl -o /tmp/downmix_result.txt --noproxy '*' --data value="false" "http://127.0.0.1/api/saveconfig?key=config.av.downmix_ac3"
echo AC3 downmix is disabled
curl -o /tmp/downmix_result.txt --noproxy '*' --data value="false" "http://127.0.0.1/api/saveconfig?key=config.av.downmix_dts"
echo DTS downmix is disabled
exit 0

and now laugh about me, I have been more than an hour to develop this one, I'm very basic skilled in programming, but it works, I'm so happy!!! thank you again @s3n0, you're my hero

the nice thing of this check is that it doesn't need to stop enigma to read the updated settings file, it queries the actual status live

#!/bin/sh
export LANG=es_ES.UTF-8
logdir="/tmp"
SUBJECT="Checks if AC3 downmix is enabled or disabled by quering enigma2 settings with API"
fecha=`date +%Y%m%d_%H%M`
search="config.av.downmix_ac3"

cat /dev/null >$logdir/downmix.status.txt
cat /dev/null >$logdir/downmix.review.txt
cat /dev/null >$logdir/downmix.status.read.txt

curl -o /tmp/downmix.status.txt "http://127.0.0.1/web/settings" #change 127.0.0.1 for the box IP if this script is executed remotely from other linux system

cat $logdir/downmix.status.txt|egrep "$search"  > $logdir/downmix.status.read.txt
cat $logdir/downmix.status.txt|grep -A 1 "$search"  > $logdir/downmix.status.read.txt

if cat $logdir/downmix.status.read.txt |
  grep -q 'False'
then
    echo "AC3 downmix is disabled"
    echo "AC3 downmix is disabled" >>$logdir/downmix.review.txt
else
    echo "AC3 downmix is enabled"
    echo "AC3 downmix is enabled" >>$logdir/downmix.review.txt
fi
exit 0

change 127.0.0.1 for the IP of the box if it is executed remotely from other linux system.

 

I integrated the logged results to a php very simple page where I check status and change them by clicking simple buttons

 

Cheers
 


 


Edited by digib, 24 March 2020 - 17:54.


Re: Modifying enigma2\settings from shell #20 s3n0

  • Senior Member
  • 673 posts

+62
Good

Posted 24 March 2020 - 19:57

Hi. You don't need to use tmp-files. You can also directly save the stdout to a variable. If you want to use curl, he saves the output by default to stdout (on display). But wget defaults to saving files from the web to file, so in the case of wget you have to specify the output to stdout with the argument:

wget -qO - URL
# short syntax:
wget -qO- URL

(-q argument means "quite" ... for more info: wget --help)

 

Some examples:

result=$(wget -q -O - http://127.0.0.1/web/settings 2>&1)

... or :

result=`wget -q -O - http://127.0.0.1/web/settings 2>&1`

...test the condition (test the variable content):

if echo "$result" | grep -q "$search"; then echo "the pattern $search was found"; else echo "the pattern $search was not found"; fi

...test thorough the error code (the last return code):

echo "$result" | grep -q "$search" && echo "the pattern $search was found" || echo "the pattern $search was not found"

(the -q argument for grep means that you get a response of 0 if the expression was found or 1 if it was not found, which is good for testing the existence of a match ... for more info please use: grep --help)


Edited by s3n0, 24 March 2020 - 20:02.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users