#!/bin/sh
#
# saveEnv - save build time environment for install time scripts
#

F=Install.defaults

echo "#!/bin/sh" > $F
echo "#Note: This file is created when the program is built." > $F
echo "#      It is used to save parameters/variables that may be" >>$F
echo "#      used during setup and installation of the package." >>$F
echo "#      These default values may be overriden by setting them in the" >>$F
echo "#      Install.params file." >>$F
echo "" >>$F

echo "" >> $F
echo "APP_PREFIX_PATH=$APP_INSTALL_ROOT" >> $F
echo "APP_INSTALL_ROOT=$APP_PREFIX_PATH" >> $F
echo "export APP_PREFIX_PATH APP_INSTALL_ROOT" >> $F
echo "" >> $F

X_APP_RES_PATH=`getXAppResDir`

echo "RESDIR=$X_APP_RES_PATH" >> $F
echo "BINDIR=/usr/local/bin" >> $F
echo "MANDIR=/usr/local/man/man1" >> $F
echo "LIBDIR=/usr/local/lib/treeps" >> $F
echo "LOCAL_BIN=/usr/local/bin" >> $F

echo "export RESDIR BINDIR MANDIR LIBDIR LOCAL_BIN" >> $F
echo "" >> $F

echo "INSTALL_SETUID_ROOT=Y" >> $F
echo "export INSTALL_SETUID_ROOT" >> $F

chmod +x $F


F=Install.params

echo "#!/bin/sh" > $F
echo "" > $F
echo "# This file is automatically created when the program is built." >>$F
echo "# If you wish to customize the setup/install then modify the" >>$F
echo "# entries here as desired. You can also override any of the" >>$F
echo "# other values defined in the Install.defaults file here by adding" >>$F
echo "# an entry with your desired value." >>$F
echo "" >> $F
echo "" >> $F

# We automatically perform a platform override for these

echo "# If you are building from source and want to change the" >> $F
echo "# install locations for your build, then see doc/Configure." >> $F
echo "" >> $F
echo "" >> $F
X_APP_BIN_PATH=`getInstallBin`
X_APP_LIB_PATH=`getInstallLib`
X_APP_MAN_PATH=`getInstallMan`
LOCAL_BIN_DIR=`getUsrLocalBin`

echo "RESDIR=$X_APP_RES_PATH" >> $F
echo "BINDIR=$X_APP_BIN_PATH" >> $F
echo "MANDIR=$X_APP_MAN_PATH/man1" >> $F
echo "LIBDIR=$X_APP_LIB_PATH" >> $F
echo "LOCAL_BIN=$LOCAL_BIN_DIR" >> $F

echo "export RESDIR BINDIR MANDIR LIBDIR LOCAL_BIN" >> $F

echo "" >> $F
echo "# The following controls whether or not the program is installed" >> $F
echo "# setuid to root. The program generally needs to be setuid root to" >> $F
echo "# gather all of the process values and to perform some commands. The">>$F
echo "# program will run without being setuid root, the limitations then">>$F
echo "# imposed depend on the particular OS/version. On older versions of" >> $F
echo "# SunOS and UNIX_SV it becomes almost useless without it, newer" >> $F
echo "# versions and GNU/Linux are quite usable without it." >> $F
echo "# I have tried to make the program as secure as possible, but" >> $F
echo "# wont claim that it's bullet proof. If you are running a single" >> $F
echo "# user type setup then it should be fine. Multiuser systems should" >> $F
echo "# be set based on your security policies." >> $F
echo "# " >> $F
echo "# See doc/Security for more details." >> $F
echo "" >> $F

SETUID=`getSetUIDSetting`
INSTALL_AS_ROOT=`getInstallAsRootRequired`

echo "INSTALL_SETUID_ROOT=$SETUID" >> $F
echo "MUST_INSTALL_AS_ROOT=$INSTALL_AS_ROOT" >> $F
echo "export MUST_INSTALL_AS_ROOT INSTALL_SETUID_ROOT" >> $F

chmod +x $F

