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