Magellan Linux

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