Skip to content

Instantly share code, notes, and snippets.

@mikezackles
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikezackles/0fa3928625d4c6242db5 to your computer and use it in GitHub Desktop.
Save mikezackles/0fa3928625d4c6242db5 to your computer and use it in GitHub Desktop.
# Maintainer: Jesse Spangenberger <azulephoenix@gmail.com>
pkgname=private-internet-access-vpn
pkgver=0.4
pkgrel=1
pkgdesc="Installs VPN profiles for Private Internet Access Service"
arch=('any')
url="https://www.privateinternetaccess.com/"
license=('GPL')
depends=('openvpn')
source=("https://www.privateinternetaccess.com/openvpn/openvpn.zip"
"https://raw.githubusercontent.com/masterkorp/openvpn-update-resolv-conf/master/update-resolv-conf.sh"
"https://gist.githubusercontent.com/mikezackles/0fa3928625d4c6242db5/raw/ed1aa78c8bee96ee6a18635811cdcdb6a7dcf229/vpn.sh"
"https://gist.githubusercontent.com/mikezackles/0fa3928625d4c6242db5/raw/e918d284d0aef83b8ccf364457da573fce82a823/restart.conf")
sha256sums=('8182a659edfb120bd5f3eee20dba50da889ba28cb1aa76caa0b4d5199f338522'
'6d3bdc9531f16cc1ad199913a71554a0b50aea87e140b28d079c4ab4c0b8c51b'
'7c0866ccccfcfc754b88e280aa0894834b402820c1471cd59af9f43e215d6e2f'
'45096bdedc35ad855c72c29fbf64e2e7970c8de09653eb3b01a187f0d0613042')
noextract=("openvpn.zip")
#VPN_USER="youruser"
#VPN_PASS="yourpassword"
prepare() {
cd "${srcdir}"
mkdir "vpn-configs"
bsdtar -xf openvpn.zip -C "vpn-configs"
cd "vpn-configs"
# Switch .ovpn file extensions to .conf. This is what the openvpn systemd
# service expects
for file in *.ovpn
do
mv "$file" "${file/%.ovpn/.conf}"
done
# Swap spaces in filenames for underscores to be more command-line friendly
for file in *\ *.conf
do
mv "$file" "${file// /_}"
done
# Attempt to ensure that we use PIA DNS servers
for file in *.conf
do
echo "script-security 2" >> "$file"
echo "up /etc/openvpn/update-resolv-conf.sh" >> "$file"
echo "down /etc/openvpn/update-resolv-conf.sh" >> "$file"
done
# Set up automatic login if a username and password have been provided
if [[ -n "$VPN_USER" && -n "$VPN_PASS" ]]
then
for file in *.conf
do
echo "auth-user-pass /etc/openvpn/login.conf" >> "$file"
done
echo "$VPN_USER" > login.conf
echo "$VPN_PASS" >> login.conf
fi
}
package() {
cd "$srcdir"
install -dm 755 "${pkgdir}/etc/openvpn/"
install -dm 755 "${pkgdir}/usr/lib/system/systemd/system-sleep/"
install -dm 755 "${pkgdir}/usr/lib/system/systemd/openvpn@.service.d"
install -m 644 vpn-configs/*.* "${pkgdir}/etc/openvpn/"
install -m 755 update-resolv-conf.sh "${pkgdir}/etc/openvpn"
install -m 755 vpn.sh "${pkgdir}/usr/lib/system/systemd/system-sleep/"
install -m 644 restart.conf "${pkgdir}/usr/lib/system/systemd/openvpn@.service.d/restart.conf"
}
[Service]
Restart=always
#!/bin/sh
if [ "$1" == "pre" ]
then
killall openvpn
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment