summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2018-08-18 08:25:31 +0200
committerGitHub <noreply@github.com>2018-08-18 08:25:31 +0200
commitbd70e8b030121a95eb9f9abcbe137917329020b8 (patch)
tree24c5a9551380f7b9b377a3d02953f2f2175bc099 /src/op_mode
parent9a204594dd0ada8d117d37c9ad5f0d4a59ff43fd (diff)
parent7a27726e0e1e1de47f8abfb64e9c28eadb34c55b (diff)
downloadvyos-1x-bd70e8b030121a95eb9f9abcbe137917329020b8.tar.gz
vyos-1x-bd70e8b030121a95eb9f9abcbe137917329020b8.zip
Merge pull request #31 from alkersan/ddns_update
T784: Added update dns dynamic operation
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/dynamic_dns.py (renamed from src/op_mode/dynamic_dns_status.py)29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/op_mode/dynamic_dns_status.py b/src/op_mode/dynamic_dns.py
index bbff01f49..7ac3dfe9f 100755
--- a/src/op_mode/dynamic_dns_status.py
+++ b/src/op_mode/dynamic_dns.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
-
+import os
+import argparse
import jinja2
import sys
import time
@@ -18,7 +19,8 @@ update-status: {{ entry.status }}
{% endfor -%}
"""
-if __name__ == '__main__':
+
+def show_status():
# Do nothing if service is not configured
c = Config()
if not c.exists_effective('service dns dynamic'):
@@ -65,3 +67,26 @@ if __name__ == '__main__':
tmpl = jinja2.Template(OUT_TMPL_SRC)
print(tmpl.render(data))
+
+
+def update_ddns():
+ os.system('systemctl stop ddclient')
+ os.remove(cache_file)
+ os.system('systemctl start ddclient')
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ group = parser.add_mutually_exclusive_group()
+ group.add_argument("--status", help="Show DDNS status", action="store_true")
+ group.add_argument("--update", help="Update DDNS on a given interface", action="store_true")
+ args = parser.parse_args()
+
+ if args.status:
+ show_status()
+ elif args.update:
+ update_ddns()
+
+
+if __name__ == '__main__':
+ main()