#!/bin/sh
#####
### Photodex CompuPic for Linux Installation Script
### Version 1.0

echo -n "Installing CompuPic for Linux..."

RUNDIR=`pwd`
PACKAGE=$RUNDIR/compupic.tar
INSTALL_DIR=/usr/local/compupic
INSTALL_BIN=/usr/local/bin
INSTALL_MAN=/usr/local/man

#### Make sure this script is being run as root
if [ "$UID" != "0" ]; then
   echo
   echo "You must be superuser to install CompuPic for Linux."
   exit
fi

#### Create $INSTALL_DIR (/usr/local/compupic)
if ! mkdir -p $INSTALL_DIR; then
   echo
   echo "Error creating directory /usr/local/compupic, exiting.."
   exit
fi

#### Unpack CompuPic into $INSTALL_DIR (/usr/local/compupic)
cd $INSTALL_DIR
if ! tar xf $PACKAGE &> /dev/null; then
   echo
   echo "Error extracting CompuPic for Linux from $PACKAGE, exiting.."
   exit
fi

#### Place compupic.1 in $INSTALL_MAN/man1 (/usr/local/man/man1)
cp -f compupic.1 $INSTALL_MAN/man1

#### Place link to $INSTALL_DIR/compupic
#### (/usr/local/compupic/compupic) in $INSTALL_BIN (/usr/local/bin)
cd $INSTALL_BIN
ln -sf $INSTALL_DIR/compupic compupic

echo "done!"
echo "Read the README file."

