summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-08-26 18:16:40 +0200
committerDaniil Baturin <daniil@baturin.org>2018-08-26 18:16:40 +0200
commit5545782bd2ffb4f715699c4a2a343462e916faca (patch)
tree245e5090ff713b0ddddd5e19364720e01dac734c /src/op_mode
parentffc8d1f4666874bd2641be54fc16515daf065985 (diff)
parent23022977a6bf94e6be7d37de04c97ab0b5d1ea35 (diff)
downloadvyos-1x-5545782bd2ffb4f715699c4a2a343462e916faca.tar.gz
vyos-1x-5545782bd2ffb4f715699c4a2a343462e916faca.zip
Merge branch 'current' of https://github.com/vyos/vyos-1x into current
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/dynamic_dns.py (renamed from src/op_mode/dynamic_dns_status.py)29
-rwxr-xr-xsrc/op_mode/powerctrl.py4
2 files changed, 29 insertions, 4 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()
diff --git a/src/op_mode/powerctrl.py b/src/op_mode/powerctrl.py
index f73d6c005..8a66b3afd 100755
--- a/src/op_mode/powerctrl.py
+++ b/src/op_mode/powerctrl.py
@@ -126,9 +126,9 @@ def main():
args = parser.parse_args()
try:
- if args.reboot:
+ if args.reboot is not None:
execute_shutdown(args.reboot, reboot=True, ask=args.yes)
- if args.poweroff:
+ if args.poweroff is not None:
execute_shutdown(args.poweroff, reboot=False,ask=args.yes)
if args.cancel:
cancel_shutdown()