--- alx-src/branches/alxconf-060/plugins/rdesktop/plugin.sh 2012/04/20 14:05:48 3522 +++ alx-src/branches/alxconf-060/plugins/rdesktop/plugin.sh 2012/04/23 07:30:59 3523 @@ -1,15 +1,32 @@ # this script gets included by config_sessions PLUGIN_NAME="rdesktop" -PLUGIN_MENUITEM_NAME="" -PLUGIN_MENUITEM_EXEC="" +PLUGIN_MENUITEM_NAME="${PLUGIN_NAME}" +PLUGIN_MENUITEM_EXEC="${PLUGIN_NAME}" PLUGIN_MENUITEM_PARAM="" PLUGIN_MENUITEM_WORKDIR="" PLUGIN_MENUITEM_ICON="" PLUGIN_AUTOSTART=0 - PLUGIN_PACKAGES="openssl rdesktop" +PLUGIN_CONFIG="/etc/alxconfig-ng/plugin-${PLUGIN_NAME}.conf" + +# include alx functions +source /etc/alxconfig-ng/config.rc +source /etc/alxconfig-ng/serial +source ${ALX_FUNCTIONS}/common +source ${ALX_FUNCTIONS}/mysqlfunctions +# missing colors +COLRED="\033[1;6m\033[31m" +COLDEFAULT="\033[0m" + +die() +{ + echo "Error: $@" + echo -e "${COLRED}Plugin \"${PLUGIN_NAME}\" will be disabled.${COLDEFAULT}" + [ -f ${PLUGIN_CONFIG} ] && rm ${PLUGIN_CONFIG} + exit 1 +} install_plugin() { @@ -26,24 +43,99 @@ setup_plugin() { - if [ ! -f /etc/alxconfig-ng/plugin-${PLUGIN_NAME}.conf ] + local CONFIG + local opts + + evaluate_table plugin_rdesktop + # sanitize variables + opts="" + if [[ -z ${plugin_rdesktop_session_name} ]] + then + die "session_name variable is missing" + fi + if [[ -z ${plugin_rdesktop_server} ]] + then + die "server variable is missing" + fi + if [[ -z ${plugin_rdesktop_username} ]] + then + plugin_rdesktop_username="" + else + opts+=" -u '${plugin_rdesktop_username}'" + fi + if [[ -z ${plugin_rdesktop_password} ]] + then + plugin_rdesktop_password="" + else + opts+=" -p '${plugin_rdesktop_password}'" + fi + if [[ -z ${plugin_rdesktop_domain} ]] + then + plugin_rdesktop_domain="" + else + opts+=" -d '${plugin_rdesktop_domain}'" + fi + if [[ -z ${plugin_rdesktop_resolution} ]] then - install /usr/lib/alxconfig-ng/plugins/${PLUGIN_NAME}/plugin-${PLUGIN_NAME}.conf /etc/alxconfig-ng + die "resolution is missing" + else + case ${plugin_rdesktop_resolution} in + fullscreen) opts+=" -f" ;; + seamless) opts+=" -A" ;; + *) opts+=" -g '${plugin_rdesktop_resolution}'" ;; + esac + fi + if [[ -z ${plugin_rdesktop_keyboard} ]] + then + plugin_rdesktop_keyboard="" + else + opts+=" -k '${plugin_rdesktop_keyboard}'" + fi + if [[ -z ${plugin_rdesktop_shell} ]] + then + plugin_rdesktop_shell="" + else + opts+=" -s '${plugin_rdesktop_shell}'" + fi + if [[ -z ${plugin_rdesktop_runpath} ]] + then + plugin_rdesktop_runpath="" + else + opts+=" -c '${plugin_rdesktop_runpath}'" fi - return 0 + CONFIG="${PLUGIN_CONFIG}" + clearconfig + addconfig "PLUGIN_CONFIG_SESSION_NAME=\"${plugin_rdesktop_session_name}\"" + addconfig "PLUGIN_CONFIG_SERVER=\"${plugin_rdesktop_server}\"" + addconfig "PLUGIN_CONFIG_PARAM=\"${opts}\"" } # create desktop buttons create_menuitem() { - if [ -f /etc/alxconfig-ng/plugin-rdesktop.conf ] + if [ -f ${PLUGIN_CONFIG} ] then - source /etc/alxconfig-ng/plugin-rdesktop.conf + source ${PLUGIN_CONFIG} fi [[ -z ${PLUGIN_CONFIG_PARAM} ]] && PLUGIN_CONFIG_PARAM="" [[ -z ${PLUGIN_CONFIG_SERVER} ]] && PLUGIN_CONFIG_SERVER="" + # no menuentries if egk_scm plugin is installed, this one will be used instead then + if [ -f ${SETTINGSPATH}/plugins/egk_scm ] + then + PLUGIN_MENUITEM_NAME="" + PLUGIN_MENUITEM_EXEC="" + PLUGIN_MENUITEM_PARAM="" + PLUGIN_MENUITEM_WORKDIR="" + PLUGIN_MENUITEM_ICON="" + else + if [[ ! -z ${PLUGIN_CONFIG_SESSION_NAME} ]] + then + PLUGIN_MENUITEM_NAME="${PLUGIN_CONFIG_SESSION_NAME}" + fi + fi + # don't touch these echo, define variables above echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\"" echo "PLUGIN_MENUITEM_EXEC=\"${PLUGIN_MENUITEM_EXEC}\"" @@ -54,12 +146,22 @@ autostart_plugin() { - echo "PLUGIN_AUTOSTART=\"${PLUGIN_AUTOSTART}\"" + # only autostart if plugin config was found + if [ -f ${PLUGIN_CONFIG} ] + then + evaluate_table plugin_rdesktop + fi + # sanitize variables + [[ -z ${plugin_rdesktop_autostart} ]] && plugin_rdesktop_autostart=0 + + echo "PLUGIN_AUTOSTART=\"${plugin_rdesktop_autostart}\"" echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\"" } uninstall_plugin() { + [ -f ${PLUGIN_CONFIG} ] && rm ${PLUGIN_CONFIG} + local i for i in ${PLUGIN_PACKAGES} do