Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2642 - (hide annotations) (download)
Thu Oct 8 10:23:56 2015 UTC (8 years, 7 months ago) by niro
File size: 3274 byte(s)
-added autostart option
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 niro 2395 [[ ${counter} -gt 0 ]] && echo "${line}" | cut -d"'" -f1-3
20 niro 2393 ((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 niro 2603 --store) shift; store="$1" ;;
35 niro 2642 --autostart) shift; autostart="$1" ;;
36 niro 2354 esac
37     shift
38     done
39    
40 niro 2383 [[ -n ${method} ]] || die "No method given"
41 niro 2642 [[ -n ${autostart} ]] || autostart=0
42 niro 2354
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 niro 2593 # add store and regen user xml
51 niro 2603 if [[ -n ${store} ]]
52 niro 2593 then
53 niro 2603 ${MCORE_LIBDIR}/storefront-store --add --store "${store}"
54 niro 2593 ${MCORE_LIBDIR}/storefront-store --regen
55     fi
56    
57 niro 2354 storefront_starter="${STOREFRONTDIR}/${name}.sh"
58     CONFIG="${MROOT}/${storefront_starter}"
59     clearconfig
60    
61     addconfig '#!/bin/bash'
62 niro 2603 addconfig "${MCORE_LIBDIR}/storefront-resolver --launch --user '${user}' --password '${password}' --domain '${domain}' --app '${session}' --store '${store}'"
63 niro 2381 chmod +x "${storefront_starter}"
64 niro 2354
65     if is_provided fluxbox
66     then
67     # generate fluxbox menu entry
68 niro 2381 ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${storefront_starter}" &&
69 niro 2354 ${MCORE_LIBDIR}/fluxbox-rebuild-menu
70 niro 2642 # 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 niro 2354 fi
77 niro 2381 if is_provided idesk
78     then
79     # generate idesk desktop icon
80 niro 2388 ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${storefront_starter}" --icon default.png &&
81 niro 2381 ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons
82     fi
83 niro 2354 ;;
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 niro 2642 ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" &&
95     ${MCORE_LIBDIR}/fluxbox-rebuild-autostart
96 niro 2354 fi
97 niro 2381 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 niro 2354 else
103     eecho "No configured session named '${name}' exists."
104     fi
105     ;;
106    
107     print)
108 niro 2394 list_files_in_directory ${MROOT}/${STOREFRONTDIR} | sed 's:\.sh::g'
109 niro 2354 ;;
110    
111     query)
112 niro 2393 eval sessionlist=( $(print_storefront_session_list) )
113 niro 2354 sessioncount="${#sessionlist[*]}"
114     for (( i=0; i<sessioncount; i++))
115     do
116     rvecho -n "${sessionlist[${i}]};"
117     done
118     rvecho
119     ;;
120     esac