Magellan Linux

Diff of /alx-src/branches/alxconf-060/functions/config_sessions.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6759 by niro, Fri Jul 17 07:38:49 2015 UTC revision 7977 by niro, Thu Dec 10 09:09:40 2015 UTC
# Line 7  fix_whitespaces() Line 7  fix_whitespaces()
7   echo "${var//\ /_}"   echo "${var//\ /_}"
8  }  }
9    
10    sanitize_store()
11    {
12     local var="$@"
13     echo "$(fix_whitespaces ${var})" | sed -e 's:\::_:g' -e 's:\/:_:g' | tr '[A-Z]' '[a-z]'
14    }
15    
16  # helper function to create citrix session files  # helper function to create citrix session files
17  generate_ica_session_file()  generate_ica_session_file()
18  {  {
# Line 33  generate_ica_session_file() Line 39  generate_ica_session_file()
39   --domain) shift; ses_domain="$1" ;;   --domain) shift; ses_domain="$1" ;;
40   --server) shift; ses_browseradrs="$1" ;;   --server) shift; ses_browseradrs="$1" ;;
41   --colordepth) shift; ses_colors="$1" ;;   --colordepth) shift; ses_colors="$1" ;;
42           esac   esac
43   shift   shift
44   done   done
45    
# Line 86  generate_ica_session_file() Line 92  generate_ica_session_file()
92   addconfig 'NoWindowManager=True'   addconfig 'NoWindowManager=True'
93  }  }
94    
95    generate_storefront_sh()
96    {
97     local server
98     local ses_session
99     local ses_filename
100     local ses_username
101     local ses_domain
102     local ses_password
103     local ses_browseradrs
104     local method
105     local ses_method
106     local name
107    
108     # very basic getops
109     for i in $*
110     do
111     case $1 in
112     --session) shift; ses_session="$1" ;;
113     --filename) shift; ses_filename="$1" ;;
114     --username) shift; ses_username="$1" ;;
115     --password) shift; ses_password="$1" ;;
116     --domain) shift; ses_domain="$1" ;;
117     --server) shift; ses_browseradrs="$1" ;;
118     --method) shift; method="$1" ;;
119     esac
120     shift
121     done
122    
123     # abort if name, dest or exec not given
124     [[ -z ${ses_filename} ]] && return 1
125     [[ -z ${ses_username} ]] && return 1
126     [[ -z ${ses_password} ]] && return 1
127     [[ -z ${ses_domain} ]] && return 1
128     [[ -z ${ses_browseradrs} ]] && return 1
129    
130     case "${method}" in
131     enumerate)
132     ses_method="${method}"
133     name="store-enumerate"
134     ;;
135     launch)
136     ses_method="${method}"
137     name="${ses_session}"
138     [[ -z ${ses_session} ]] && return 1
139     ;;
140     *) echo "generate_storefront_sh(): wrong method given, either 'launch' or 'enumerate' are allowed."
141     return 1
142     ;;
143     esac
144    
145     generate_program_sh \
146     --name "${name}" \
147     --exec "storefront-resolver" \
148     --param "${method} '${ses_username}' '${ses_password}' '${ses_domain}' '${ses_session}'" \
149     --dest "${ALX_UNPRIV_HOME}/.alxprogs/$(fix_whitespaces ${ses_filename})" \
150     --environment "STORE=${ses_browseradrs}"
151    }
152    
153  # generates a sh file to start programs  # generates a sh file to start programs
154  generate_program_sh()  generate_program_sh()
155  {  {
# Line 105  generate_program_sh() Line 169  generate_program_sh()
169   --param|-p) shift; param="$1" ;;   --param|-p) shift; param="$1" ;;
170   --dest|-d) shift; dest="$1" ;;   --dest|-d) shift; dest="$1" ;;
171   --workdir|-w) shift; workdir="$1" ;;   --workdir|-w) shift; workdir="$1" ;;
172           esac   --environment|-e)  shift; environment="$1" ;;
173     esac
174   shift   shift
175   done   done
176    
# Line 116  generate_program_sh() Line 181  generate_program_sh()
181    
182   CONFIG="${dest}"   CONFIG="${dest}"
183   addconfig "#!/bin/sh"   addconfig "#!/bin/sh"
184   [ -n "${workdir}" ] && addconfig "cd ${workdir}"   [[ -n ${environment} ]] && addconfig "export ${environment}"
185     [[ -n ${workdir} ]] && addconfig "cd ${workdir}"
186   addconfig "exec ${exec} ${param}"   addconfig "exec ${exec} ${param}"
187    
188   chmod 0755 "${dest}"   chmod 0755 "${dest}"
# Line 150  generate_icon() Line 216  generate_icon()
216   --icon-width|-w) shift; iwidth="$1" ;;   --icon-width|-w) shift; iwidth="$1" ;;
217   --icon-height|-h) shift; iheight="$1" ;;   --icon-height|-h) shift; iheight="$1" ;;
218   --default-icon) shift; deficon="$1" ;;   --default-icon) shift; deficon="$1" ;;
219           esac   esac
220   shift   shift
221   done   done
222    
# Line 264  generate_all_desktop_icons() Line 330  generate_all_desktop_icons()
330    
331   generate_icon \   generate_icon \
332   --name "${cfg_sessions_session}" \   --name "${cfg_sessions_session}" \
333   --command "wfica-launcher ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \   --command "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \
334   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \   --icon "${ALX_SESSIONS_ICONS}/$(fix_whitespaces ${cfg_sessions_session}).png" \
335   --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \   --dest "${dest}/$(fix_whitespaces ${cfg_sessions_session}).lnk" \
336   --xres "${x}" \   --xres "${x}" \
# Line 438  config_sessions() Line 504  config_sessions()
504   local fbinit   local fbinit
505   local fbkeys   local fbkeys
506   local progsh_path   local progsh_path
507     local storefront_enumerate=0
508     local storefront_store
509     local _store
510     local all_storefront_stores=""
511    
512   progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"   progsh_path="${ALX_UNPRIV_HOME}/.alxprogs"
513    
# Line 481  config_sessions() Line 551  config_sessions()
551   addconfig ' [Deco] {NONE}'   addconfig ' [Deco] {NONE}'
552   addconfig '[end]'   addconfig '[end]'
553   fi   fi
554     # never show decorations with the ica client
555     addconfig '[app] (Wfica)'
556     addconfig ' [Deco] {NONE}'
557     addconfig '[end]'
558   # add icon utility   # add icon utility
559   [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'   [ -x /usr/bin/idesk ] && addconfig '[startup] {nohup idesk > /dev/null &}'
560   # add numlock utility   # add numlock utility
# Line 517  config_sessions() Line 591  config_sessions()
591   fi   fi
592   done   done
593    
  # add autostart session  
  if [[ ! -z ${cfg_autostart_session} ]]  
  then  
  # sleep one second to wait until busybox is fully initialized and the screen is really centered  
  addconfig "[startup] {sleep 1 && wfica-launcher ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_autostart_session}) &}"  
  fi  
   
594   # fluxbox hotkeys   # fluxbox hotkeys
595   if [ -f ${ALX_SKELETONS}/fluxbox/keys ]   if [ -f ${ALX_SKELETONS}/fluxbox/keys ]
596   then   then
# Line 545  config_sessions() Line 612  config_sessions()
612   # add a newline (maybe there is no crlf in the header)   # add a newline (maybe there is no crlf in the header)
613   addconfig   addconfig
614    
615     # delete all progs
616     [ -d ${progsh_path} ] && rm -rf ${progsh_path}
617     install -d ${progsh_path}
618    
619   # first generate session files   # first generate session files
620   for i in ${all_ses_ids}   for i in ${all_ses_ids}
621   do   do
622   evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"   evaluate_table cfg_sessions "where serial='${ALX_SERIAL}' and id='${i}'"
623   generate_ica_session_file \  
624   --session "${cfg_sessions_session}" \   # generate STOREFRONT/PNABROWSE compatible session
625   --filename "$(fix_whitespaces ${cfg_sessions_filename})" \   case "${cfg_sessions_browseradrs}" in
626   --username "${cfg_sessions_username}" \   "http://"*|"https://"* )
627   --password "${cfg_sessions_password}" \   # run storefront_enumerate on startup to get all available sessions
628   --domain "${cfg_sessions_domain}" \   storefront_enumerate=1
629   --server "${cfg_sessions_browseradrs}" \   storefront_store="$(sanitize_store ${cfg_sessions_browseradrs})"
630   --colordepth "${cfg_graphic_depth}"   store_found=0
631     for _store in ${all_storefront_stores}
632     do
633     if [[ ${storefront_store} = ${_store} ]]
634     then
635     store_found=1
636     fi
637     done
638     if [[ ${store_found} = 0 ]]
639     then
640     all_storefront_stores="${all_storefront_stores} ${storefront_store}"
641     generate_storefront_sh \
642     --method "enumerate" \
643     --filename "store-enumerate_${storefront_store}_.sh" \
644     --username "${cfg_sessions_username}" \
645     --password "${cfg_sessions_password}" \
646     --domain "${cfg_sessions_domain}" \
647     --server "${cfg_sessions_browseradrs}"
648     fi
649    
650     # generate STOREFRONT/PNABROWSE compatible session
651     generate_storefront_sh \
652     --method "launch" \
653     --session "${cfg_sessions_session}" \
654     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
655     --username "${cfg_sessions_username}" \
656     --password "${cfg_sessions_password}" \
657     --domain "${cfg_sessions_domain}" \
658     --server "${cfg_sessions_browseradrs}"
659     ;;
660     *)
661     # generate ICA compatible session
662     generate_ica_session_file \
663     --session "${cfg_sessions_session}" \
664     --filename "$(fix_whitespaces ${cfg_sessions_filename})" \
665     --username "${cfg_sessions_username}" \
666     --password "${cfg_sessions_password}" \
667     --domain "${cfg_sessions_domain}" \
668     --server "${cfg_sessions_browseradrs}" \
669     --colordepth "${cfg_graphic_depth}"
670     # gen prog startup wrapper
671     generate_program_sh \
672     --name "$(fix_whitespaces ${cfg_sessions_filename})" \
673     --exec "wfica-launcher" \
674     --param "${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})" \
675     --dest "${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})" \
676     "${workdir}"
677     ;;
678     esac
679    
680   # fluxbox menusession   # fluxbox menusession
681   addconfig "[exec] (${cfg_sessions_session}) {wfica-launcher ${ALX_ICA_SESSIONS}/$(fix_whitespaces ${cfg_sessions_filename})}"   addconfig "[exec] (${cfg_sessions_session}) {${progsh_path}/$(fix_whitespaces ${cfg_sessions_filename})}"
682   done   done
683     if [[ ${storefront_enumerate} = 1 ]]
684   # delete all progs   then
685   [ -d ${progsh_path} ] && rm -rf ${progsh_path}   for _store in ${all_storefront_stores}
686   install -d ${progsh_path}   do
687     CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
688     addconfig "[startup] {${progsh_path}/store-enumerate_${_store}_.sh &}"
689     done
690     fi
691    
692   # add other menuitems   # add other menuitems
693   for i in ${all_other_ids}   for i in ${all_other_ids}
# Line 590  config_sessions() Line 713  config_sessions()
713   --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \   --dest "${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})" \
714   "${workdir}"   "${workdir}"
715    
716     CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
717   addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}"   addconfig "[exec] (${cfg_other_menuitems_name}) {${progsh_path}/$(fix_whitespaces ${cfg_other_menuitems_name})} ${cfg_other_menuitems_icon}"
718   done   done
719    
# Line 624  config_sessions() Line 748  config_sessions()
748   --dest "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \   --dest "${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})" \
749   "${workdir}"   "${workdir}"
750    
751     CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
752   addconfig "[exec] (${PLUGIN_MENUITEM_NAME}) {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})} ${PLUGIN_MENUITEM_ICON}"   addconfig "[exec] (${PLUGIN_MENUITEM_NAME}) {${progsh_path}/$(fix_whitespaces ${PLUGIN_MENUITEM_NAME})} ${PLUGIN_MENUITEM_ICON}"
753   fi   fi
754    
# Line 635  config_sessions() Line 760  config_sessions()
760   unset PLUGIN_MENUITEM_ICON   unset PLUGIN_MENUITEM_ICON
761   done   done
762    
763     # add autostart session
764     if [[ ! -z ${cfg_autostart_session} ]]
765     then
766     CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/apps"
767     # sleep one second to wait until busybox is fully initialized and the screen is really centered
768     addconfig "[startup] {sleep 1 && ${progsh_path}/$(fix_whitespaces ${cfg_autostart_session}) &}"
769     fi
770    
771   # fluxbox menu footer   # fluxbox menu footer
772   cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${ALX_UNPRIV_HOME}/.fluxbox/menu   CONFIG="${ALX_UNPRIV_HOME}/.fluxbox/menu"
773     cat ${ALX_SKELETONS}/fluxbox/menu.footer >> ${CONFIG}
774   # add a newline (maybe there is no crlf in the footer)   # add a newline (maybe there is no crlf in the footer)
775   addconfig   addconfig
776    

Legend:
Removed from v.6759  
changed lines
  Added in v.7977