Skip to content

Instantly share code, notes, and snippets.

@darrenpmeyer
Last active June 10, 2020 16:22
Show Gist options
  • Save darrenpmeyer/b0b964e02f815be75698 to your computer and use it in GitHub Desktop.
Save darrenpmeyer/b0b964e02f815be75698 to your computer and use it in GitHub Desktop.
Autobuild script for OpenConnect 7 (Ubuntu 14/15/16 trusty/vivid/xenial)
#!/usr/bin/env bash
## NOTE! OpenConnect is now on Version 8, and this is only for historical use
## See https://gist.github.com/darrenpmeyer/1a56d0d4817352998fe9d7cfe5a79684 for new script
oc_ver="7.08"
echo "Autobuild OpenConnect $oc_ver"
echo " "
echo "This script uses apt-get and make install via sudo rights"
echo "To simplify this, we're going to use sudo -v to pre-authenticate you"
sudo -k
sudo -v
## Preflight
sudo apt-get install curl vpnc-scripts build-essential gettext pkg-config libssl-dev libxml2-dev liblz4-dev libstoken1 stoken
curl -O ftp://ftp.infradead.org/pub/openconnect/openconnect-${oc_ver}.tar.gz
curl -O ftp://ftp.infradead.org/pub/openconnect/openconnect-${oc_ver}.tar.gz.asc
gpg --keyserver pgp.mit.edu --recv-key 67e2f359
if gpg --verify openconnect-${oc_ver}.tar.gz.asc 2>/dev/null
then
echo -e "\n++++ GPG Signature Verified OK! ++++\n\n"
else
gpg --verify openconnect-${oc_ver}.tar.gz.asc # to show output
echo -e "\n!!!! GPG Signature FAILED. Not proceeding with autobuild !!!!\n\n"
exit 127
fi
tar xzf openconnect-${oc_ver}.tar.gz
cd openconnect-${oc_ver}
if ! (./configure --without-gnutls --with-vpnc-script=/usr/share/vpnc-scripts/vpnc-script)
then
echo "!! Configuration was not successful, not proceeding with autobuild"
exit 1
fi
if ! (make)
then
echo "!! build was not successful, not proceeding with install"
exit 2
fi
if ! (sudo make install)
then
echo "!! installation failed"
exit 3
fi
if ! (sudo ldconfig /usr/local/lib)
then
echo "?? error running ldconfig; this MAY be a problem"
echo " but we will not exit with an error for it"
fi
exit 0
@christianlacerda
Copy link

Great script! Please fix line 28. Should ${oc_ver}.

Thank you!

@darrenpmeyer
Copy link
Author

Fixed, thanks.

@jpeletier
Copy link

Hi, I needed to previously install these additional packages for this to compile on Ubuntu Server 14.04:

apt-get gettext pkg-config

After this, it worked perfectly. Thanks!!

@jmarcedwards
Copy link

The ftp.infradead.org server appears to be dead.

@darrenpmeyer
Copy link
Author

@jmarcedwards: the Infradead FTP server does occasionally go down; it's not under my control and is back up as I write this.

@elenadbe
Copy link

I receive a time out from pgp.mit.edu. Any idea? Thanks in advance

@elenadbe
Copy link

sorry proxy is missing (i just prefix http_proxy=http://...

@ivantsyba
Copy link

Thanks, compiled openconnect works fine.
How to make this version of openconnect work with Network Manager gui? It still uses old openconnect which can't connect with TLS errors

@darrenpmeyer
Copy link
Author

Integration with NetworkManager is handled through the network-manager-openconnect package on Ubuntu; that package contains a wrapper script that NetworkManager needs to interface with openconnect. IIRC, it will install the openconnect package also; you will have to compile a newer version of openconnect and replace the binaries/libraries. I have not found need to do this, so I can't advise you; probably you will need to change the configure command direct the compiled binary to where the networkmanager wrapper script expects it.

@ivantsyba
Copy link

@darrenpmeyer Thank you
I haven't find any other "openconnect" binary in the system to replace it. I'll use compiled 7.08 from command line and don't bother with Network Manager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment