#!/bin/tcsh

set installdir="/usr/sbin"
echo -n "installing procfg in $installdir... "
cp procfg $installdir || echo "failed" && exit 1
echo "OK"

set man_cfg=/etc/man.confg
set man_type=man1
set dirlist=`[ -e $man_cfg ] && grep -e "^MANPATH[^_]" $man_cfg | awk '{print $2}'`
if ("$dirlist" == "") then
    set dirlist="/usr/share/man /usr/man"
endif
# prune the list down to only values that exist
foreach dir ($dirlist)
    [ -e $dir/$man_type ] && set man_path = $dir && break
end
if ("$man_path" == "") then
    set man_path = /usr/man
endif
set man_path = $man_path/$man_type

echo -n "installing procfg man page (procfg.1) in $man_path..."gzip procfg.1
rm -f $man_path/procfg.1
cp procfg.1.gz $man_path || echo "failed" && exit 1
echo "OK"

# documentation installation
set docdir="/usr/share/doc/procfg-"1.3.12""
mkdir -p $docdir
echo -n "installing documentation in $docdir..."
cp README LICENSE* ldistrib.txt $docdir || echo "failed" && exit 1
echo "OK"
