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