#!/bin/sh
#------------------------------------------------------------------------------
# /var/install/bin/pre-setup-services-subversion-module-menu
#
# Creation   :  2018-07-11 daniel
# Last Update:  2023-07-23 09:11:10
#
# Copyright (c) 2025 the eisfair team, team(at)eisfair(dot)org
#
# 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.
#------------------------------------------------------------------------------

# create the module file for subversion
# that was found in the menu-root from the system

menu_file=$(ls /var/install/menu/setup.services.subversion.module.*.menu | \
            awk -F. '{print($1"."$2"."$3"."$4"."$5"."$NF)}' | uniq)

{
    echo "<!-- Creation:     2007-04-28  dv-->"
    echo "<package>subversion</package>"
    echo "<title>subversion module administration</title>"
    for menu in ${menu_file}
    do
        package_entry="$(grep "package" ${menu} | sed 's#</*package>##g')"
        menu_entry="$(grep "title" ${menu} | sed 's#</*title>##g')"

        echo "<menu file=\"setup.services.subversion.module.${package_entry}.menu\">${menu_entry}</menu>"
    done
} > /var/install/menu/setup.services.subversion.module.menu

exit 0