Skip to content

Commit 92e5bc2

Browse files
committed
Implement a systemd-timer that updates the server list once every week (closes #26)
1 parent 097dc85 commit 92e5bc2

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

PKGBUILD

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maintainer: Philipp Schmitt (philipp<at>schmitt<dot>co)
22

33
pkgname=pia-tools-orig
4-
pkgver=0.9.7.3
4+
pkgver=0.9.8.0
55
pkgrel=1
66
pkgdesc='OpenVPN hook for privateinternetaccess.com'
77
arch=('any')
@@ -14,23 +14,31 @@ source=('https://raw.github.com/pschmitt/pia-tools/master/pia-tools'
1414
'https://raw.github.com/pschmitt/pia-tools/master/pia_common'
1515
'https://raw.github.com/pschmitt/pia-tools/master/pia-up'
1616
'https://raw.github.com/pschmitt/pia-tools/master/pia-down'
17-
'https://raw.github.com/pschmitt/pia-tools/master/pia-tools.install')
18-
sha256sums=('90aad9e167b6dbc3ba6e728ea69973cff48a8af91754a8df1c0d2a0a573a5aad'
17+
'https://raw.github.com/pschmitt/pia-tools/master/pia-tools.install'
18+
'https://raw.github.com/pschmitt/pia-tools/master/pia-tools-update.service'
19+
'https://raw.github.com/pschmitt/pia-tools/master/pia-tools-update.timer')
20+
sha256sums=('25945e042899843ed5d39807bc07e7433321d12918c5e299d0308b13c2397e3b'
1921
'22a34cb38e02ee1ed32e5697bc507df074629cbf5f1f7290a72e2c947cf611eb'
2022
'118d961db36fb243e059543215a818d1546ec94e8d52b24c75b7de6fe64ba749'
2123
'b571a8edbd9cb2a9ad63fadf360f64d4f80e291295f6c851b3a716c291ba3f8d'
2224
'063ee23a9c98e728168affb8056cda201fb02ede2bd29dfe2b768ce834b35e7c'
2325
'12299e53b5024084c73e604132db3a10b6e91763d90d484cabdd1985a17cf733'
24-
'a7e82a1589406477898adee768d17c0270c8bcf341ae72be823095331c4e99c5')
26+
'a7e82a1589406477898adee768d17c0270c8bcf341ae72be823095331c4e99c5'
27+
'9c85077075dc9192109abb9736f5905721574ce3b902f6d709afc6e262c8ed29'
28+
'dee96c9e2a3f8d447d1d8aafbb1fc10fcd124e89239f1078311d5ce2c963359f')
2529
install="pia-tools.install"
2630

2731
package() {
2832
cd "${srcdir}"
2933
install -Dm755 pia-tools "${pkgdir}/usr/bin/pia-tools"
3034
install -Dm644 pia-tools.groff "${pkgdir}/usr/share/man/man1/pia-tools.1"
3135
install -Dm644 pia@.service "${pkgdir}/usr/lib/systemd/system/pia@.service"
36+
install -Dm644 pia-tools-update.service "${pkgdir}/usr/lib/systemd/system/pia-tools-update.service"
37+
install -Dm644 pia-tools-update.timer "${pkgdir}/usr/lib/systemd/system/pia-tools-update.timer"
3238
install -Dm644 pia_common "${pkgdir}/etc/openvpn/pia/pia_common"
3339
install -Dm755 pia-up "${pkgdir}/etc/openvpn/pia/pia-up"
3440
install -Dm755 pia-up "${pkgdir}/etc/openvpn/pia/pia-down"
41+
# Activate the ovpn update service
42+
install -d -m755 "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants"
43+
ln -s ../pia-tools-update.timer "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants/pia-tools-update.timer"
3544
}
36-

pia-tools

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# Description: Script to automate privateinternetacces port forwarding and
33
# starting/stopping transmission when connected/disconnected and other stuff
4-
# Version: 0.9.7.3
4+
# Version: 0.9.8.0
55
# Author: Philipp Schmitt (philipp<at>schmitt.co)
66
# Documentation: cf. pia-tools.groff
77
# Dependencies: curl openvpn sudo systemd transmission-daemon unzip
@@ -241,14 +241,14 @@ setup() {
241241

242242
update_config() {
243243
echo -n 'Updating configuration... '
244-
local ovpn ovpn_spaceless
244+
local ovpn ovpn_spaceless overwrite=$([[ -n "$FORCE" ]] && echo '-o')
245245

246246
# Clean up
247-
rm -f $PIA_CONFIG_DIR/ca.crt $PIA_CONFIG_DIR/*.ovpn
247+
rm -f "$PIA_CONFIG_DIR/ca.crt" "$PIA_CONFIG_DIR"/*.ovpn
248248

249249
# Fetch server config files
250-
curl -sL -o $PIA_CONFIG_DIR/openvpn.zip $PIA_CONFIG_URL
251-
unzip -d $PIA_CONFIG_DIR -q $PIA_CONFIG_DIR/openvpn.zip
250+
curl -sL -o "$PIA_CONFIG_DIR/openvpn.zip" "$PIA_CONFIG_URL"
251+
unzip "$overwrite" -d "$PIA_CONFIG_DIR" -q "$PIA_CONFIG_DIR/openvpn.zip"
252252

253253
# Replace space by underscore in filenames
254254
local ifs_bak=$IFS
@@ -260,7 +260,7 @@ update_config() {
260260
mv "$ovpn" "$ovpn_spaceless"
261261
fi
262262
# Append up/down scripts to every ovpn file
263-
cat "$PIA_COMMON_CONFIG" >> "$ovpn_spaceless"
263+
cat "$PIA_COMMON_CONFIG" >> "$ovpn_spaceless"
264264
done
265265
IFS=$ifs_bak
266266

pia-tools-update.service

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[Unit]
2+
Description=Update the pia-tools ovpn files
3+
4+
[Service]
5+
Type=oneshot
6+
ExecStart=/usr/bin/pia-tools -uf

pia-tools-update.timer

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[Unit]
2+
Description=Weekly Update of the pia-tools config files
3+
4+
[Timer]
5+
OnCalendar=weekly
6+
Persistent=true
7+

0 commit comments

Comments
 (0)