#!/bin/bash MCORE_LIBDIR="@@MCORE_LIBDIR@@" source @@SYSCONFDIR@@/mcore/mcore.conf source ${MCORE_LIBDIR}/include/common.global.class source ${MCORE_LIBDIR}/include/daemon.global.class RDESKTOP_SESSIONDIR="${MCORE_CONFIG_PATH}/rdesktop/sessions" RDESKTOP_CONFIGDIR="${MCORE_CONFIG_PATH}/rdesktop/config.d" die() { echo "ERROR: $@"; exit 1; } # very basic getops for argv in $* do case $1 in --add|--del|--print) method="${1//--}" ;; --name) shift; name="$1" ;; --server) shift; server="$1" ;; --mode) shift; mode="$1" ;; --user) shift; user="$1" ;; --domain) shift; domain="$1" ;; --password) shift; password="$1" ;; --shell) shift; shell="$1" ;; --autostart) shift; autostart="$1" ;; --keymap) shift; keymap="$1" ;; esac shift done cmdline="" [[ -n ${method} ]] || die "No method given" [[ -n ${autostart} ]] || autostart=0 [[ -n ${keymap} ]] || keymap="de" [[ ${shell} = NULL ]] && shell="" [[ ${user} = NULL ]] && user="" [[ ${domain} = NULL ]] && domain="" [[ ${password} = NULL ]] && password="" [[ -d ${RDESKTOP_SESSIONDIR} ]] || install -d ${RDESKTOP_SESSIONDIR} [[ -d ${RDESKTOP_CONFIGDIR} ]] || install -d ${RDESKTOP_CONFIGDIR} case "${method}" in add) # requires name [[ -n ${name} ]] || die "No name given" # and session [[ -n ${server} ]] || die "No server given" # other sanity checks case "${mode}" in fullscreen) cmdline+=" -f" ;; *x*) cmdline+=" -g '${mode}'" ;; *) die "unknown mode '${mode}'" esac # optional [[ -n ${user} ]] && cmdline+=" -u '${user}'" [[ -n ${password} ]] && cmdline+=" -p '${password}'" [[ -n ${domain} ]] && cmdline+=" -d '${domain}'" [[ -n ${shell} ]] && cmdline+=" -s '${shell}'" [[ -n ${keymap} ]] && cmdline+=" -k '${keymap}'" # load all global_options global_options="" for conf in $(find ${RDESKTOP_CONFIGDIR} -name \*.conf) do if [[ -f ${conf} ]] then decho "including options from '${conf}'" source ${conf} fi done decho "global_options='${global_options}'" [[ -n ${global_options} ]] && cmdline+=" ${global_options}" rdesktop_starter="${RDESKTOP_SESSIONDIR}/${name}.sh" CONFIG="${MROOT}/${rdesktop_starter}" clearconfig addconfig '#!/bin/bash' addconfig "rdesktop ${cmdline} '${server}'" chmod +x "${rdesktop_starter}" if is_provided fluxbox then # generate fluxbox menu entry ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${rdesktop_starter}" && ${MCORE_LIBDIR}/fluxbox-rebuild-menu # add autostart if [[ ${autostart} = 1 ]] then ${MCORE_LIBDIR}/fluxbox-autostart --add --name "${name}" --exec "${rdesktop_starter}" && ${MCORE_LIBDIR}/fluxbox-rebuild-autostart fi fi if is_provided idesk then # generate idesk desktop icon ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${rdesktop_starter}" --icon rdp.png && ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons fi ;; del) [[ -n ${name} ]] || die "No name given" if [ -f ${MROOT}/${RDESKTOP_SESSIONDIR}/"${name}".sh ] then rm ${MROOT}/${RDESKTOP_SESSIONDIR}/"${name}".sh if is_provided fluxbox then ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && ${MCORE_LIBDIR}/fluxbox-rebuild-menu ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" && ${MCORE_LIBDIR}/fluxbox-rebuild-autostart fi if is_provided idesk then ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" && ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons fi else eecho "No configured session named '${name}' exists." fi ;; print) list_files_in_directory ${MROOT}/${RDESKTOP_SESSIONDIR} | sed 's:\.sh::g' ;; esac