summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-29 20:06:01 +0200
committerChristian Poessinger <christian@poessinger.com>2020-05-29 20:13:18 +0200
commitf671b4ed2ca7b2f73223bf87d4b77a2634d574db (patch)
tree1dfc76be5328a1379146250fd9075fe4eb22d670 /src/op_mode
parentb5b6e657ca7f59e21bdc52b975b0f454b9da523f (diff)
downloadvyos-1x-f671b4ed2ca7b2f73223bf87d4b77a2634d574db.tar.gz
vyos-1x-f671b4ed2ca7b2f73223bf87d4b77a2634d574db.zip
dynamic-dns: T2528: bugfix FileNotFoundError in "update dns dynamic"
Stopping and starting ddclient should only happen if the DNS dynamic service is actually configured. In addition it should always be checked if the file we try to delete really exists. (cherry picked from commit 0525e443fa68cda451c9f4c838e1f55cec913d2a)
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/dynamic_dns.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/op_mode/dynamic_dns.py b/src/op_mode/dynamic_dns.py
index 0d457e247..14bcf65c1 100755
--- a/src/op_mode/dynamic_dns.py
+++ b/src/op_mode/dynamic_dns.py
@@ -35,12 +35,6 @@ update-status: {{ entry.status }}
"""
def show_status():
- # Do nothing if service is not configured
- c = Config()
- if not c.exists_effective('service dns dynamic'):
- print("Dynamic DNS not configured")
- sys.exit(0)
-
data = {
'hosts': []
}
@@ -85,22 +79,24 @@ def show_status():
def update_ddns():
os.system('systemctl stop ddclient')
- os.remove(cache_file)
+ if os.path.exists(cache_file):
+ os.remove(cache_file)
os.system('systemctl start ddclient')
-
-def main():
+if __name__ == '__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()
+ # Do nothing if service is not configured
+ c = Config()
+ if not c.exists_effective('service dns dynamic'):
+ print("Dynamic DNS not configured")
+ sys.exit(1)
+
if args.status:
show_status()
elif args.update:
update_ddns()
-
-
-if __name__ == '__main__':
- main()