Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/citrix.control.class.in
Parent Directory | Revision Log
Revision 2627 -
(hide annotations)
(download)
Tue Sep 29 10:03:39 2015 UTC (8 years, 7 months ago) by niro
File size: 6288 byte(s)
Tue Sep 29 10:03:39 2015 UTC (8 years, 7 months ago) by niro
File size: 6288 byte(s)
-reworked citrix control class and install it
1 | niro | 2627 | # $Id$ |
2 | niro | 2051 | |
3 | niro | 2627 | push_config 70_citrix_serverlist |
4 | push_config 80_citrix_session | ||
5 | |||
6 | help_citrix_serverlist() | ||
7 | niro | 2051 | { |
8 | niro | 2305 | local serial="${CLASS_ARGV[0]}" |
9 | niro | 2627 | control_client "${serial}" help citrix.serverlist |
10 | niro | 2051 | |
11 | niro | 2627 | mecho "get citrix.serverlist [action]" |
12 | mecho " Shows all hosts added on the serverlist." | ||
13 | mecho " [actions]:" | ||
14 | mecho " print - prints local configured serverlist" | ||
15 | mecho " query - get serverlist of the farm from given [server]" | ||
16 | mecho | ||
17 | mecho "set citrix.serverlist [action] [host]" | ||
18 | mecho " Adds or deletes a server from the ica serverlist." | ||
19 | mecho " [actions]:" | ||
20 | mecho " add - adds a server" | ||
21 | mecho " del - deletes a server" | ||
22 | mecho " auto - queries given [server] for the serverlist and adds all of them" | ||
23 | mecho | ||
24 | mecho " host - dns hostname or ip of the server" | ||
25 | mecho | ||
26 | mecho " If no [host] was given, all entries are deleted." | ||
27 | niro | 2051 | } |
28 | |||
29 | niro | 2627 | help_citrix_session() |
30 | niro | 2051 | { |
31 | niro | 2305 | local serial="${CLASS_ARGV[0]}" |
32 | niro | 2627 | control_client "${serial}" help citrix.session |
33 | niro | 2051 | |
34 | niro | 2627 | mecho "get citrix.session" |
35 | mecho " Shows all configured ICA sessions" | ||
36 | mecho " print - prints all local configured sessions" | ||
37 | mecho " query - get sessionlist of the farm from given [server]" | ||
38 | mecho | ||
39 | mecho "set citrix.session [action] [name] [session] [mode] [user] [domain] [password]" | ||
40 | mecho " Adds or delets a ICA session." | ||
41 | mecho " Available actions:" | ||
42 | mecho " add - adds a new ica session" | ||
43 | mecho " del - deletes ica session with name [name]" | ||
44 | mecho " if no [name] given, all sessions will be deleted" | ||
45 | mecho | ||
46 | mecho " Available modes:" | ||
47 | mecho " fullscreen - fullscreen session" | ||
48 | mecho " seamless - seamless windows session" | ||
49 | mecho " *x* - windowed session with given resolution" | ||
50 | mecho " any resonable resolution is fine like:" | ||
51 | mecho " 1024x768, 1280x1024, 1440x900 etc" | ||
52 | mecho | ||
53 | mecho " session - name of the Citrix session" | ||
54 | mecho " user - user inside the session - optional" | ||
55 | mecho " domain - logon domain of the user - optional" | ||
56 | mecho " password - password of the user - optional" | ||
57 | } | ||
58 | niro | 2051 | |
59 | niro | 2627 | set_citrix_session() |
60 | { | ||
61 | local serial="${CLASS_ARGV[0]}" | ||
62 | local action="${CLASS_ARGV[1]}" | ||
63 | local name="${CLASS_ARGV[2]}" | ||
64 | local session="${CLASS_ARGV[3]}" | ||
65 | local mode="${CLASS_ARGV[4]}" | ||
66 | local user="${CLASS_ARGV[5]}" | ||
67 | local domain="${CLASS_ARGV[6]}" | ||
68 | local password="${CLASS_ARGV[7]}" | ||
69 | local id | ||
70 | local enabled | ||
71 | |||
72 | case "${action}" in | ||
73 | add) enabled=1 ;; | ||
74 | del) enabled=0 ;; | ||
75 | *) | ||
76 | eecho "Unknown action '${action}'" | ||
77 | return 1 | ||
78 | ;; | ||
79 | esac | ||
80 | |||
81 | if [[ -z ${name} ]] | ||
82 | then | ||
83 | eecho "No name given" | ||
84 | return 1 | ||
85 | fi | ||
86 | |||
87 | id=$(mysqldo "select id from cfg_sessions_citrix where serial='${serial}' and name='${name}';") | ||
88 | if [[ -n ${id} ]] | ||
89 | then | ||
90 | mysqldo "update cfg_sessions_citrix set name='${name}', session='${session}', filename='${filename}', username='${username}', domain='${domain}', password='${password}', browseradrs='${browseradrs}', enabled='${enabled}' where id=${id};" | ||
91 | else | ||
92 | mysqldo "insert into cfg_sessions_citrix(serial, name, session, filename, username, domain, password, browseradrs, enabled) values('${serial}', '${name}', '${session}', ${store}', '${filename}', '${domain}', '${password}', '${browseradrs}', '${enabled}');" | ||
93 | fi | ||
94 | } | ||
95 | |||
96 | control_citrix_session() | ||
97 | { | ||
98 | local serial="${CLASS_ARGV[0]}" | ||
99 | push_config_80_citrix_session "${serial}" | ||
100 | } | ||
101 | |||
102 | push_config_80_citrix_session() | ||
103 | { | ||
104 | local serial="$1" | ||
105 | local values | ||
106 | local id | ||
107 | |||
108 | values=$(mysqldo "select id from cfg_sessions_citrix where serial='${serial}';") | ||
109 | for id in ${values} | ||
110 | niro | 2051 | do |
111 | niro | 2627 | evaluate_table_xml cfg_sessions_citrix "where serial='${serial}'" |
112 | if [[ -z ${cfg_sessions_citrix_session} ]] | ||
113 | then | ||
114 | eecho "Session must not be empty id->'${id}'" | ||
115 | continue | ||
116 | fi | ||
117 | if [[ -z ${cfg_sessions_citrix_enabled} ]] | ||
118 | then | ||
119 | eecho "Enabled must not be empty id->'${id}'" | ||
120 | continue | ||
121 | fi | ||
122 | if [[ ${cfg_sessions_citrix_enabled} = 1 ]] | ||
123 | then | ||
124 | control_client "${serial}" set citrix.session add "${cfg_sessions_citrix_name}" "${cfg_sessions_citrix_session}" "${cfg_sessions_citrix_store}" "${cfg_sessions_citrix_username}" "${cfg_sessions_citrix_domain} ${cfg_sessions_citrix_password}" | ||
125 | elif [[ ${cfg_sessions_citrix_enabled} = 0 ]] | ||
126 | then | ||
127 | control_client "${serial}" set citrix.session del "${cfg_sessions_citrix_name}" | ||
128 | # remove from database too | ||
129 | mysqldo "delete from cfg_sessions_citrix where id='${id}';" | ||
130 | else | ||
131 | eecho "unknown enabled value id->'${id}', cfg_sessions_citrix_enabled -> '${cfg_sessions_citrix_enabled}'" | ||
132 | return 1 | ||
133 | fi | ||
134 | niro | 2051 | done |
135 | } | ||
136 | |||
137 | niro | 2627 | set_citrix_serverlist() |
138 | niro | 2051 | { |
139 | niro | 2305 | local serial="${CLASS_ARGV[0]}" |
140 | niro | 2627 | local action="${CLASS_ARGV[1]}" |
141 | local host="${CLASS_ARGV[2]}" | ||
142 | local id | ||
143 | local enabled | ||
144 | niro | 2051 | |
145 | niro | 2627 | case "${action}" in |
146 | add) enabled=1 ;; | ||
147 | del) enabled=0 ;; | ||
148 | *) | ||
149 | eecho "Unknown action '${action}'" | ||
150 | return 1 | ||
151 | ;; | ||
152 | esac | ||
153 | |||
154 | if [[ -z ${store} ]] | ||
155 | then | ||
156 | eecho "No store given" | ||
157 | return 1 | ||
158 | fi | ||
159 | |||
160 | id=$(mysqldo "select id from cfg_citrix_serverlist where serial='${serial}' and host='${host}';") | ||
161 | if [[ -n ${id} ]] | ||
162 | then | ||
163 | mysqldo "update cfg_citrix_serverlist set host='${host}', enabled='${enabled}' where id=${id};" | ||
164 | else | ||
165 | mysqldo "insert into cfg_citrx_serverlist(serial, store, enabled) values('${serial}', '${store}', '${enabled}');" | ||
166 | fi | ||
167 | niro | 2051 | } |
168 | niro | 2627 | |
169 | control_citrix_serverlist() | ||
170 | { | ||
171 | local serial="${CLASS_ARGV[0]}" | ||
172 | push_config_70_citrix_serverlist "${serial}" | ||
173 | } | ||
174 | |||
175 | push_config_70_citrix_serverlist() | ||
176 | { | ||
177 | local serial="$1" | ||
178 | local values | ||
179 | local id | ||
180 | |||
181 | values=$(mysqldo "select id from cfg_citrix_serverlist where serial='${serial}';") | ||
182 | for id in ${values} | ||
183 | do | ||
184 | evaluate_table_xml cfg_citrix_serverlist "where serial='${serial}'" | ||
185 | if [[ -z ${cfg_citrix_serverlist_host} ]] | ||
186 | then | ||
187 | eecho "Host must not be empty id->'${id}'" | ||
188 | continue | ||
189 | fi | ||
190 | if [[ -z ${cfg_citrix_serverlist_enabled} ]] | ||
191 | then | ||
192 | eecho "Enabled must not be empty id->'${id}'" | ||
193 | continue | ||
194 | fi | ||
195 | if [[ ${cfg_citrix_serverlist_enabled} = 1 ]] | ||
196 | then | ||
197 | control_client "${serial}" set citrix.serverlist add "${cfg_citrix_serverlist_host}" | ||
198 | elif [[ ${cfg_citrix_serverlist_enabled} = 0 ]] | ||
199 | then | ||
200 | control_client "${serial}" set citrix.serverlist del "${cfg_citrix_serverlist_host}" | ||
201 | # remove from database too | ||
202 | mysqldo "delete from cfg_citrix_serverlist where id='${id}';" | ||
203 | else | ||
204 | eecho "unknown enabled value id->'${id}', cfg_citrix_serverlist_enabled -> '${cfg_citrix_serverlist_enabled}'" | ||
205 | return 1 | ||
206 | fi | ||
207 | done | ||
208 | } |