Magellan Linux

Annotation of /mcore-src/trunk/mcore-tools/src/modules/citrix/citrix-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: 4520 byte(s)
-load all client provides to honor is_provided()
1 niro 2272 #!/bin/bash
2    
3     MCORE_LIBDIR="@@MCORE_LIBDIR@@"
4     source @@SYSCONFDIR@@/mcore/mcore.conf
5     source ${MCORE_LIBDIR}/include/common.global.class
6 niro 2343 source ${MCORE_LIBDIR}/include/daemon.global.class
7 niro 2272
8     ICADIR="${MCORE_CONFIG_PATH}/citrix/ica"
9     ICASUFFIX="ica"
10    
11     die() { echo "ERROR: $@"; exit 1; }
12    
13 niro 2893 load_classes client
14    
15 niro 2272 # very basic getops
16     for argv in $*
17     do
18     case $1 in
19     --add|--del|--print|--query) method="${1//--}" ;;
20     --name) shift; name="$1" ;;
21     --session) shift; session="$1" ;;
22     --mode) shift; mode="$1" ;;
23     --user) shift; user="$1" ;;
24     --domain) shift; domain="$1" ;;
25     --password) shift; password="$1" ;;
26 niro 2634 --serverlist) shift; serverlist="$1" ;;
27 niro 2642 --autostart) shift; autostart="$1" ;;
28 niro 2272 esac
29     shift
30     done
31    
32     [[ -n ${method} ]] || die "No method given"
33 niro 2642 [[ -n ${autostart} ]] || autostart=0
34 niro 2272
35     case "${method}" in
36     add)
37     # requires name
38     [[ -n ${name} ]] || die "No name given"
39     # action 'add' requires mode too
40     [[ -n ${mode} ]] || die "No mode given"
41     # and session
42     [[ -n ${session} ]] || die "No session given"
43    
44     # other sanity checks
45     case "${mode}" in
46     fullscreen) ;;
47     seamless) ;;
48     *x*) ;;
49     *) die "unknown mode '${mode}'"
50     esac
51    
52 niro 2634 # add servers from serverlist
53     if [[ -n ${serverlist} ]]
54     then
55     OLD_IFS=$IFS
56     IFS=";"
57     for server in ${serverlist}
58     do
59     ${MCORE_LIBDIR}/citrix-serverlist --add --server "${server}"
60     done
61     IFS=${OLD_IFS}
62     fi
63    
64 niro 2272 icafile="${ICADIR}/${name}.${ICASUFFIX}"
65     CONFIG="${MROOT}/${icafile}"
66     clearconfig
67    
68     addconfig '[WFClient]'
69     addconfig 'Version=2'
70    
71 niro 2479 serverlist=$(NOCOLORS=1 ${MCORE_LIBDIR}/citrix-serverlist --print)
72 niro 2272 declare -i i=0
73     for server in ${serverlist}
74     do
75     (( i++ ))
76     server_num="${i}"
77     [[ ${i} -eq 1 ]] && server_num=""
78     addconfig "TcpBrowserAddress${server_num}=${server}"
79 niro 2610 addconfig "HttpBrowserAddress${server_num}=${server}"
80 niro 2272 done
81     addconfig 'ScreenPercent=0'
82     addconfig '[ApplicationServers]'
83     addconfig "${session}="
84     addconfig "[${session}]"
85     addconfig "Address=${session}"
86     addconfig "InitialProgram=#${session}"
87    
88     # mapping table xorg -> citrix
89     # citrix 1 = 16 colors
90     # citrix 2 = 256 colors
91     # citrix 4 = 16 bit
92     # citrix 8 = 32 bit
93     # try always 16 bit
94     addconfig "DesiredColor=4"
95    
96     addconfig 'TransportDriver=TCP/IP'
97     addconfig 'WinStationDriver=ICA 3.0'
98    
99     [[ -n ${user} ]] && addconfig "Username=${user}"
100     [[ -n ${domain} ]] && addconfig "Domain=${domain}"
101     [[ -n ${password} ]] && addconfig "ClearPassword=${password}"
102    
103     # use the right display settings
104     case "${mode}" in
105     # fullscreen mode
106     fullscreen)
107     addconfig 'UseFullScreen=Yes'
108     addconfig 'NoWindowManager=True'
109     addconfig "DesiredHRES=65535"
110     addconfig "DesiredVRES=65535"
111     ;;
112     # seamless window mode
113     seamless)
114     addconfig 'TWIMode=On'
115     ;;
116     # a desired resolution
117     *x*)
118     addconfig "DesiredHRES=${mode%x*}"
119     addconfig "DesiredVRES=${mode#*x}"
120     ;;
121     esac
122 niro 2319
123     if is_provided fluxbox
124     then
125     # generate fluxbox menu entry
126 niro 2639 ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${MCORE_LIBDIR}/launch-ica ${icafile}" &&
127 niro 2319 ${MCORE_LIBDIR}/fluxbox-rebuild-menu
128 niro 2642 # add autostart
129     if [[ ${autostart} = 1 ]]
130     then
131     ${MCORE_LIBDIR}/fluxbox-autostart --add --name "${name}" --exec "${MCORE_LIBDIR}/launch-ica ${icafile}" &&
132     ${MCORE_LIBDIR}/fluxbox-rebuild-autostart
133     fi
134 niro 2319 fi
135 niro 2405 if is_provided idesk
136     then
137     # generate idesk desktop icon
138 niro 2639 ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${MCORE_LIBDIR}/launch-ica ${icafile}" --icon default.png &&
139 niro 2405 ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons
140     fi
141 niro 2272 ;;
142    
143     del)
144     [[ -n ${name} ]] || die "No name given"
145     if [ -f ${MROOT}/${ICADIR}/"${name}".${ICASUFFIX} ]
146     then
147     rm ${MROOT}/${ICADIR}/"${name}".${ICASUFFIX}
148 niro 2319 if is_provided fluxbox
149     then
150     ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" &&
151     ${MCORE_LIBDIR}/fluxbox-rebuild-menu
152 niro 2642 ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" &&
153     ${MCORE_LIBDIR}/fluxbox-rebuild-autostart
154 niro 2319 fi
155 niro 2405 if is_provided idesk
156     then
157     ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" &&
158     ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons
159     fi
160 niro 2272 else
161     eecho "No configured session named '${name}' exists."
162     fi
163     ;;
164    
165     print)
166     list_files_in_directory ${MROOT}/${ICADIR}
167     ;;
168    
169     query)
170     eval sessionlist=( $(${MCORE_LIBDIR}/query-citrix-browser --session) )
171     sessioncount="${#sessionlist[*]}"
172     for (( i=0; i<sessioncount; i++))
173     do
174     rvecho -n "${sessionlist[${i}]};"
175     done
176     rvecho
177     ;;
178     esac