#!/bin/sh
#
# Linux DGNC Post Install script.
# Should be run after make install.
#
# 1) Will be called automagically by rpm -i.
# 2) Needs to be called manually for the tar.gz install
#    by doing a "make postinstall"

echo "Running Post Install script..."

# Determine if the user's system is using UDEV.
# If they are, move our UDEV rules file into the correct place.
if [ -d /etc/udev ]
then
	cp -f /etc/dgnc/10-dgnc.rules /etc/udev/rules.d/10-dgnc.rules
fi

# Make any wanted symlinks

# The dgdn DPA is too different to become the default "dpa",
# so we do NOT create a symlink here for it.


if [ ! -e /usr/bin/ditty ]
then
	ln -s /usr/bin/ditty.dgnc /usr/bin/ditty
fi

if [ ! -e /usr/bin/dinc ]
then
	ln -s /usr/bin/dinc.dgnc /usr/bin/dinc
fi         

if [ ! -e /usr/bin/dgncview ]
then
	ln -s /etc/dgnc/dgnc_view /usr/bin/dgncview
fi

if [ ! -e /usr/bin/dgnctest ]
then
	ln -s /etc/dgnc/dgnctest /usr/bin/dgnctest
fi

# Add the driver to the modules conf file
if [ -f /etc/modules.conf ]
then
	printf "Adding dgnc module to /etc/modules.conf file...\n"
	echo "keep # dgnc" >> /etc/modules.conf   
	echo "path[dgnc]=/lib/modules/`uname -r`/misc # dgnc" >> /etc/modules.conf   
	echo "post-install dgnc /usr/sbin/dgnc_updatedevs # dgnc" >> /etc/modules.conf
fi  

# Finally, force dependency checks
if [ -e /sbin/depmod ]
then
	/sbin/depmod -a
fi

printf "\n\n     **********************************************************************\n"
if [ -d /etc/rc.d/init.d ]
then
	printf "     * Please run \"/etc/rc.d/init.d/dgnc start\" to start the dgnc driver. *\n"
else
	printf "     *    Please run \"/etc/init.d/dgnc start\" to start the dgnc driver.   *\n"
fi
printf "     **********************************************************************\n\n\n"
