#!/bin/sh
#
#PGP 5.0 Binary install script.
#
# By Brett A. Thomas <quark@baz.com>, <bat@pgp.com>
#
# Apologies if the mkdir -p is non-portable; if so, it will be fixed
# in the near future.
#
#Copyright (C) 1997 Pretty Good Privacy, Inc.  All rights reserved.
#
# $Id: pgpinst,v 1.1.2.1 1997/07/02 11:15:19 quark Exp $

#Default binary destination directory:
BINDIR="/usr/local/bin"

#Default man page destination directory:
MANDIR="/usr/local/man"

#Assume that any argument is a plea for help.

if [ $1 ]; then
    echo "PGP 5.0 install script.  Usage:"
    echo "$0 [dest_dir]"
    echo "If you have a source distribution, do \"make install\", instead."
    exit 0
fi

#Ok, ask the user for directory confirmation:

echo -n "Binary installation directory [$BINDIR]: "
read TMP

if [ $TMP ]; then
    BINDIR=$TMP
fi

#A really, really cool script would make the default directory here based
#on the above user input, but that sounds like a lot of work.

echo -n "Man page installation directory [$MANDIR]: "
read TMP

if [ $TMP ]; then
    MANDIR=$TMP
fi

#Check for, and create, the destination directories if they don't exist:
if [ ! -d $BINDIR ]; then
    echo "Creating $BINDIR."
    mkdir -p $BINDIR
fi

if [ ! -d $MANDIR ]; then
    echo "Creating $MANDIR"
    mkdir -p $MANDIR
fi

if [ ! -d $MANDIR/man1 ]; then
    echo "Creating $MANDIR/man1"
    mkdir -p $MANDIR/man1
fi

if [ ! -d $MANDIR/man5 ]; then
    echo "Creating $MANDIR/man5"
    mkdir -p $MANDIR/man5
fi

if [ ! -d $MANDIR/man7 ]; then
    echo "Creating $MANDIR/man7"
    mkdir -p $MANDIR/man7
fi

#Do a sanity check for the sources:

if [ ! -f apps/pgp/pgp ]; then
    echo "Unable to find apps/pgp/pgp for copying!"
    exit 1
elif [ ! -f  apps/pgpk/pgpk ]; then
    echo "Unable to find apps/pgpk/pgpk for copying!"
fi

echo "Installing PGP 5.0 binaries to $BINDIR..."

install -m 755 apps/pgp/pgp $BINDIR
install -m 755 apps/pgpk/pgpk $BINDIR
ln -sf $BINDIR/pgp $BINDIR/pgpe
ln -sf $BINDIR/pgp $BINDIR/pgps
ln -sf $BINDIR/pgp $BINDIR/pgpv

echo "Complete.  Installing man pages to $MANDIR..."

install -m 655 man/*.1 $MANDIR/man1
install -m 655 man/*.5 $MANDIR/man5
#install -m 655 man/*.7 $MANDIR/man7

echo "Installation complete.  \"man pgp\" for starting points."
