summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/mv_webuser.py
blob: 3fdbc35f95670be2eb3eaa7aa9bf73e3808995d8 (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
30
31
32
33
34
35
# -*- coding: utf-8 -*-
import logging, mv_common
#import os

def setup_web_auth(UseMythWEB_auth):
    if  mv_common.read_config(mv_common.module_config,"webuser")  == False  :
        logging.info("____Skipping of webuser, config disabled____")
        return

    logging.info("____Start of setup_web_auth____")
    include_file="/etc/gen_light_conf.d/auth.conf"
    if UseMythWEB_auth == str(1):
        logging.info("    Enabling authorization for mythweb")
        try:
            fo = open(include_file, "w")
            out_string='''include "/etc/lighttpd/auth-inc.conf"
'''
            fo.write(out_string)
            fo.close()
        except:
            logging.info("    Couldn't open auth include file")

    else:
        #disable auth
        logging.info("    Disabling authorization for mythweb")
        cmd="rm -f %s" %include_file
        mv_common.runcmd(cmd)
    logging.debug("Running gen_light_include.py")
    cmd="/usr/LH/bin/gen_light_include.py"
    mv_common.runcmd(cmd)
    logging.debug("Restarting lighttpd")
    cmd="sudo sv restart lighttpd"
    mv_common.runcmd(cmd)
    logging.info("__End of webauth\n")