# Install script for Capacisense package

if [ -r install/slack-desc ] ; then
chroot . << EOF

fgrep -v /usr/bin/CSrun /etc/rc.d/rc.local | fgrep -v Capacisense > /tmp/rc.local
cp /tmp/rc.local /etc/rc.d/rc.local
rm -f /tmp/rc.local
rm -f /lib/modules/*/extra/pci17?4*
rm -f /???/udev/rules.d/90-advpci*17?4*
rm -f /usr/bin/CSdemo*
rm -f /var/lib/cpm/win32/CSdemo*
rm -f /var/lib/cpm/win32/CS*server*
rm -rf /usr/src/modules/pci17[14]4

make -C /usr/src/modules/pci17x4 install
make -C /usr/src/modules/pci17x4 clean

depmod -a

CSrunning="$(ps -C CSserver --no-header)"
CSdebug="$(ps -C CSserverd --no-header)"

if [ "$CSrunning$CSdebug" != "" ] ; then
  /etc/init.d/CSserver.sh stop
fi
/sbin/rmmod pci1714
/sbin/rmmod pci1744
/sbin/rmmod pci17x4
/sbin/modprobe pci1714
/sbin/modprobe pci1744
if [ "$CSrunning" != "" ] ; then
  /etc/init.d/CSserver.sh start
elif [ "$CSdebug" != "" ] ; then
  /etc/init.d/CSserver.sh debug
fi

EOF
fi >/dev/null 2>/dev/null

# Additional, 'makepkg' generated stuff will come here...

( cd etc/rc3.d ; rm -rf K99CSserver )
( cd etc/rc3.d ; ln -sf ../init.d/CSserver.sh K99CSserver )
( cd etc/rc3.d ; rm -rf S99CSserver )
( cd etc/rc3.d ; ln -sf ../init.d/CSserver.sh S99CSserver )
( cd etc/rc4.d ; rm -rf K99CSserver )
( cd etc/rc4.d ; ln -sf ../init.d/CSserver.sh K99CSserver )
( cd etc/rc4.d ; rm -rf S99CSserver )
( cd etc/rc4.d ; ln -sf ../init.d/CSserver.sh S99CSserver )
