Using cmd_arguments

This may sound silly. I am trying to get ddclient with OpenDNS to work. I can get it to work on my laptop and yet the cmd_arguments when trying to run it as a rockon are giving me frustration. This is the bit for the cmd_aguments:

"cmd_arguments": [
                    [
                        "bash",
                        " -c \"echo -e \\\"protocol=dyndns2\\nssl=yes\\ndaemon=300\\nsyslog=yes\\npid=/var/run/ddclient/ddclient.pid\\nuse=web, web=ipinfo.io/ip\\nserver=updates.opendns.com\\nlogin='\\${ODNSUSR}'\\npassword='\\${ODNSPSW}'\\n\\${ODNSNETLABEL}\\\" > /config/ddclient.conf\""
                    ]
                ]

excusing the potential escaping issue this is what is output in the container in rockstor:

bash:  -c "echo -e \"protocol=dyndns2\nssl=yes\ndaemon=300\nsyslog=yes\npid=/var/run/ddclient/ddclient.pid\nuse=web, web=ipinfo.io/ip\nserver=updates.opendns.com\nlogin='\${ODNSUSR}'\npassword='\${ODNSPSW}'\n\${ODNSNETLABEL}\" > /config/ddclient.conf": No such file or directory
[cmd] bash exited 127

I would love to be able to figure this out. thanks for any help.

1 Like

Hi @mercbot7,

Thanks for bringing this to my attention; it thus seems we do have room for improvement here. I’m unfortunately very short on time at the moment so I won’t be able to look at it in details, but in the meantime, would you be able to confirm what the docker run command should look like in the end? You mention you do have it working on your laptop so I just want to make sure we have a clear goal to reach here :slight_smile: in terms of final syntax.

@Flox Thanks for looking at this, it is not a huge rush so take your time. the situation is that the ddclient container runs and THEN you create your config file in the storage mapped to /config. This is frustrating to me as in my opinion I should be able to set my config in the run, meh! what I want to do is provide the config file through the run (or potentially --entrypoint which I just thought of while doing Kubernetes training).
The config should look something like this for OpenDNS

protocol=dyndns2
ssl=yes
daemon=600
syslog=yes
pid=/var/run/ddclient/ddclient.pid
use=web, web=ipinfo.io/ip
server=updates.opendns.com
login='<your opendns username-usually your email address>'
password='<your opendns password>'
<network label name>

The docker run command looks like this:

docker run \
--env ODNSUSR='bogus@email.com' \
--env ODNSPSW='opendnspassword' \
--env ODNSNETLABEL="OpenDNSNetworkLabel" \
-v ../config -it linuxserver/ddclient \
/bin/bash -c "echo -e \
\"protocol=dyndns2\n\
ssl=yes\n\
daemon=300\n\
syslog=yes\n\
pid=/var/run/ddclient/ddclient.pid\n\
use=web, web=ipinfo.io/ip\n\
server=updates.opendns.com\n\
login='\${ODNSUSR}'\n\
password='\${ODNSPSW}'\n\
\${ODNSNETLABEL}\"\
> /config/ddclient.conf"

Sorry for the long post but sometimes some background helps.
Dave

3 Likes

On the contrary, thanks a lot for that as I immediately see what you’re trying to achieve :slight_smile: .
I’ll try to have a look at it when I get the chance, but I wouldn’t be surprised if more knowledgeable people will chime in before that.

1 Like

@mercbot7, could be that using double quotes around the variables instead will make it work

echo -e \\\"protocol=dyndns2\\nssl=yes\\ndaemon=300\\nsyslog=yes\\npid=/var/run/ddclient/ddclient.pid\\nuse=web, web=ipinfo.io/ip\\nserver=updates.opendns.com\\nlogin=\\"${ODNSUSR}"\\npassword=\\"${ODNSPSW}"\\n\\"${ODNSNETLABEL}"\\\" > /config/ddclient.conf\"

`

2 Likes

@Hooverdan That very well could be. From what I see, and it could be super wrong, it doesn’t even seem to be evaluating that part of the command, it never gets there. Also, I wanted to encapsulate the Username and Password in Single Quotes after expansion for special characters based on what I have read about some errors with encoding for web? I will have to explore the double quotes to see if it makes a difference.

Thanks!!

3 Likes

I know, it’s not the end all/be all but I’ve started using https://www.shellcheck.net/ for a low-tech sanity check of bash statements when they become more complicated.

2 Likes