1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
#!/bin/sh
#
# Copyright (C) 2000-2002 Cameron J. Morland
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# File Name: install
#
# Project Name: changetrack
#
# Module Description: changetrack installation utility
#
# Author: Cameron J. Morland and Devin Reade
# defaults
APPPATH_DEFAULT="/usr/bin"
MANPATH_DEFAULT="/usr/man/man1"
ROOTCONFFILE_DEFAULT="/etc/changetrack.conf"
ROOTHISTORYPATH_DEFAULT="/var/state/changetrack"
USERCONFFILE_DEFAULT="changetrack.conf"
USERHISTORYPATH_DEFAULT="changetrack.output"
MAILFROM_DEFAULT="changetrack@localhost"
PERLPATH=`which perl`
# enable or disable features
ESMAIL="# (install error) "
DSMAIL="# (install error) "
ENCOPY="# (install error) "
DNCOPY="# (install error) "
# override the defaults if we've installed from here before
d=`dirname $0`
if [ -f $d/.config ]; then
cat <<EOF
Using previous values from $d/.config
Delete that file if you want the factory defaults.
EOF
. $d/.config
fi
# include macros
. $d/functions
# show the information about the license (whole thing awfully long)
clear
cat gnu_short.txt
echo ""
#
# Asks a question, giving a default value. The user can either accept the
# default, or enter something else.
#
# Usage: ask "question" variable_name default_value
#
ask () {
question="$1"
variable="$2"
default="$3"
echo -n "$question ($default) "
result=''
read response
if [ -z "$response" ]; then
result="$default"
else
result="$response"
fi
eval $variable=$result
}
#
# Like 'ask', but forces the answer to begin with either 'y' or 'n', case-
# insensitive. The returned value is always either 'yes' or 'no'.
#
# Usage: yesno "question" variable_name default_value
#
yesno () {
question="$1"
variable="$2"
default="$3"
echo -n "$question ($default) "
result=''
read response
if [ -z "$response" ]; then
result="$default"
fi
while [ -z "$result" ]; do
# use sed to get the first character of the response
short=`echo $response | sed -e 's/^\(.\).*/\1/`
#short=`expr substr "$response" 1 1`
if [ "$short" = 'y' -o "$short" = 'Y' ]; then
result=yes
elif [ "$short" = 'n' -o "$short" = 'N' ]; then
result=no
else
echo -n "please answer 'yes' or 'no': "
read response
fi
done
eval $variable=$result
}
########## Determine what's up with Perl
if [ `perl -e 'print 1;'` ] ; then
# some version of Perl exists
echo "Perl detected"
if [ `perl -e 'if($] >= 5) {print 1;} else {}'` ] ; then
# Perl 5 or greater detected
echo "Perl version OK."
PERL=1
else
# Perl 5 not detected
perl -e 'print "Perl version $] detected.\n"'
echo "Changetrack has been tested only with Perl 5."
yesno "Install anyway?" YN no
if [ "$YN" = no ]; then
echo "Installation cancelled."
echo "Perl is available at www.perl.com"
exit 1
else
echo "Installing with old Perl."
echo "Upgrading Perl is recommended."
echo "Perl is available at www.perl.com"
PERL=0
fi
fi
else
# no version of Perl exists.
cat <<EOF
Perl not detected. Make sure Perl is in your path.
Changetrack requires at least Perl version 5, available from www.perl.com.
Installation cancelled.
EOF
exit 1
fi
########## Are my defaults OK for this machine?
ask "Application directory:" APPPATH $APPPATH_DEFAULT
ask "Manual page directory:" MANPATH $MANPATH_DEFAULT
ask "System-wide configuration file:" ROOTCONFFILE $ROOTCONFFILE_DEFAULT
ask "System-wide history files directory:" ROOTHISTORYPATH $ROOTHISTORYPATH_DEFAULT
ask "User configuration file:" USERCONFFILE $USERCONFFILE_DEFAULT
ask "User history files directory:" USERHISTORYPATH $USERHISTORYPATH_DEFAULT
cat <<EOF
If you want changetrack to send email notifications, you need to configure
the email address where the mail comes *from*. This is because some MTAs
(mail transfer agents, such as sendmail) are configured to block email
addresses that do not resolve to a valid domain name. As a rule in this
case, you must not use 'localhost' for the domain.
If you *don't* want to use email notifications, then you can safely use
'changetrack@localhost' or whatever else you want; the address will not
be used.
EOF
ask "Originating email address: " MAILFROM $MAILFROM_DEFAULT
#
# Save our configuration
#
date=`date`
cat > $d/.config <<EOF
#
# Configuration file created by $0
# $date
#
APPPATH_DEFAULT="$APPPATH"
MANPATH_DEFAULT="$MANPATH"
ROOTCONFFILE_DEFAULT="$ROOTCONFFILE"
ROOTHISTORYPATH_DEFAULT="$ROOTHISTORYPATH"
USERCONFFILE_DEFAULT="$USERCONFFILE"
USERHISTORYPATH_DEFAULT="$USERHISTORYPATH"
MAILFROM_DEFAULT="$MAILFROM"
EOF
#
# Check to see if Mail::Sendmail is installed
#
GOTMAIL=`perl -e 'use Mail::Sendmail' 2>&1`
if [ "$GOTMAIL" == "" ]; then
# it's installed. We comment out the one line.
ESMAIL="# --sendmail enabled-- "
DSMAIL=""
else
# perl will have complained bitterly.
more <<EOF
Mail::Sendmail appears to not be installed.
I will disable mail sending for now.
The Mail::Sendmail module can be installed by running the following
command as root:
perl -MCPAN -e "install Mail::Sendmail"
EOF
# comment out the other line.
ESMAIL=""
DSMAIL="# --sendmail disabled-- "
fi
#
# Check to see if File::NCopy is installed
#
GOTNCOPY=`perl -e 'use File::NCopy' 2>&1`
if [ "$GOTNCOPY" == "" ]; then
# it's installed. We comment out the one line.
ENCOPY="# --ncopy enabled -- "
DNCOPY=""
else
# perl will have complained bitterly.
more <<EOF
File::NCopy appears to not be installed.
I will use File::Copy for now, but this may disable features
The File::NCopy module can be installed by running the following
command as root:
perl -MCPAN -e "install File::NCopy"
EOF
# comment out the other line.
ENCOPY=""
DNCOPY="# --ncopy disabled-- "
fi
my_install changetrack.pl $APPPATH/changetrack 0755
my_install changetrack.man $MANPATH/changetrack.1 0644
if [ -f "$ROOTCONFFILE" ]; then
echo "$ROOTCONFFILE exists; not installing default file."
else
yesno "Should I put in a default $ROOTCONFFILE?" YN yes
if [ "$YN" = yes ]; then
my_install changetrack.conf $ROOTCONFFILE 0644
else
echo "Omitting default configuration file."
fi
fi
|