Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-session.in
Parent Directory | Revision Log
Revision 2394 -
(hide annotations)
(download)
Thu Aug 27 08:19:43 2015 UTC (8 years, 8 months ago) by niro
File size: 2651 byte(s)
Thu Aug 27 08:19:43 2015 UTC (8 years, 8 months ago) by niro
File size: 2651 byte(s)
-fixed a typo
1 | niro | 2354 | #!/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 | niro | 2357 | STOREFRONTDIR="${MCORE_CONFIG_PATH}/citrix/storefront" |
9 | niro | 2354 | |
10 | die() { echo "ERROR: $@"; exit 1; } | ||
11 | |||
12 | niro | 2393 | print_storefront_session_list() |
13 | { | ||
14 | local counter | ||
15 | |||
16 | declare -i counter=0 | ||
17 | x11runas "${MCORE_LIBDIR}/storefront-resolver --enumerate --user '${user}' --password '${password}' --domain '${domain}'" | while read line | ||
18 | do | ||
19 | [[ ${counter} -gt 0 ]] && "${line}" | cut -d"'" -f1-3 | ||
20 | ((counter++)) | ||
21 | done | ||
22 | } | ||
23 | |||
24 | niro | 2354 | # very basic getops |
25 | for argv in $* | ||
26 | do | ||
27 | case $1 in | ||
28 | --add|--del|--print|--query) method="${1//--}" ;; | ||
29 | --name) shift; name="$1" ;; | ||
30 | --session) shift; session="$1" ;; | ||
31 | --user) shift; user="$1" ;; | ||
32 | --domain) shift; domain="$1" ;; | ||
33 | --password) shift; password="$1" ;; | ||
34 | esac | ||
35 | shift | ||
36 | done | ||
37 | |||
38 | niro | 2383 | [[ -n ${method} ]] || die "No method given" |
39 | niro | 2354 | |
40 | case "${method}" in | ||
41 | add) | ||
42 | # requires name | ||
43 | [[ -n ${name} ]] || die "No name given" | ||
44 | # and session | ||
45 | [[ -n ${session} ]] || die "No session given" | ||
46 | |||
47 | storefront_starter="${STOREFRONTDIR}/${name}.sh" | ||
48 | CONFIG="${MROOT}/${storefront_starter}" | ||
49 | clearconfig | ||
50 | |||
51 | addconfig '#!/bin/bash' | ||
52 | niro | 2391 | addconfig "${MCORE_LIBDIR}/storefront-resolver --launch --user '${user}' --password '${password}' --domain '${domain}' --app '${session}'" |
53 | niro | 2381 | chmod +x "${storefront_starter}" |
54 | niro | 2354 | |
55 | if is_provided fluxbox | ||
56 | then | ||
57 | # generate fluxbox menu entry | ||
58 | niro | 2381 | ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${storefront_starter}" && |
59 | niro | 2354 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
60 | fi | ||
61 | niro | 2381 | if is_provided idesk |
62 | then | ||
63 | # generate idesk desktop icon | ||
64 | niro | 2388 | ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${storefront_starter}" --icon default.png && |
65 | niro | 2381 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
66 | fi | ||
67 | niro | 2354 | ;; |
68 | |||
69 | del) | ||
70 | [[ -n ${name} ]] || die "No name given" | ||
71 | if [ -f ${MROOT}/${STOREFRONTDIR}/"${name}".sh ] | ||
72 | then | ||
73 | rm ${MROOT}/${STOREFRONTDIR}/"${name}".sh | ||
74 | if is_provided fluxbox | ||
75 | then | ||
76 | ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && | ||
77 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu | ||
78 | fi | ||
79 | niro | 2381 | if is_provided idesk |
80 | then | ||
81 | ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" && | ||
82 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons | ||
83 | fi | ||
84 | niro | 2354 | else |
85 | eecho "No configured session named '${name}' exists." | ||
86 | fi | ||
87 | ;; | ||
88 | |||
89 | print) | ||
90 | niro | 2394 | list_files_in_directory ${MROOT}/${STOREFRONTDIR} | sed 's:\.sh::g' |
91 | niro | 2354 | ;; |
92 | |||
93 | query) | ||
94 | niro | 2393 | eval sessionlist=( $(print_storefront_session_list) ) |
95 | niro | 2354 | sessioncount="${#sessionlist[*]}" |
96 | for (( i=0; i<sessioncount; i++)) | ||
97 | do | ||
98 | rvecho -n "${sessionlist[${i}]};" | ||
99 | done | ||
100 | rvecho | ||
101 | ;; | ||
102 | esac |