Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront.control.class.in
Parent Directory | Revision Log
Revision 2628 -
(show annotations)
(download)
Tue Sep 29 10:13:00 2015 UTC (8 years, 7 months ago) by niro
File size: 4633 byte(s)
Tue Sep 29 10:13:00 2015 UTC (8 years, 7 months ago) by niro
File size: 4633 byte(s)
-fixed typos
1 | # $Id$ |
2 | |
3 | #push_config 70_storefront_store 80_storefront_session |
4 | push_config 80_storefront_session |
5 | |
6 | help_storefront_store() |
7 | { |
8 | local serial="${CLASS_ARGV[0]}" |
9 | control_client "${serial}" help storefront.store |
10 | } |
11 | |
12 | help_storefront_session() |
13 | { |
14 | local serial="${CLASS_ARGV[0]}" |
15 | control_client "${serial}" help storefront.session |
16 | } |
17 | |
18 | set_storefront_session() |
19 | { |
20 | local serial="${CLASS_ARGV[0]}" |
21 | local action="${CLASS_ARGV[1]}" |
22 | local name="${CLASS_ARGV[2]}" |
23 | local session="${CLASS_ARGV[3]}" |
24 | local store="${CLASS_ARGV[4]}" |
25 | local user="${CLASS_ARGV[5]}" |
26 | local domain="${CLASS_ARGV[6]}" |
27 | local password="${CLASS_ARGV[7]}" |
28 | local id |
29 | local enabled |
30 | |
31 | case "${action}" in |
32 | add) enabled=1 ;; |
33 | del) enabled=0 ;; |
34 | *) |
35 | eecho "Unknown action '${action}'" |
36 | return 1 |
37 | ;; |
38 | esac |
39 | |
40 | if [[ -z ${name} ]] |
41 | then |
42 | eecho "No name given" |
43 | return 1 |
44 | fi |
45 | |
46 | id=$(mysqldo "select id from cfg_sessions_storefront where serial='${serial}' and name='${name}';") |
47 | if [[ -n ${id} ]] |
48 | then |
49 | mysqldo "update cfg_sessions_storefront set name='${name}', session='${session}', filename='${filename}', username='${username}', domain='${domain}', password='${password}', store='${store}', enabled='${enabled}' where id=${id};" |
50 | else |
51 | mysqldo "insert into cfg_sessions_storefront(serial, name, session, filename, username, domain, password, store, enabled) values('${serial}', '${name}', '${session}', ${store}', '${filename}', '${domain}', '${password}', '${store}', '${enabled}');" |
52 | fi |
53 | } |
54 | |
55 | control_storefront_session() |
56 | { |
57 | local serial="${CLASS_ARGV[0]}" |
58 | push_config_80_storefront_session "${serial}" |
59 | } |
60 | |
61 | push_config_80_storefront_session() |
62 | { |
63 | local serial="$1" |
64 | local values |
65 | local id |
66 | |
67 | values=$(mysqldo "select id from cfg_sessions_storefront where serial='${serial}';") |
68 | for id in ${values} |
69 | do |
70 | evaluate_table_xml cfg_sessions_storefront "where serial='${serial}'" |
71 | if [[ -z ${cfg_sessions_storefront_session} ]] |
72 | then |
73 | eecho "Session must not be empty id->'${id}'" |
74 | continue |
75 | fi |
76 | if [[ -z ${cfg_sessions_storefront_enabled} ]] |
77 | then |
78 | eecho "Enabled must not be empty id->'${id}'" |
79 | continue |
80 | fi |
81 | if [[ ${cfg_sessions_storefront_enabled} = 1 ]] |
82 | then |
83 | control_client "${serial}" set storefront.session add "${cfg_sessions_storefront_name}" "${cfg_sessions_storefront_session}" "${cfg_sessions_storefront_store}" "${cfg_sessions_storefront_username}" "${cfg_sessions_storefront_domain} ${cfg_sessions_storefront_password}" |
84 | elif [[ ${cfg_sessions_storefront_enabled} = 0 ]] |
85 | then |
86 | control_client "${serial}" set storefront.session del "${cfg_sessions_storefront_name}" |
87 | # remove from database too |
88 | mysqldo "delete from cfg_sessions_storefront where id='${id}';" |
89 | else |
90 | eecho "unknown enabled value id->'${id}', cfg_sessions_storefront_enabled -> '${cfg_sessions_storefront_enabled}'" |
91 | return 1 |
92 | fi |
93 | done |
94 | } |
95 | |
96 | set_storefront_store() |
97 | { |
98 | local serial="${CLASS_ARGV[0]}" |
99 | local action="${CLASS_ARGV[1]}" |
100 | local store="${CLASS_ARGV[2]}" |
101 | local id |
102 | local enabled |
103 | |
104 | case "${action}" in |
105 | add) enabled=1 ;; |
106 | del) enabled=0 ;; |
107 | *) |
108 | eecho "Unknown action '${action}'" |
109 | return 1 |
110 | ;; |
111 | esac |
112 | |
113 | if [[ -z ${store} ]] |
114 | then |
115 | eecho "No store given" |
116 | return 1 |
117 | fi |
118 | |
119 | id=$(mysqldo "select id from cfg_storefront_store where serial='${serial}' and store='${store}';") |
120 | if [[ -n ${id} ]] |
121 | then |
122 | mysqldo "update cfg_storefront_store set store='${store}', enabled='${enabled}' where id=${id};" |
123 | else |
124 | mysqldo "insert into cfg_storefront_store(serial, store, enabled) values('${serial}', '${store}', '${enabled}');" |
125 | fi |
126 | } |
127 | |
128 | control_storefront_store() |
129 | { |
130 | local serial="${CLASS_ARGV[0]}" |
131 | push_config_70_storefront_store "${serial}" |
132 | } |
133 | |
134 | push_config_70_storefront_store() |
135 | { |
136 | local serial="$1" |
137 | local values |
138 | local id |
139 | |
140 | values=$(mysqldo "select id from cfg_storefront_store where serial='${serial}';") |
141 | for id in ${values} |
142 | do |
143 | evaluate_table_xml cfg_storefront_store "where serial='${serial}'" |
144 | if [[ -z ${cfg_storefront_store_store} ]] |
145 | then |
146 | eecho "Store must not be empty id->'${id}'" |
147 | continue |
148 | fi |
149 | if [[ -z ${cfg_storefront_store_enabled} ]] |
150 | then |
151 | eecho "Enabled must not be empty id->'${id}'" |
152 | continue |
153 | fi |
154 | if [[ ${cfg_storefront_store_enabled} = 1 ]] |
155 | then |
156 | control_client "${serial}" set storefront.store add "${cfg_storefront_store_store}" |
157 | elif [[ ${cfg_storefront_store_enabled} = 0 ]] |
158 | then |
159 | control_client "${serial}" set storefront.store del "${cfg_storefront_store_store}" |
160 | # remove from database too |
161 | mysqldo "delete from cfg_storefront_store where id='${id}';" |
162 | else |
163 | eecho "unknown enabled value id->'${id}', cfg_storefront_store_enabled -> '${cfg_storefront_store_enabled}'" |
164 | return 1 |
165 | fi |
166 | done |
167 | } |