Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-session.in
Parent Directory | Revision Log
Revision 2642 -
(show annotations)
(download)
Thu Oct 8 10:23:56 2015 UTC (8 years, 8 months ago) by niro
File size: 3274 byte(s)
Thu Oct 8 10:23:56 2015 UTC (8 years, 8 months ago) by niro
File size: 3274 byte(s)
-added autostart option
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 | 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 ]] && echo "${line}" | cut -d"'" -f1-3 |
20 | ((counter++)) |
21 | done |
22 | } |
23 | |
24 | # 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 | --store) shift; store="$1" ;; |
35 | --autostart) shift; autostart="$1" ;; |
36 | esac |
37 | shift |
38 | done |
39 | |
40 | [[ -n ${method} ]] || die "No method given" |
41 | [[ -n ${autostart} ]] || autostart=0 |
42 | |
43 | case "${method}" in |
44 | add) |
45 | # requires name |
46 | [[ -n ${name} ]] || die "No name given" |
47 | # and session |
48 | [[ -n ${session} ]] || die "No session given" |
49 | |
50 | # add store and regen user xml |
51 | if [[ -n ${store} ]] |
52 | then |
53 | ${MCORE_LIBDIR}/storefront-store --add --store "${store}" |
54 | ${MCORE_LIBDIR}/storefront-store --regen |
55 | fi |
56 | |
57 | storefront_starter="${STOREFRONTDIR}/${name}.sh" |
58 | CONFIG="${MROOT}/${storefront_starter}" |
59 | clearconfig |
60 | |
61 | addconfig '#!/bin/bash' |
62 | addconfig "${MCORE_LIBDIR}/storefront-resolver --launch --user '${user}' --password '${password}' --domain '${domain}' --app '${session}' --store '${store}'" |
63 | chmod +x "${storefront_starter}" |
64 | |
65 | if is_provided fluxbox |
66 | then |
67 | # generate fluxbox menu entry |
68 | ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${storefront_starter}" && |
69 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
70 | # add autostart |
71 | if [[ ${autostart} = 1 ]] |
72 | then |
73 | ${MCORE_LIBDIR}/fluxbox-autostart --add --name "${name}" --exec "${storefront_starter}" && |
74 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart |
75 | fi |
76 | fi |
77 | if is_provided idesk |
78 | then |
79 | # generate idesk desktop icon |
80 | ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${storefront_starter}" --icon default.png && |
81 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
82 | fi |
83 | ;; |
84 | |
85 | del) |
86 | [[ -n ${name} ]] || die "No name given" |
87 | if [ -f ${MROOT}/${STOREFRONTDIR}/"${name}".sh ] |
88 | then |
89 | rm ${MROOT}/${STOREFRONTDIR}/"${name}".sh |
90 | if is_provided fluxbox |
91 | then |
92 | ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && |
93 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
94 | ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" && |
95 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart |
96 | fi |
97 | if is_provided idesk |
98 | then |
99 | ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" && |
100 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
101 | fi |
102 | else |
103 | eecho "No configured session named '${name}' exists." |
104 | fi |
105 | ;; |
106 | |
107 | print) |
108 | list_files_in_directory ${MROOT}/${STOREFRONTDIR} | sed 's:\.sh::g' |
109 | ;; |
110 | |
111 | query) |
112 | eval sessionlist=( $(print_storefront_session_list) ) |
113 | sessioncount="${#sessionlist[*]}" |
114 | for (( i=0; i<sessioncount; i++)) |
115 | do |
116 | rvecho -n "${sessionlist[${i}]};" |
117 | done |
118 | rvecho |
119 | ;; |
120 | esac |