summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 265b440f9b0169e301ea34e5959329915aeb2dfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Maintainer: emersion <contact@emersion.fr>

pkgname=openvpn-protonvpn
pkgver=20200207
pkgrel=1
pkgdesc="OpenVPN configuration files and helper for protonvpn.com"
arch=(any)
url="https://protonvpn.com/"
license=('MIT')
depends=('openvpn')
optdepends=()
makedepends=('unzip' 'coreutils')
provides=('protonvpn')
source=("${pkgname}-${pkgver}.zip::https://api.protonmail.ch/vpn/config?Category=Server&Platform=Linux&Protocol=udp&Tier=2")
noextract=(zip)
sha256sums=('SKIP') # ZIP is auto-generated, cannot use a checksum

prepare() {
    test -d conf && rm -rf conf
    mkdir conf
    unzip -q "${pkgname}-${pkgver}.zip" -d conf
}

package() {
    # Generate TCP config files
    for f in $(find conf -type f -name '*udp1194.ovpn'); do
        basename=$(echo $(basename $f) | sed -e s/udp1194/tcp443/)
        sed -e 's/proto udp/proto tcp/' -E -e 's/remote ([^ ]+) 1194/remote \1 443/' $f > conf/$basename
    done
    for f in $(find conf -type f -name '*.ovpn'); do
        id=$(echo $(basename $f) | cut -d '.' -f 1,4)
        install -D -m 644 $f $pkgdir/etc/openvpn/client/protonvpn.${id}.conf
    done
    chmod 755 $pkgdir/etc/openvpn/client
}