Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/citrix-session.in
Parent Directory | Revision Log
Revision 2405 -
(show annotations)
(download)
Mon Aug 31 08:58:41 2015 UTC (8 years, 8 months ago) by niro
File size: 3724 byte(s)
Mon Aug 31 08:58:41 2015 UTC (8 years, 8 months ago) by niro
File size: 3724 byte(s)
-generate a desktop icon
1 | #!/bin/bash |
2 | |
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 | source @@SYSCONFDIR@@/mcore/mcore.conf |
5 | source ${MCORE_LIBDIR}/include/common.global.class |
6 | source ${MCORE_LIBDIR}/include/daemon.global.class |
7 | |
8 | ICADIR="${MCORE_CONFIG_PATH}/citrix/ica" |
9 | ICASUFFIX="ica" |
10 | |
11 | die() { echo "ERROR: $@"; exit 1; } |
12 | |
13 | # very basic getops |
14 | for argv in $* |
15 | do |
16 | case $1 in |
17 | --add|--del|--print|--query) method="${1//--}" ;; |
18 | --name) shift; name="$1" ;; |
19 | --session) shift; session="$1" ;; |
20 | --mode) shift; mode="$1" ;; |
21 | --user) shift; user="$1" ;; |
22 | --domain) shift; domain="$1" ;; |
23 | --password) shift; password="$1" ;; |
24 | esac |
25 | shift |
26 | done |
27 | |
28 | [[ -n ${method} ]] || die "No method given" |
29 | |
30 | case "${method}" in |
31 | add) |
32 | # requires name |
33 | [[ -n ${name} ]] || die "No name given" |
34 | # action 'add' requires mode too |
35 | [[ -n ${mode} ]] || die "No mode given" |
36 | # and session |
37 | [[ -n ${session} ]] || die "No session given" |
38 | |
39 | # other sanity checks |
40 | case "${mode}" in |
41 | fullscreen) ;; |
42 | seamless) ;; |
43 | *x*) ;; |
44 | *) die "unknown mode '${mode}'" |
45 | esac |
46 | |
47 | icafile="${ICADIR}/${name}.${ICASUFFIX}" |
48 | CONFIG="${MROOT}/${icafile}" |
49 | clearconfig |
50 | |
51 | addconfig '[WFClient]' |
52 | addconfig 'Version=2' |
53 | |
54 | serverlist=$(NOCOLORS=true ${MCORE_LIBDIR}/citrix-serverlist --print) |
55 | declare -i i=0 |
56 | for server in ${serverlist} |
57 | do |
58 | (( i++ )) |
59 | server_num="${i}" |
60 | [[ ${i} -eq 1 ]] && server_num="" |
61 | addconfig "TcpBrowserAddress${server_num}=${server}" |
62 | done |
63 | addconfig 'ScreenPercent=0' |
64 | addconfig '[ApplicationServers]' |
65 | addconfig "${session}=" |
66 | addconfig "[${session}]" |
67 | addconfig "Address=${session}" |
68 | addconfig "InitialProgram=#${session}" |
69 | |
70 | # mapping table xorg -> citrix |
71 | # citrix 1 = 16 colors |
72 | # citrix 2 = 256 colors |
73 | # citrix 4 = 16 bit |
74 | # citrix 8 = 32 bit |
75 | # try always 16 bit |
76 | addconfig "DesiredColor=4" |
77 | |
78 | addconfig 'TransportDriver=TCP/IP' |
79 | addconfig 'WinStationDriver=ICA 3.0' |
80 | |
81 | [[ -n ${user} ]] && addconfig "Username=${user}" |
82 | [[ -n ${domain} ]] && addconfig "Domain=${domain}" |
83 | [[ -n ${password} ]] && addconfig "ClearPassword=${password}" |
84 | |
85 | # use the right display settings |
86 | case "${mode}" in |
87 | # fullscreen mode |
88 | fullscreen) |
89 | addconfig 'UseFullScreen=Yes' |
90 | addconfig 'NoWindowManager=True' |
91 | addconfig "DesiredHRES=65535" |
92 | addconfig "DesiredVRES=65535" |
93 | ;; |
94 | # seamless window mode |
95 | seamless) |
96 | addconfig 'TWIMode=On' |
97 | ;; |
98 | # a desired resolution |
99 | *x*) |
100 | addconfig "DesiredHRES=${mode%x*}" |
101 | addconfig "DesiredVRES=${mode#*x}" |
102 | ;; |
103 | esac |
104 | |
105 | if is_provided fluxbox |
106 | then |
107 | # generate fluxbox menu entry |
108 | ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "wfica ${icafile}" && |
109 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
110 | fi |
111 | if is_provided idesk |
112 | then |
113 | # generate idesk desktop icon |
114 | ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "wfica ${icafile}" --icon default.png && |
115 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
116 | fi |
117 | ;; |
118 | |
119 | del) |
120 | [[ -n ${name} ]] || die "No name given" |
121 | if [ -f ${MROOT}/${ICADIR}/"${name}".${ICASUFFIX} ] |
122 | then |
123 | rm ${MROOT}/${ICADIR}/"${name}".${ICASUFFIX} |
124 | if is_provided fluxbox |
125 | then |
126 | ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && |
127 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
128 | fi |
129 | if is_provided idesk |
130 | then |
131 | ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" && |
132 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
133 | fi |
134 | else |
135 | eecho "No configured session named '${name}' exists." |
136 | fi |
137 | ;; |
138 | |
139 | print) |
140 | list_files_in_directory ${MROOT}/${ICADIR} |
141 | ;; |
142 | |
143 | query) |
144 | eval sessionlist=( $(${MCORE_LIBDIR}/query-citrix-browser --session) ) |
145 | sessioncount="${#sessionlist[*]}" |
146 | for (( i=0; i<sessioncount; i++)) |
147 | do |
148 | rvecho -n "${sessionlist[${i}]};" |
149 | done |
150 | rvecho |
151 | ;; |
152 | esac |