#!/usr/bin/sh
#----------------------------------------------------------------------------
# /tmp/preinstall.sh - networkmanager preinstallation
#
# Creation   :  2025-10-10 holbru
# Last update:  $Id$
#
# Copyright (c) 2025-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net
#
# 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.
#----------------------------------------------------------------------------

# set package name
package_name=networkmanager

resolv_conf='/etc/resolv.conf'

# ---------------------------------------------------------------------------
# check
# ---------------------------------------------------------------------------
# 2025-11-15 hbfl networkmanager 3.6.0 
installed_bonding=$(eisman check bonding)
if [ "${installed_bonding}" = "installed" ]
then
    /usr/sbin/service disable bonding.service
    /usr/bin/rm -f /usr/lib/systemd/system/bonding.service
fi
installed_bridge=$(eisman check bridge)
if [ "${installed_bridge}" = "installed" ]
then
    /usr/sbin/service disable bridge.service
    /usr/bin/rm -f /usr/lib/systemd/system/bridge.service
fi
installed_dhcpc=$(eisman check dhcpc)
if [ "${installed_dhcpc}" = "installed" ]
then
    /usr/sbin/service disable dhcpc.service
    /usr/bin/rm -f /usr/lib/systemd/system/dhcpc.service
fi        
if [ -L "${resolv_conf}" ]
then
    /usr/bin/rm -f "${resolv_conf}"
    /usr/bin/touch "${resolv_conf}"
fi

path='/etc/systemd/system/multi-user.target.wants'
path2='/etc/systemd/system/network-online.target.wants'
if [ -L "${path}/ip-eth.service" ]
then 
    /usr/bin/rm "${path}/ip-eth.service"
    /usr/bin/rm -f "${path2}/ip-eth.service"
fi
if [ -L "${path}/resolver.service" ]
then
    /usr/bin/rm "${path}/resolver.service"
    /usr/bin/rm -f "${path2}/resolver.service"
fi
if [ -L "${path}/route.service" ]
then
    /usr/bin/rm "${path}/route.service"
    /usr/bin/rm -f "${path2}/route.service"
fi

if [ -L "/etc/systemd/system/resolv.service" ]
then
    /usr/bin/rm "/etc/systemd/system/resolv.service"
fi

installed=$(eisman check networkmanager 3.6.1)
if [ "${installed}" = "installed" ]
then
    > /run/networkmanager-no-restart
fi

exit 0
# ---------------------------------------------------------------------------
# end
# ---------------------------------------------------------------------------
