24 |
generate_storefront_xml() |
generate_storefront_xml() |
25 |
{ |
{ |
26 |
local config |
local config |
27 |
local store_uri |
local store |
28 |
local xml |
local xml |
29 |
|
|
30 |
install -o "${MCORE_UNPRIV_USER}" -g "${MCORE_UNPRIV_GROUP}" -d "${MCORE_UNPRIV_HOME}/.ICAClient/cache/Stores" |
install -o "${MCORE_UNPRIV_USER}" -g "${MCORE_UNPRIV_GROUP}" -d "${MCORE_UNPRIV_HOME}/.ICAClient/cache/Stores" |
34 |
if [[ -L ${STOREFRONT_DIR}/default-store ]] |
if [[ -L ${STOREFRONT_DIR}/default-store ]] |
35 |
then |
then |
36 |
store_uri=$(source ${STOREFRONT_DIR}/default-store; echo "${STORE}") |
store_uri=$(source ${STOREFRONT_DIR}/default-store; echo "${STORE}") |
37 |
addconfig " <DefaultStore>${store_uri}</DefaultStore>" |
addconfig " <DefaultStore>${store}</DefaultStore>" |
38 |
else |
else |
39 |
# use the first one which gets found |
# use the first one which gets found |
40 |
for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
41 |
do |
do |
42 |
store_uri=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
43 |
if [[ -n ${store_uri} ]] |
if [[ -n ${store} ]] |
44 |
then |
then |
45 |
addconfig " <DefaultStore>${store_uri}</DefaultStore>" |
addconfig " <DefaultStore>${store}</DefaultStore>" |
46 |
break |
break |
47 |
fi |
fi |
48 |
done |
done |
56 |
addconfig ' <VisibleStores>' |
addconfig ' <VisibleStores>' |
57 |
for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
58 |
do |
do |
59 |
store_uri=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
60 |
if [[ -n ${store_uri} ]] |
if [[ -n ${store} ]] |
61 |
then |
then |
62 |
addconfig " <Store name=\"${store_uri}\" type=\"PNA\">" |
addconfig " <Store name=\"${store}\" type=\"PNA\">" |
63 |
addconfig " ${store_uri}" |
addconfig " ${store}" |
64 |
addconfig ' </Store>' |
addconfig ' </Store>' |
65 |
fi |
fi |
66 |
done |
done |
88 |
case "${method}" in |
case "${method}" in |
89 |
add) |
add) |
90 |
# requires name and store |
# requires name and store |
91 |
[[ -n ${store_uri} ]] || die "No store uri given" |
[[ -n ${store} ]] || die "No store uri given" |
92 |
|
|
93 |
# only pna stores are allowed at the moment |
# only pna stores are allowed at the moment |
94 |
if [[ ${store_uri/config.xml} = ${store_uri} ]] |
if [[ ${store/config.xml} = ${store} ]] |
95 |
then |
then |
96 |
die "Only PNA Stores are allowed." |
die "Only PNA Stores are allowed." |
97 |
fi |
fi |
98 |
|
|
99 |
store_name="$(normalize_store ${store_uri})" |
store_name="$(normalize_store ${store})" |
100 |
config="${STOREFRONT_STORES_DIR}/${store_name}.conf" |
config="${STOREFRONT_STORES_DIR}/${store_name}.conf" |
101 |
CONFIG="${MROOT}/${config}" |
CONFIG="${MROOT}/${config}" |
102 |
clearconfig |
clearconfig |
103 |
addconfig "STORE=\"${store_uri}\"" |
addconfig "STORE=\"${store}\"" |
104 |
;; |
;; |
105 |
|
|
106 |
del) |
del) |
107 |
if [[ -z ${store_uri} ]] |
if [[ -z ${store} ]] |
108 |
then |
then |
109 |
for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
for config in $(NOCOLORS=1 list_files_in_directory ${STOREFRONT_STORES_DIR}) |
110 |
do |
do |
114 |
fi |
fi |
115 |
done |
done |
116 |
else |
else |
117 |
store_name="$(normalize_store ${store_uri})" |
store_name="$(normalize_store ${store})" |
118 |
if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] |
if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] |
119 |
then |
then |
120 |
rm ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf |
rm ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf |
125 |
;; |
;; |
126 |
|
|
127 |
default) |
default) |
128 |
# requires store_uri |
# requires store |
129 |
[[ -n ${store_uri} ]] || die "No store uri given" |
[[ -n ${store} ]] || die "No store uri given" |
130 |
|
|
131 |
store_name="$(normalize_store ${store_uri})" |
store_name="$(normalize_store ${store})" |
132 |
if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] |
if [ -f ${MROOT}/${STOREFRONT_STORES_DIR}/"${store_name}".conf ] |
133 |
then |
then |
134 |
ln -snf ${STOREFRONT_STORES_DIR}/"${store_name}".conf ${STOREFRONT_DIR}/default-store |
ln -snf ${STOREFRONT_STORES_DIR}/"${store_name}".conf ${STOREFRONT_DIR}/default-store |
142 |
do |
do |
143 |
if [ -f ${STOREFRONT_STORES_DIR}/${config} ] |
if [ -f ${STOREFRONT_STORES_DIR}/${config} ] |
144 |
then |
then |
145 |
store_uri=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
store=$(source ${STOREFRONT_STORES_DIR}/${config}; echo "${STORE}") |
146 |
rvecho "${store_uri}" |
rvecho "${store}" |
147 |
fi |
fi |
148 |
done |
done |
149 |
;; |
;; |