# Created by Tobias Powalowski <tpowa@archlinux.org>

install ()
{
    MODULES=" $(checked_modules "/drivers/net/" | grep -ve "wireless") "
    # add staging modules
    STAGING="et131x"
    for i in $STAGING; do
        MODULES="$MODULES $(checked_modules "/drivers/staging/$i")"
    done
    BINARIES="ping ping6 route nslookup telnet ssh arpd ctstat genl ifcfg ifstat ip lnstat nstat routef routel rtacct rtmon rtpr rtstat ss tc dhclient ifplugd ifplugstatus"
    FILES=""
    SCRIPT=""
    add_file "/sbin/dhcpcd"
    add_file "/sbin/ifenslave"
    add_file "/usr/sbin/brctl"
    add_file "/etc/rc.d/network"
    add_file "/usr/share/archboot/net/etc/conf.d/dhcpcd" "/etc/conf.d/dhcpcd"
    add_file "/usr/share/archboot/net/etc/conf.d/bonding" "/etc/conf.d/bonding"
    add_file "/usr/share/archboot/net/etc/conf.d/bridges" "/etc/conf.d/bridges"
    for i in $(find /usr/lib/dhcpcd -type f); do
        add_file "$i"
    done
    add_file "/usr/share/archboot/net/etc/dhcpcd.conf" "/etc/dhcpcd.conf"
    add_dir "/var/lib/dhcpcd"
    add_file "/usr/lib/tc/q_atm.so"
    add_file "/usr/share/tc/experimental.dist"
    add_file "/usr/share/tc/normal.dist"
    add_file "/usr/share/tc/pareto.dist"
    add_file "/usr/share/tc/paretonormal.dist"
    add_file "/usr/share/archboot/net/etc/iproute2/ematch_map" "/etc/iproute2/ematch_map"
    add_file "/usr/share/archboot/net/etc/iproute2/rt_dsfield" "/etc/iproute2/rt_dsfield"
    add_file "/usr/share/archboot/net/etc/iproute2/rt_protos" "/etc/iproute2/rt_protos"
    add_file "/usr/share/archboot/net/etc/iproute2/rt_realms" "/etc/iproute2/rt_realms"
    add_file "/usr/share/archboot/net/etc/iproute2/rt_scopes" "/etc/iproute2/rt_scopes"
    add_file "/usr/share/archboot/net/etc/iproute2/rt_tables" "/etc/iproute2/rt_tables"
    # add dhclient support
    add_file "/sbin/dhclient-script"
    add_dir "/var/lib/dhclient"
    add_dir "/var/state/dhcp"
    # add ifplugd support
    add_file "/etc/rc.d/ifplugd"
    add_file "/etc/ifplugd/ifplugd.action"
    add_file "/usr/share/archboot/net/etc/ifplugd/ifplugd.conf" "/etc/ifplugd/ifplugd.conf"
    # fixing licenses
    add_file "/usr/share/licenses/db/LICENSE"
    add_file "/usr/share/licenses/dhcpcd/LICENSE"
    add_file "/usr/share/licenses/dhclient/LICENSE"
    add_file "/usr/share/licenses/dnsutils/LICENSE"
    add_file "/usr/share/licenses/heimdal/LICENSE"
    add_file "/usr/share/licenses/openssh/LICENCE"
    add_file "/usr/share/licenses/openssl/LICENSE"
    add_file "/usr/share/licenses/sqlite3/license.txt"
    add_file "/usr/share/licenses/tcp_wrappers/license.txt"
}

help ()
{
cat<<HELPEOF
  This hook includes the network on an arch boot image.
HELPEOF
}
