#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/add-menu - add a menu entry / modify a menu entry # # Creation: 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # Usage: # # old style version (for non XML-menus) # ------------------------------------- # # add-menu menu-file shell-script comment # # menu-file absolute filename of menu-file # # The new entry # shell-script comment # is added to the end of the menu-file # if such a line does not already exist. # # shell-script absolute filename of a shell-script # # This shell-scripts is called e.g. to # display a new menu. # # comment comment to display in the menu # # new style version (for XML-menus) # --------------------------------- # # add-menu [--menu] [opt-parameter] menu-file sub-menu-file comment # add-menu --script [opt-parameter] menu-file script-file comment # # --menu add -Tag [default] # --script add # is added to the end of the menu-file # if such a line does not already exist. # # comment text to display in the menu # # menu-file and sub-menu-file/script-file and comment have to be # the last parameters. # # Additional description: # A menu file (example.menu) containing the following lines # # Handling for mainpackage configuration # Handling for subpackage configuration # is a valid menu. # # To create the two menu lines use # add-menu example.menu sub.menu 'Handling for mainpackage configuration' # add-menu --package subpackage example.menu sub.menu 'Handling for subpackage configuration' # # To modify the two menu lines use # add-menu example.menu sub.menu 'New handling for mainpackage configuration' # add-menu --package subpackage example.menu sub.menu 'Advanced handling for subpackage configuration' # # The optional parameter --package becomes mandatory to identify # the correct line. # # Result: # New handling for mainpackage configuration # Advanced handling for subpackage configuration # # Using --pre pre-skript and/or --post post-script you can add lines # containg pre="pre-skript" post="post-script" arguments. # These values can be modified by a following add-menu call. # To modify package="xxx" arguments or add a package="xxx" argument # you have to delete the line using del-line an add it with the # --package package argument or the initial --package package argument # using add-menu. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib etc . /var/install/include/eislib XMLSPLIT='/usr/bin/xmlsplit' SED='/usr/bin/sed' GREP='/usr/bin/grep' pre_script_attr='' post_script_attr='' package_attr='' tag='menu' xml_tag='MENU' # used by xmlsplit menu_path='/var/install/menu' bin_path='/var/install/bin' #debug=true if ${debug:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi # --------------------------------------------------------------------------- # work # --------------------------------------------------------------------------- work() { if [ -f "${menu_path}/${menu_file}" ] then # new behavior XML-Menu # build new line new_line="<${tag} ${package_attr}${pre_script_attr}${post_script_attr}file=\"${menu_cmd}\">${menu_text}" # grep old lines old_line=$(${GREP} " file=\"${menu_cmd}\"" ${menu_path}/${menu_file}) # extract correct line if