summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/LinHES-config/mv_ddns.py
blob: 7ac7d3ac4aa1bac9ceb603e3a574b87940a3f382 (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
# -*- coding: utf-8 -*-
import logging, mv_common
import os, re

config_file = "mv_config"

def setup_ddns(systemconfig):
    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")