Skip to content

Instantly share code, notes, and snippets.

@hdoverobinson
Last active August 28, 2019 22:33
Show Gist options
  • Save hdoverobinson/4faf72b492767e790a1281869572eb6a to your computer and use it in GitHub Desktop.
Save hdoverobinson/4faf72b492767e790a1281869572eb6a to your computer and use it in GitHub Desktop.
Compiles OpenVPN with mbedTLS on Debian/Ubuntu for use with safer-things-server: https://github.com/hdoverobinson/safer-things-server
#!/bin/bash
MBEDVERSION="2.16.2"
OVPNVERSION="2.4.7"
COREPACKAGES="openvpn"
BUILDPACKAGES="cmake net-tools python wget"
MBEDURL="https://tls.mbed.org/download/mbedtls-${MBEDVERSION}-apache.tgz"
OVPNURL="https://swupdate.openvpn.org/community/releases/openvpn-${OVPNVERSION}.tar.gz"
###SET UP APT###
sed -i 's/.*deb-src/deb-src/g' /etc/apt/sources.list &&
apt-get update &&
###UNHOLD CORE PACKAGES###
apt-mark unhold $COREPACKAGES &&
###INSTALL SAFER-THINGS PACKAGES###
apt-get -y install --no-install-recommends $COREPACKAGES $BUILDPACKAGES &&
apt-get -y build-dep $COREPACKAGES &&
###COMPILE AND INSTALL MBEDTLS###
rm -rf /usr/src/mbedtls/ &&
mkdir -p /usr/src/mbedtls/ &&
cd /usr/src/mbedtls/ &&
wget $MBEDURL -O mbedtls-${MBEDVERSION}-apache.tgz &&
tar -xzvf mbedtls-${MBEDVERSION}-apache.tgz &&
cd mbedtls-${MBEDVERSION}/ &&
cmake . &&
make -j4 &&
make test &&
make install &&
###COMPILE AND INSTALL OPENVPN###
/etc/init.d/openvpn stop &&
rm -rf /usr/src/openvpn/ &&
mkdir -p /usr/src/openvpn/ &&
cd /usr/src/openvpn/ &&
wget $OVPNURL -O openvpn-${OVPNVERSION}.tar.gz &&
tar -xzvf openvpn-${OVPNVERSION}.tar.gz &&
cd openvpn-${OVPNVERSION}/ &&
./configure --prefix=/usr --with-crypto-library=mbedtls &&
make -j4 &&
make install &&
find /etc/openvpn -mindepth 1 -type d -delete &&
###HOLD CORE PACKAGES###
apt-mark hold $COREPACKAGES &&
###CLEAN UP PACKAGES###
apt-get update &&
apt-get -y autoremove &&
apt-get -y clean &&
apt-get -y autoclean &&
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment