Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-session.in
Parent Directory | Revision Log
Revision 2893 -
(show annotations)
(download)
Fri Aug 14 11:45:43 2020 UTC (3 years, 8 months ago) by niro
File size: 3295 byte(s)
Fri Aug 14 11:45:43 2020 UTC (3 years, 8 months ago) by niro
File size: 3295 byte(s)
-load all client provides to honor is_provided()
1 | #!/bin/bash |
2 | |
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 | source @@SYSCONFDIR@@/mcore/mcore.conf |
5 | source ${MCORE_LIBDIR}/include/common.global.class |
6 | source ${MCORE_LIBDIR}/include/daemon.global.class |
7 | |
8 | STOREFRONTDIR="${MCORE_CONFIG_PATH}/citrix/storefront" |
9 | |
10 | die() { echo "ERROR: $@"; exit 1; } |
11 | |
12 | load_classes client |
13 | |
14 | print_storefront_session_list() |
15 | { |
16 | local counter |
17 | |
18 | declare -i counter=0 |
19 | x11runas "${MCORE_LIBDIR}/storefront-resolver --enumerate --user '${user}' --password '${password}' --domain '${domain}'" | while read line |
20 | do |
21 | [[ ${counter} -gt 0 ]] && echo "${line}" | cut -d"'" -f1-3 |
22 | ((counter++)) |
23 | done |
24 | } |
25 | |
26 | # very basic getops |
27 | for argv in $* |
28 | do |
29 | case $1 in |
30 | --add|--del|--print|--query) method="${1//--}" ;; |
31 | --name) shift; name="$1" ;; |
32 | --session) shift; session="$1" ;; |
33 | --user) shift; user="$1" ;; |
34 | --domain) shift; domain="$1" ;; |
35 | --password) shift; password="$1" ;; |
36 | --store) shift; store="$1" ;; |
37 | --autostart) shift; autostart="$1" ;; |
38 | esac |
39 | shift |
40 | done |
41 | |
42 | [[ -n ${method} ]] || die "No method given" |
43 | [[ -n ${autostart} ]] || autostart=0 |
44 | |
45 | case "${method}" in |
46 | add) |
47 | # requires name |
48 | [[ -n ${name} ]] || die "No name given" |
49 | # and session |
50 | [[ -n ${session} ]] || die "No session given" |
51 | |
52 | # add store and regen user xml |
53 | if [[ -n ${store} ]] |
54 | then |
55 | ${MCORE_LIBDIR}/storefront-store --add --store "${store}" |
56 | ${MCORE_LIBDIR}/storefront-store --regen |
57 | fi |
58 | |
59 | storefront_starter="${STOREFRONTDIR}/${name}.sh" |
60 | CONFIG="${MROOT}/${storefront_starter}" |
61 | clearconfig |
62 | |
63 | addconfig '#!/bin/bash' |
64 | addconfig "${MCORE_LIBDIR}/storefront-resolver --launch --user '${user}' --password '${password}' --domain '${domain}' --app '${session}' --store '${store}'" |
65 | chmod +x "${storefront_starter}" |
66 | |
67 | if is_provided fluxbox |
68 | then |
69 | # generate fluxbox menu entry |
70 | ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${storefront_starter}" && |
71 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
72 | # add autostart |
73 | if [[ ${autostart} = 1 ]] |
74 | then |
75 | ${MCORE_LIBDIR}/fluxbox-autostart --add --name "${name}" --exec "${storefront_starter}" && |
76 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart |
77 | fi |
78 | fi |
79 | if is_provided idesk |
80 | then |
81 | # generate idesk desktop icon |
82 | ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${storefront_starter}" --icon default.png && |
83 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
84 | fi |
85 | ;; |
86 | |
87 | del) |
88 | [[ -n ${name} ]] || die "No name given" |
89 | if [ -f ${MROOT}/${STOREFRONTDIR}/"${name}".sh ] |
90 | then |
91 | rm ${MROOT}/${STOREFRONTDIR}/"${name}".sh |
92 | if is_provided fluxbox |
93 | then |
94 | ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && |
95 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
96 | ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" && |
97 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart |
98 | fi |
99 | if is_provided idesk |
100 | then |
101 | ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" && |
102 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
103 | fi |
104 | else |
105 | eecho "No configured session named '${name}' exists." |
106 | fi |
107 | ;; |
108 | |
109 | print) |
110 | list_files_in_directory ${MROOT}/${STOREFRONTDIR} | sed 's:\.sh::g' |
111 | ;; |
112 | |
113 | query) |
114 | eval sessionlist=( $(print_storefront_session_list) ) |
115 | sessioncount="${#sessionlist[*]}" |
116 | for (( i=0; i<sessioncount; i++)) |
117 | do |
118 | rvecho -n "${sessionlist[${i}]};" |
119 | done |
120 | rvecho |
121 | ;; |
122 | esac |