summaryrefslogtreecommitdiff
path: root/cronjob.py
diff options
context:
space:
mode:
Diffstat (limited to 'cronjob.py')
-rwxr-xr-xcronjob.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/cronjob.py b/cronjob.py
index 81b5497..14061b9 100755
--- a/cronjob.py
+++ b/cronjob.py
@@ -6,7 +6,7 @@ from lib_autopeer import *
import os
-curs = DB.execute('SELECT name, asn FROM peers')
+curs = DB.execute('SELECT name, asn FROM peers WHERE deleted=0')
while row := curs.fetchone():
name, asn = row
print(f'Processing {asn}-{name}...')
@@ -20,4 +20,14 @@ while row := curs.fetchone():
wgcfg.close()
os.system(f'systemctl enable --now wg-quick@wg{asn%10000:04}{name}')
+curs = DB.execute('SELECT name, asn FROM peers WHERE deleted=1')
+while row := curs.fetchone():
+ name, asn = row
+ print(f'Deleting {asn}-{name}...')
+ try: os.remove(f'/etc/bird/peers/as{asn}{name}.conf')
+ except FileNotFoundError: pass
+ try: os.remove(f'/etc/wireguard/wg{asn%10000:04}{name}.conf')
+ except FileNotFoundError: pass
+ os.system(f'systemctl disable --now wg-quick@wg{asn%10000:04}{name}')
+
os.system('birdc configure')