aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorfelinae982020-12-11 21:44:37 +0800
committerfelinae982020-12-11 21:44:37 +0800
commit8a70a4c9c971a3e5c92ece961541d98265c9e94f (patch)
tree642879b8168f6d65ebcbc514e5a4883ace0db4ec
parent6139c27687bab39ac07684741cafdf7b68e939a6 (diff)
downloadaur-8a70a4c9c971a3e5c92ece961541d98265c9e94f.tar.gz
add period update
-rw-r--r--.SRCINFO10
-rw-r--r--PKGBUILD14
-rwxr-xr-xclashup11
-rw-r--r--clashup.service9
-rw-r--r--clashup.timer10
5 files changed, 43 insertions, 11 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 212acf7a1c13..1fd698a6004e 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = clashup
pkgdesc = auto update clash's config file
- pkgver = 0.2.6
- pkgrel = 1
+ pkgver = 0.3.0
+ pkgrel = 2
url = https://github.com/felinae98/clashup
arch = any
license = GPL
@@ -11,8 +11,12 @@ pkgbase = clashup
depends = python-daemon
source = clashup
source = clashup.conf
- md5sums = 5003219768c527792b83b9412097c4c5
+ source = clashup.service
+ source = clashup.timer
+ md5sums = d2d6b7c638bd59e6ac0cfd1ece1301e1
md5sums = 177338346005e11d33e27edc1f8ab780
+ md5sums = f805be578902fb8c6606aef828111af8
+ md5sums = 58604e2d881d0260623659ce06158e14
pkgname = clashup
diff --git a/PKGBUILD b/PKGBUILD
index d6f2a5290a8e..dcb6af2a9de4 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Tang Yuming <felinae225@qq.com>
pkgname=clashup
-pkgver=0.2.6
-pkgrel=1
+pkgver=0.3.0
+pkgrel=2
pkgdesc="auto update clash's config file"
license=('GPL')
arch=('any')
@@ -10,10 +10,14 @@ depends=(python
clash
python-requests
python-daemon)
-source=(clashup clashup.conf)
+source=(clashup clashup.conf clashup.service clashup.timer)
package() {
install -Dm755 clashup ${pkgdir}/usr/bin/clashup
install -Dm644 clashup.conf ${pkgdir}/etc/systemd/user/clash.service.d/clashup.conf
+ install -Dm644 clashup.service ${pkgdir}/usr/lib/systemd/system/clashup.service
+ install -Dm644 clashup.timer ${pkgdir}/usr/lib/systemd/system/clashup.timer
}
-md5sums=('5003219768c527792b83b9412097c4c5'
- '177338346005e11d33e27edc1f8ab780')
+md5sums=('d2d6b7c638bd59e6ac0cfd1ece1301e1'
+ '177338346005e11d33e27edc1f8ab780'
+ 'f805be578902fb8c6606aef828111af8'
+ '58604e2d881d0260623659ce06158e14')
diff --git a/clashup b/clashup
index 211d3ec3032c..32b34dfa0a2d 100755
--- a/clashup
+++ b/clashup
@@ -27,7 +27,8 @@ class ClashUp:
"is_subscribe_banned": false,
"custom_rules": [],
"mmdb_file_url": "http://www.ideame.top/mmdb/Country.mmdb",
- "mmdb_version_url: "http://www.ideame.top/mmdb/version"
+ "mmdb_version_url: "http://www.ideame.top/mmdb/version",
+ "periodically_update": false
}
'''
def __init__(self):
@@ -139,9 +140,13 @@ class ClashUp:
parser = argparse.ArgumentParser()
parser.add_argument('--pre', action='store_true')
parser.add_argument('--post', action='store_true')
+ parser.add_argument('--update', action='store_true')
args = parser.parse_args()
self.load_conf()
- if args.pre:
+ if args.update:
+ self.update(False)
+ self.update_mmdb()
+ elif args.pre and not self.config.get('periodically_update', False):
if self.config['is_subscribe_banned']:
logging.info('Subscribe is banned, pass this run')
else:
@@ -149,7 +154,7 @@ class ClashUp:
if self.config.get('mmdb_version_url') and self.config.get('mmdb_file_url'):
with daemon.DaemonContext():
self.update_mmdb()
- elif args.post:
+ elif args.post and not self.config.get('periodically_update', False):
if self.config['is_subscribe_banned']:
if self.update_time_cache():
self.update(True)
diff --git a/clashup.service b/clashup.service
new file mode 100644
index 000000000000..69f6710ca859
--- /dev/null
+++ b/clashup.service
@@ -0,0 +1,9 @@
+[Unit]
+Wants=network-online.target
+After=network-online.target
+Description=Update clash config file
+
+[Service]
+ExecStart=/usr/bin/clashup --update
+ExecStopPost=/usr/bin/systemctl restart clash@root
+Type=oneshot
diff --git a/clashup.timer b/clashup.timer
new file mode 100644
index 000000000000..251512d4fd97
--- /dev/null
+++ b/clashup.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Update clash once a day
+Wants=network-online.target
+After=network-online.target
+
+[Timer]
+OnUnitActiveSec=1d
+
+[Install]
+WantedBy=timers.target