Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-resolver.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2352 - (show annotations) (download)
Mon Aug 24 11:03:25 2015 UTC (8 years, 8 months ago) by niro
File size: 2960 byte(s)
-added initial storefront support
1 #!/bin/bash
2
3 CMD="$1"
4 USER="$2"
5 PASS="$3"
6 DOMAIN="$4"
7 APP="$5"
8
9 BROWSER=""
10 : ${STOREFRONT_STORE=""}
11
12 if [[ -z ${STOREFRONT_STORE} ]]
13 then
14 source @@SYSCONFDIR@@/mcore/citrix.conf
15 fi
16
17 # prefer storebrowse
18 if [[ -e ${STOREBROWSE_EXECUTABLE} ]]
19 then
20 BROWSER=${STOREBROWSE_EXECUTABLE}
21 ADDSTORE_REQUIERED=1
22 # use old pnabrowse
23 elif [[ -e ${PNABROWSE_EXECUTABLE} ]]
24 then
25 BROWSER=${PNABROWSE_EXECUTABLE}
26 ADDSTORE_REQUIERED=0
27 else
28 echo "No Citrix browser found."
29 exit 1
30 fi
31
32 USE_XMESSAGE=0
33 if [[ -x $(type -P xmessage) ]]
34 then
35 USE_XMESSAGE=1
36 fi
37
38 storefront_add_store()
39 {
40 if [[ -z $("${BROWSER}" -l "${STORE}" | grep "'${STOREFRONT_STORE}'") ]]
41 then
42 "${BROWSER}" -a "${STOREFRONT_STORE}"
43 else
44 echo "Store '${STOREFRONT_STORE}' already added."
45 fi
46 }
47
48 storefront_delete_store()
49 {
50 if [[ -n $("${BROWSER}" -l "${STORE}" | grep "'${STOREFRONT_STORE}'") ]]
51 then
52 "${BROWSER}" -d "${STOREFRONT_STORE}"
53 else
54 echo "Store '${STOREFRONT_STORE}' not found."
55 fi
56 }
57
58 storefront_subscribe_app()
59 {
60 # already subscribed?
61 if [[ -z $("${BROWSER}" -S -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" | grep "'${APP}'") ]]
62 then
63 "${BROWSER}" -s "${APP}" -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}"
64 else
65 echo "'${APP}' already subscribed.'"
66 fi
67 }
68
69 storefront_unsubscribe_app()
70 {
71 # already subscribed?
72 if [[ -n $("${BROWSER}" -S -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}" | grep "'${APP}'") ]]
73 then
74 "${BROWSER}" -u "${APP}" -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}"
75 else
76 echo "'${APP}' not subscribed.'"
77 fi
78 }
79
80 storefront_enumerate()
81 {
82 "${BROWSER}" -E -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}"
83 }
84
85 storefront_launch()
86 {
87 "${BROWSER}" -L "${APP}" -U "${USER}" -P "${PASS}" -D "${DOMAIN}" "${STOREFRONT_STORE}"
88 }
89
90 case ${CMD} in
91 enumerate)
92 # enumerate apps
93 if [[ ${ADDSTORE_REQUIERED} = 1 ]]
94 then
95 storefront_add_store
96 fi
97 storefront_enumerate
98 ;;
99
100 launch)
101 # launch apps
102 if [[ ${USE_XMESSAGE} = 1 ]]
103 then
104 xmessage -center -title "ICA-Client" -buttons "" "
105 Starting session '${APP}' ...
106
107 " &
108 fi
109 if [[ ${ADDSTORE_REQUIERED} = 1 ]]
110 then
111 storefront_add_store
112 storefront_subscribe_app
113 else
114 # always enumerate all apps to fill the cache or launch will not work
115 # and always enumerate if the cache is older than one day
116 if [ ! -f ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml ] ||
117 [[ ! -z $(find ~/.ICAClient/cache/Citrix/PNAgent/AppCache/appdata.xml -mtime +1) ]]
118 then
119 storefront_enumerate
120 fi
121 fi
122 if storefront_launch
123 then
124 if [[ ${USE_XMESSAGE} = 1 ]]
125 then
126 killall xmessage
127 fi
128 else
129 if [[ ${USE_XMESSAGE} = 1 ]]
130 then
131 killall xmessage
132 xmessage -center -title "ICA-Client" -buttons "
133 Abort" "Failed to start session '${APP}'.
134
135 " &
136 else
137 echo "Failed to start session '${APP}'."
138 fi
139 fi
140 ;;
141
142 *)
143 echo "Unknown command '${CMD}'."
144 exit 1
145 ;;
146 esac