openvpn-update-resolv-conf
openvpn-update-resolv-conf copied to clipboard
Command not recognized
resolvconf: Error: Command not recognized Usage: resolvconf (-d IFACE|-a IFACE|-u|--enable-updates|--disable-updates|--updates-are-enabled)
yet in the script I see $RESOLVCONF -x -a "${dev}.inet"
There is no -x flag above.
What's wrong?
Hello,
Can you give more information about our OS, and your RESOLVCONF?
I am seeing the same problem on Ubuntu 17.04, RESOLVCONF=/usr/sbin/resolvconf .
I have the same issue on Ubuntu 17.04. Removing -x flag remove the error.
Please set the 'verb' to 4 or above, and then run the openvpn in terminal/console and then post the log to us. Filter out your sensitive information before posting.
I've worked around this problem & am all set thanks
Removing the -x flag and the ".inet" PROG specifier from the device name fixes the script for me on Ubuntu 16.04.
I will need to fix this and check resolvconf versions.
Hello!
I'm getting the same error:
resolvconf: Error: Command not recognized
Usage: resolvconf (-d IFACE|-a IFACE|-u|--enable-updates|--disable-updates|--updates-are-enabled)
$ cat /etc/issue
Ubuntu 16.04.4 LTS
$ uname -a
Linux intrepid 4.13.0-38-generic #43~16.04.1-Ubuntu SMP Wed Mar 14 17:48:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
I can confirm that fix by sheldonh is working:
Removing the -x flag and the ".inet" PROG specifier from the device name fixes the script for me on Ubuntu 16.04.
Same fix by @sheldonh for Ubuntu 18.04
4.15.0-64-generic #73-Ubuntu SMP Thu Sep 12 13:16:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
I need to add some OS detection to this.
Would it be reliable to just check if the command output is Command not recognised and try the other command in that case?
The current command should work in systemd's resolvectl and openresolv, so it's just the resolvconf that ships with Ubuntu <18.04(?) that doesn't support those command line options.
This is the output of resolvconf --version for each command. Perhaps this output could be used for detecting which command to run if not the method above.
(sorry I cannot copy&paste text into Firefox atm)
openresolv on Arch Linux:

resolvectl on Arch Linux (symlinked to /usr/bin/resolvconf when being used):

resolvconf on Ubuntu 16.04:

The best way would be to verify that OS that the script is running on. Basically all the debian based images (Raspbian, Ubuntu, Debian) ships with a resolvconf that does not know this -x command.
The accepted answer on stackoverflow can give some insight: https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script
When testing this on a a Ubuntu 18.04 server, echo ${OS} returns: Ubuntu
On Raspbian, echo ${OS} returns Raspbian GNU/Linux
With this, you can specify certain commands depending on a certain distro. If you want to really go nuts, you can also check the version with ${VER}
Wouldn't the most surefire way be to detect the "version" of resolveconf being run, because the user may be using a different one as to what was originally shipped. For example on one of my Ubuntu 16.04 I'm running openresolv instead of the script originally shipped with the distro.
My solution for Ubuntu 16.04 was to apt install the openresolv package which upgrades the default resolvconf to a newer version that supports the -x option.
Edit: Which of course is mentioned in the README. :sweat_smile: