# this script gets included by config_sessions PLUGIN_NAME="rdesktop" 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 alsa-lib 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() { local i for i in ${PLUGIN_PACKAGES} do if [[ -z $(magequery -n ${i}) ]] then MAGE_BOOTSTRAP=true mage install ${i} mage clean fi done } setup_plugin() { 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 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 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 ${PLUGIN_CONFIG} ] then 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}\"" echo "PLUGIN_MENUITEM_PARAM=\"${PLUGIN_CONFIG_PARAM} ${PLUGIN_MENUITEM_PARAM} ${PLUGIN_CONFIG_SERVER}\"" echo "PLUGIN_MENUITEM_WORKDIR=\"${PLUGIN_MENUITEM_WORKDIR}\"" echo "PLUGIN_MENUITEM_ICON=\"${PLUGIN_MENUITEM_ICON}\"" } autostart_plugin() { # 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 if [[ -n $(magequery -n ${i}) ]] then MAGE_BOOTSTRAP=true mage uninstall ${i} mage clean fi done mage clean } case $1 in install) install_plugin ;; setup) setup_plugin ;; menuitem) create_menuitem ;; uninstall) uninstall_plugin ;; autostart) autostart_plugin ;; *) echo "PLUGIN '${PLUGIN_NAME}': unkown operation '$1'" ;; esac