#! /bin/sh

fcopy -i /etc/hosts.equiv /etc/hosts.allow /etc/hosts.deny

if ifclass DHCPC; then

    cat > $target/etc/network/interfaces <<-EOF
# generated by FAI
auto lo eth0
iface lo inet loopback
iface eth0 inet dhcp
EOF
    
else

    cat > $target/etc/network/interfaces <<-EOF
# generated by FAI
auto lo eth0
iface lo inet loopback
iface eth0 inet static
address $IPADDR
netmask $NETMASK
broadcast $BROADCAST
gateway $GATEWAYS
EOF
    echo "localnet $NETWORK" > $target/etc/networks

    [ -s /tmp/etc/resolv.conf ] && cp -p /tmp/etc/resolv.conf $target/etc
    fcopy -i /etc/resolv.conf
fi
# here fcopy is mostly used, when installing a client for running in a
# different subnet than during the installation  
fcopy -iM /etc/network/interfaces /etc/hosts /etc/networks

ifclass NTP && {
cat > $target/etc/ntp.conf <<-EOF
	logfile /var/log/ntpd
	driftfile /var/lib/ntp/ntp.drift
	#broadcastclient yes
EOF
for s in $NTPSRVS; do
    echo "server $s" >> $target/etc/ntp.conf
done
}

fcopy -i /etc/printcap
ifclass NISLPRCLIENT && $ROOTCMD checkpc -f
ifclass NISLPRCLIENT || for p in $printers; do
    mkdir -p $target/var/spool/lpd/$p
    chown lp:lp $target/var/spool/lpd/$p
    chmod 775 $target/var/spool/lpd/$p
done

fcopy -i /etc/bootptab
