Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/storefront-session.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2893 - (hide annotations) (download)
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 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 2893 load_classes client
13    
14 niro 2393 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 niro 2395 [[ ${counter} -gt 0 ]] && echo "${line}" | cut -d"'" -f1-3
22 niro 2393 ((counter++))
23     done
24     }
25    
26 niro 2354 # 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 niro 2603 --store) shift; store="$1" ;;
37 niro 2642 --autostart) shift; autostart="$1" ;;
38 niro 2354 esac
39     shift
40     done
41    
42 niro 2383 [[ -n ${method} ]] || die "No method given"
43 niro 2642 [[ -n ${autostart} ]] || autostart=0
44 niro 2354
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 niro 2593 # add store and regen user xml
53 niro 2603 if [[ -n ${store} ]]
54 niro 2593 then
55 niro 2603 ${MCORE_LIBDIR}/storefront-store --add --store "${store}"
56 niro 2593 ${MCORE_LIBDIR}/storefront-store --regen
57     fi
58    
59 niro 2354 storefront_starter="${STOREFRONTDIR}/${name}.sh"
60     CONFIG="${MROOT}/${storefront_starter}"
61     clearconfig
62    
63     addconfig '#!/bin/bash'
64 niro 2603 addconfig "${MCORE_LIBDIR}/storefront-resolver --launch --user '${user}' --password '${password}' --domain '${domain}' --app '${session}' --store '${store}'"
65 niro 2381 chmod +x "${storefront_starter}"
66 niro 2354
67     if is_provided fluxbox
68     then
69     # generate fluxbox menu entry
70 niro 2381 ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${storefront_starter}" &&
71 niro 2354 ${MCORE_LIBDIR}/fluxbox-rebuild-menu
72 niro 2642 # 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 niro 2354 fi
79 niro 2381 if is_provided idesk
80     then
81     # generate idesk desktop icon
82 niro 2388 ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${storefront_starter}" --icon default.png &&
83 niro 2381 ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons
84     fi
85 niro 2354 ;;
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 niro 2642 ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" &&
97     ${MCORE_LIBDIR}/fluxbox-rebuild-autostart
98 niro 2354 fi
99 niro 2381 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 niro 2354 else
105     eecho "No configured session named '${name}' exists."
106     fi
107     ;;
108    
109     print)
110 niro 2394 list_files_in_directory ${MROOT}/${STOREFRONTDIR} | sed 's:\.sh::g'
111 niro 2354 ;;
112    
113     query)
114 niro 2393 eval sessionlist=( $(print_storefront_session_list) )
115 niro 2354 sessioncount="${#sessionlist[*]}"
116     for (( i=0; i<sessioncount; i++))
117     do
118     rvecho -n "${sessionlist[${i}]};"
119     done
120     rvecho
121     ;;
122     esac