--- alx-src/branches/alxconf-060/functions/config_sessions.sh 2011/05/17 11:47:17 2149 +++ alx-src/branches/alxconf-060/functions/config_sessions.sh 2011/05/18 14:35:13 2161 @@ -1,6 +1,12 @@ # $Id$ # configures ica-sessions on the host via mysql db settings +fix_whitespaces() +{ + local var="$@" + echo "${var//\ /_}" +} + # helper function to create citrix session files generate_ica_session_file() { @@ -24,15 +30,15 @@ --username) shift; ses_username="$1" ;; --password) shift; ses_password="$1" ;; --domain) shift; ses_domain="$1" ;; - --server) ses_browseradrs="$1" ;; + --server) shift; ses_browseradrs="$1" ;; esac shift done # abort if session, filename or server not given - [[ -z ${session} ]] && return 1 - [[ -z ${file} ]] && return 1 - [[ -z ${server} ]] && return 1 + [[ -z ${ses_session} ]] && return 1 + [[ -z ${ses_filename} ]] && return 1 + [[ -z ${ses_browseradrs} ]] && return 1 # write session files CONFIG="${ALX_ICA_SESSIONS}/${ses_filename}" @@ -74,6 +80,7 @@ local dest local name local exec + local param local workdir local CONFIG @@ -83,6 +90,7 @@ case $1 in --name|-n) shift; name="$1" ;; --exec|-x) shift; exec="$1" ;; + --param|-p) shift; param="$1" ;; --dest|-d) shift; dest="$1" ;; --workdir|-w) shift; workdir="$1" ;; esac @@ -97,7 +105,7 @@ CONFIG="${dest}" addconfig "#!/bin/sh" [ -n "${workdir}" ] && addconfig "cd ${workdir}" - addconfig "exec ${exec}" + addconfig "exec ${exec} ${param}" chmod 0755 "${dest}" } @@ -150,7 +158,7 @@ icon="${ALX_SESSIONS_ICONS}/${deficon}" fi - CONFIG=${dest} + CONFIG="${dest}" clearconfig addconfig 'table Icon' @@ -180,12 +188,12 @@ local yres local x local y - local item + local i local name local progsh_path # progsh path - progsh_path=${ALX_UNPRIV_HOME}/.alxprogs + progsh_path="${ALX_UNPRIV_HOME}/.alxprogs" # get the resolution res=$(mysqldo "select resolution from cfg_graphic where serial='${ALX_SERIAL}'") @@ -211,10 +219,13 @@ declare -i y=30 # ica icons - for item in ${session_list} + for i in ${session_list} do # abort if empty - [[ -z ${item} ]] && continue + [[ -z ${i} ]] && continue + + # get database information + evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" # new line if x > xres if [ ${x} -ge ${xres} ] @@ -233,22 +244,24 @@ [ ${x} -ge ${xres} ] && x=30 fi - name="$(basename ${item} .ica)" generate_icon \ - --name "${name}" \ - --command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/${item}" \ - --icon "${ALX_SESSIONS_ICONS}/${name}.png" \ - --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${name}.lnk" \ + --name "${cfg_session_session}" \ + --command "nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_session_filename})" \ + --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_session_session}).png" \ + --dest "${ALX_UNPRIV_HOME}/.xtdesktop/$(fix_whitespaces ${cfg_session_session}).lnk" \ --xres "${x}" \ --yres "${y}" y=$((${y} + 80)) done - for item in ${other_menuitem_list} + for i in ${other_menuitem_list} do # abort if empty - [[ -z ${item} ]] && continue + [[ -z ${i} ]] && continue + + # get database information + evaluate_table cfg_other_menuitems "where serial='${ALX_SERIAL}' and id='${i}'" # new line if x > xres if [ ${x} -ge ${xres} ] @@ -268,10 +281,10 @@ fi generate_icon \ - --name "${item}" \ - --command "${progsh_path}/${item}" \ - --icon "${ALX_SESSIONS_ICONS}/${item}.png" \ - --dest "${ALX_UNPRIV_HOME}/.xtdesktop/${item}.lnk" \ + --name "${cfg_other_menuitems_name}" \ + --command "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_exec})" \ + --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_other_menuitems_name}).png" \ + --dest "${ALX_UNPRIV_HOME}/.xtdesktop/$(fix_whitespaces ${cfg_other_menuitems_name}).lnk" \ --xres "${x}" \ --yres "${y}" \ --default-icon "default_item.png" @@ -315,8 +328,6 @@ local all_other_ids local CONFIG local screensaver_passwd_cmd - local all_sessions - local all_other_menuitems # get all session ids from database all_ses_ids=$(mysqldo "select id from cfg_sessions where serial='${ALX_SERIAL}'") @@ -359,14 +370,14 @@ # add autostart session if [[ ! -z ${cfg_autostart_session} ]] then - addconfig "[startup] {nohup nice -n 19 wfica ${ALX_ICA_SESSIONS}/${cfg_autostart_session} &}" + addconfig "[startup] {nohup nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_autostart_session}) &}" fi # fluxbox hotkeys cat ${ALX_SKELETONS}/fluxbox/keys > ${ALX_UNPRIV_HOME}/.fluxbox/keys # generate a fluxbox menu - CONFIG=${ALX_UNPRIV_HOME}/.fluxbox/menu + CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu" clearconfig # fluxbox menu header @@ -383,17 +394,14 @@ evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'" generate_ica_session_file \ --session "${cfg_sessions_session}" \ - --filename "${cfg_sessions_filename}" \ + --filename "$(fix_whitespaces ${cfg_sessions_filename})" \ --username "${cfg_sessions_username}" \ --password "${cfg_sessions_password}" \ --domain "${cfg_sessions_domain}" \ --server "${cfg_sessions_browseradrs}" # fluxbox menusession - addconfig "[exec] (${cfg_sessions_session}) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/${cfg_sessions_filename}}" - - # add to all_sessions variable to create icons later for these - all_sessions="${all_sessions} ${cfg_sessions_filename}" + addconfig "[exec] (${cfg_sessions_session}) {nice -n 19 wfica ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})}" done # delete all progs @@ -421,13 +429,11 @@ generate_program_sh \ --name "${cfg_other_menuitems_name}" \ --exec "${cfg_other_menuitems_exec}" \ - --dest "${progsh_path}/${cfg_other_menuitems_name}" \ - "${cfg_other_menuitems_workdir}" - - addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/${cfg_other_menuitems_name}} ${cfg_other_menuitems_icon}" + --param "${cfg_other_menuitems_param}" \ + --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \ + "${workdir}" - # add to all_other_menuitems variable to create icons later for these - all_other_menuitems="${all_other_menuitems} ${cfg_other_menuitems_name}" + addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}" done # fluxbox menu footer @@ -436,7 +442,7 @@ addconfig # now it's a good time to generate *all* icons :) - generate_all_desktop_icons "${all_sessions}" "${all_other_menuitems}" + generate_all_desktop_icons "${all_ses_ids}" "${all_other_ids}" # fix permissions chown ${ALX_UNPRIV_USER}:${ALX_UNPRIV_GROUP} ${ALX_UNPRIV_HOME}