Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/tigervnc/vnc.client.class.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2171 - (hide annotations) (download)
Fri Jan 10 14:10:21 2014 UTC (10 years, 3 months ago) by niro
File size: 2428 byte(s)
-fixed whitespaces
1 niro 1248 # $Id$
2    
3     provide x0vnc
4 niro 1263 require basic-video
5 niro 1248
6 niro 2070 help_vnc_service()
7 niro 1248 {
8 niro 2070 mecho "get vnc.service"
9     mecho " Shows X0-VNC facility status."
10     mecho
11     mecho "set vnc.service [command]"
12     mecho " Controls the X0-VNC facility."
13     mecho " Commands:"
14     mecho " enable - Enable vnc for the X0 display"
15     mecho " disable - Disable vnc for the X0 display"
16     mecho
17     mecho " X11 restart is required!"
18 niro 1248 }
19    
20     help_vnc_passwd()
21     {
22 niro 2070 mecho "get vnc.passwd"
23     mecho " Shows if a vnc password was set."
24     mecho
25 niro 1248 mecho "set vnc.passwd [password]"
26 niro 2070 mecho " Sets given vnc password for remote connections."
27 niro 1248 }
28    
29 niro 2070 helper_vnc_enable()
30 niro 1248 {
31 niro 1263 # add to module section
32 niro 2024 local CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/module/99-vnc.conf"
33 niro 1248 clearconfig
34 niro 1263 addconfig ' Load "vnc"'
35 niro 1248
36 niro 1263 # add to screen section
37 niro 2024 local CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/99-vnc.conf"
38 niro 1263 clearconfig
39     addconfig ' Option "SecurityTypes" "VncAuth"'
40 niro 2171 addconfig ' Option "UserPasswdVerifier" "VncAuth"'
41     addconfig ' Option "PasswordFile" "/root/.vnc/passwd"'
42 niro 1263
43     # requires graphic!
44     helper_graphic_rebuild_xorg_conf_d
45    
46     mecho "Done but X11 restart required!"
47 niro 1248 }
48    
49 niro 2070 helper_vnc_disable()
50 niro 1248 {
51 niro 2024 local CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/screen/99-vnc.conf"
52 niro 1263 clearconfig
53    
54 niro 2024 local CONFIG="${MROOT}/${MCORE_CONFIG_PATH}/xorg/module/99-vnc.conf"
55 niro 1263 clearconfig
56    
57     # requires graphic!
58     helper_graphic_rebuild_xorg_conf_d
59    
60     mecho "Done but X11 restart required!"
61 niro 1248 }
62    
63 niro 2070 get_vnc_service()
64     {
65     if [ -f ${MROOT}/etc/X11/xorg.conf.d/25-module.conf ]
66     then
67     if [[ -n $(grep 'Load.*vnc' ${MROOT}/etc/X11/xorg.conf.d/25-module.conf) ]]
68     then
69     mecho "VNC facility is enabled."
70     rvecho "1"
71     else
72     mecho "VNC facility is disabled."
73     rvecho "0"
74     fi
75     else
76     mecho "VNC facility not configured yet."
77     rvecho "0"
78     fi
79     }
80    
81     set_vnc_service()
82     {
83     local action="$1"
84     if [[ -z ${action} ]]
85     then
86     help_vnc_service
87     return 1
88     fi
89    
90     case ${action} in
91     enable) helper_vnc_enable ;;
92     disable) helper_vnc_disable ;;
93     *) help_vnc_service && return 1 ;;
94     esac
95     }
96    
97     get_vnc_passwd()
98     {
99     if [ -s ${MROOT}/root/.vnc/passwd ]
100     then
101     mecho "A VNC password was set."
102     rvecho "1"
103     else
104     mecho "No VNC password was set yet."
105     rvecho "0"
106     fi
107     }
108    
109 niro 1248 set_vnc_passwd()
110     {
111     local pass="$1"
112 niro 2107 local vncconfigdir="${MROOT}/root/.vnc"
113     local vncpasswd="${vncconfigdir}/passwd"
114 niro 1248 [[ -z ${pass} ]] && help_vnc_passwd && return 1
115 niro 2107 [ -d ${vncconfigdir} ] || install -d ${vncconfigdir}
116 niro 1248
117     vncpasswd "${vncpasswd}" > /dev/null << EOF
118     ${pass}
119     ${pass}
120     EOF
121     }