#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/add-menu - add a menu entry # # Copyright (c) 2001-2005 The Eisfair Team, c/o Frank Meyer, frank(at)eisfair(dot)org # # Creation: 04.11.2001 fm # Last Update: $Id$ # # 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] menu-file sub-menu-file comment # add-menu -script 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 # # 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. #---------------------------------------------------------------------------- case "$1" in -script) shift tag="script" ;; -menu) shift tag="menu" ;; *) tag="menu" ;; esac menu_file=$1 menu_cmd=$2 shift 2 menu_text="$*" menu_path='/var/install/menu' if [ -f "$menu_path/$menu_file" ] then # new behavior if grep -q "<$tag file=\"$menu_cmd\"" $menu_path/$menu_file then exit 0 fi echo "<$tag file=\"$menu_cmd\">$menu_text" >>$menu_path/$menu_file else # old behavior if grep -q "^$menu_cmd " $menu_file then exit 0 fi echo "$menu_cmd $menu_text" >>$menu_file fi