#! /bin/sh

# change cdrecord default
fcopy -Mi /etc/default/cdrecord
# set cdrecord to suid 
[ -f $target/usr/bin/cdrecord ] && chmod u+s $target/usr/bin/cdrecord

# install mozilla plugins
ifclass LINUX && ifclass CS_KOELN && ftar /usr/lib/mozilla
# only used for acroread5
ifclass USR_LOCAL_MOUNT || ftar /usr/local

# for our local installation we copy a backuped ssh_key
if [ -d $target/files/scratch/${HOSTNAME}-backup/etc/ssh ]; then
    cp -p $target/files/scratch/${HOSTNAME}-backup/etc/ssh/ssh_host* $target/etc/ssh
fi
fcopy -i /etc/ssh/ssh_known_hosts

ifclass DATALESS && ftar /etc/alternatives

# if TeX/LaTeX is installed build german hyphenation
if $ROOTCMD dpkg -l |grep -q tetex-bin ; then
    echo "Creating german hyphenation for TeX/LaTeX"
    cat > $target/tmp/mkgermantex.sh <<EOF
cd /tmp
echo "\input hyphen.cfg" > hyphen.tex
initex /usr/share/texmf/tex/plain/config/tex.ini
cp /var/lib/texmf/web2c/tex.fmt /var/lib/texmf/web2c/tex.fmt.old
cp tex.fmt /var/lib/texmf/web2c
initex /usr/share/texmf/tex/latex/base/latex.ltx
cp latex.fmt /var/lib/texmf/web2c
EOF
    chmod u+x $target/tmp/mkgermantex.sh
    $ROOTCMD /tmp/mkgermantex.sh
fi

if [ -n "$hdparm" ]; then
    cat > $target/etc/init.d/hdparm <<-EOF
	#! /bin/sh
	# added by FAI
	# tune my harddisks
	$hdparm
EOF
    chmod a+rx $target/etc/init.d/hdparm
    ln -s ../init.d/hdparm $target/etc/rcS.d/S61hdparm
fi

ifclass USR_LOCAL_COPY && {
    # you have to mount /usr/local
    # mount -o ro $bserver:/usr/local /usr/local
    cp -a /usr/local $target/usr
}

ifclass USR_LOCAL_RSYNC && {
    echo "Syncing /usr/local via $LOGUSER@$bserver"
    vopt=
    [ "$verbose" ] && vopt=-v
    rsync $vopt --delete -a $LOGUSER@$bserver:/usr/local/ $target/usr/local/
}
