#!/bin/sh
#Functions for the afribin install checker
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/afribin"
export PATH
LANG=C
export LANG

OS=`uname -s`
export OS

case "$OS" in
   FreeBSD)
      #echo "Running FreeBSD"
      UNIX=1 ; export UNIX
      FREEBSD=1 ; export FREEBSD
      SRCDIR="$HOME/src"
   ;;
   Linux)
      #echo "Running Linux"
      UNIX=1 ; export UNIX
      LINUX=1 ; export LINUX
      SRCDIR="/usr/src/afribin"   
   ;;
   CYGWIN_NT*)
      #echo "Running under windows"
      MSWIN=1 ; export MSWIN
   ;;
   *)
        echo "Unknown OS cannot continue"
        exit 1
   ;;
esac

if [ -d /var/cpanel/users ] ; then
   CPANELSERVER=1 ; export CPANELSERVER
fi


cpondiff() {
   #Will only copy file if it has changed
   # $1 src
   # $2 dest
   # $3 Comment if successfull
   diff "$1" "$2" > /dev/null 2> /dev/null
   if [ $? -gt 0 ] ; then #Files not the same
      echo $3
      case "$OS" in
         FreeBSD)
            echo "cp -Rp $1 $2"
            cp -Rp $1 $2
         ;;
         Linux)
            cp -a $1 $2
         ;;
         *)
            echo "Don't know how to copy '$1' to '$2'"
         ;;
      esac
      return 1
   fi
  return 0
}

lnondiff() {
    # Will only link file/directory if it does not exist
    # $1 src
    # $2 dest
    # $3 Comment if successfull
    if [ -e $2 ] ; then #Link already exists
        return 0
    fi
    echo $3
    ln -s $1 $2
    return 1
}


