summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_ddns.py
blob: 9695f76006bc30fd7cbcb6d34bd84e74a8a37d5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
import logging, mv_common
import os, re

config_file = "mv_config"

def setup_ddns(systemconfig):
    if  mv_common.read_config(mv_common.module_config,"ddns")  == False  :
        logging.info("____Skipping of DDNS, config disabled____")
        return
    logging.info("____Start of setup_ddns____")

    if systemconfig["DDnsEnable"] == "1":
        logging.debug("    Enabling DDNS")
	mv_common.pacinstall("ddclient")
	mv_common.cp_and_log("/etc/ddclient/ddclient.conf.dynamic.dyndns.sample",
	  		     "/etc/ddclient/ddclient.conf")
	cmd = ''' sed -i -e "s/your-dynamic-dyndns-login/%s/g" /etc/ddclient/ddclient.conf''' %(systemconfig["DDnslogin"])
	mv_common.runcmd(cmd)
	cmd = ''' sed -i -e "s/your-dynamic-dyndns-password/%s/g" /etc/ddclient/ddclient.conf''' %(systemconfig["DDnspassword"])
	mv_common.runcmd(cmd)
	cmd = ''' sed -i -e "s/your-dynamic-dyndns-host/%s/g" /etc/ddclient/ddclient.conf''' %(systemconfig["DDnshostname"])
	mv_common.runcmd(cmd)
	mv_common.add_service("ddclient")
    else:
        logging.debug("    Disabling DDNS")
	mv_common.remove_service("ddclient")

    logging.info("__End of ddns\n")