# this script gets called by config_sessions PLUGIN_NAME="remserial" # all empty - do not create any menuitems PLUGIN_MENUITEM_NAME="" PLUGIN_MENUITEM_EXEC="" PLUGIN_MENUITEM_PARAM="" PLUGIN_MENUITEM_WORKDIR="" PLUGIN_MENUITEM_ICON="" PLUGIN_AUTOSTART=0 # 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}" # disable the service rc-config del remserial > /dev/null exit 1 } install_plugin() { if [[ -z $(magequery -n remserial) ]] then MAGE_BOOTSTRAP=true mage install remserial mage clean fi } setup_plugin() { local CONFIG # first of all get the vars evaluate_table plugin_remserial # sanitize variables [[ -z ${plugin_remserial_remote_host} ]] && die "remote_host variable is empty" [[ -z ${plugin_remserial_remote_port} ]] && die "remote_port variable is empty" [[ -z ${plugin_remserial_stty_opts} ]] && die "stty_opts variable is empty" [[ -z ${plugin_remserial_device} ]] && die "device variable is empty" # thats ok [[ -z ${plugin_remserial_extra_opts} ]] && plugin_remserial_extra_opts="" # setup config [[ ! -d /etc/conf.d ]] && install /etc/conf.d CONFIG="/etc/conf.d/remserial" clearconfig addconfig "REMOTE_HOST=\"${plugin_remserial_remote_host}\"" addconfig "REMOTE_PORT=\"${plugin_remserial_remote_port}\"" addconfig "STTY_OPTS=\"${plugin_remserial_stty_opts}\"" addconfig "DEVICE=\"${plugin_remserial_device}\"" addconfig "EXTRA_OPTS=\"${plugin_remserial_extra_opts}\"" # add to runlevels rc-config add remserial > /dev/null } # create desktop buttons create_menuitem() { # 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_MENUITEM_PARAM}\"" echo "PLUGIN_MENUITEM_WORKDIR=\"${PLUGIN_MENUITEM_WORKDIR}\"" echo "PLUGIN_MENUITEM_ICON=\"${PLUGIN_MENUITEM_ICON}\"" } autostart_plugin() { echo "PLUGIN_AUTOSTART=\"${PLUGIN_AUTOSTART}\"" echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\"" } uninstall_plugin() { # remove from runlevels rc-config del remserial if [[ -n $(magequery -n remserial) ]] then MAGE_BOOTSTRAP=true mage uninstall remserial mage clean fi # remove config files if [[ -f /etc/conf.d/remserial ]] then rm -f /etc/conf.d/remserial fi } 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