Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront.control.class.in

Parent Directory Parent Directory | Revision Log Revision Log


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