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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# -*- coding: utf-8 -*-
import logging, mv_common
import os, re
config_file = "mv_config"
def setupvnc_system(systemconfig,data_config):
logging.info("____Start of vnc setup____")
mv_common.pacinstall("tigervnc")
vncdir=data_config.VNCHOME+"/.vnc"
try:
os.makedirs(vncdir)
os.chown(vncdir,78,78)
except:
logging.info(" couldn't create vnc dir:%s" %vncdir)
vncfile="%s/xstartup" %vncdir
file_contents='''
#!/bin/bash
xhost + localhost
xhost + 127.0.0.1
vncconfig -iconic &
if [ ! -e ~GNUstep ]
then
wmaker.inst
cp -f /usr/share/wm_data/GNUstep/Defaults/WindowMaker ~/GNUstep/Defaults/
cp -f /usr/share/wm_data/GNUstep/Defaults/WMState.vnc ~/GNUstep/Defaults/WMState
cp -f /usr/share/wm_data/GNUstep/Defaults/WMWindowAttributes ~/GNUstep/Defaults/
cp -f /usr/share/wm_data/GNUstep/Defaults/WMRootMenu ~/GNUstep/Defaults/
fi
exec wmaker
'''
try:
logging.debug(" Writing %s",vncfile)
f= open(vncfile,'w')
f.write(file_contents)
f.close()
os.chmod(vncfile,0755)
except:
logging.debug(" Couldn't open %s",vncfile)
logging.debug(" Aborting vnc...")
try:
vncuid = pwd.getpwnam('vncsvc')[2]
vncgid = pwd.getpwnam('vncsvc')[3]
except:
logging.critical("* vncsvc not found")
vncuid = '78'
vncgid = '78'
mv_common.mkdir_mythhome(data_config.VNCHOME,vncuid,vncgid)
home_xml_file=data_config.VNCHOME + "/.mythtv/config.xml"
configxml_file="/usr/share/mythtv/config.xml"
mv_common.link_file(configxml_file,home_xml_file)
logging.info(" Writing out password")
vncpassfile="%s/passwd" %vncdir
cmd="echo %s|vncpasswd -f > %s" %(systemconfig.get("vncpassword"),vncpassfile)
mv_common.runcmd(cmd)
cmd="chmod 700 %s" %vncpassfile
mv_common.runcmd(cmd)
cmd="chown vncsvc %s" %vncpassfile
mv_common.runcmd(cmd)
logging.info("__End of vnc \n")
def setupvnc(systemconfig,data_config):
logging.info("____Start of vnc config ____")
if mv_common.read_config(mv_common.module_config,"vnc") == False :
logging.info("____Skipping of vnc, config disabled____")
return
try:
vnc=systemconfig.get("vncenable")
except:
vnc = "0"
if vnc == "1":
logging.info(" Installing vnc system\n")
setupvnc_system(systemconfig,data_config)
mv_common.add_service("vnc")
else:
mv_common.remove_service("vnc")
logging.info("__End of vnc\n")
|