| 1 |
#!/bin/ksh |
| 2 |
# |
| 3 |
########################################################################## |
| 4 |
################# A C.elegans database ######################### |
| 5 |
################# R.Durbin and J.Thierry-Mieg ######################### |
| 6 |
################# ######################### |
| 7 |
################# Installation script for ######################### |
| 8 |
################# ######################### |
| 9 |
################# ACEDB 4_8 ######################### |
| 10 |
################# ######################### |
| 11 |
################# Dec 2000 ######################### |
| 12 |
################# ######################### |
| 13 |
########################################################################## |
| 14 |
# |
| 15 |
# $Id: INSTALL,v 1.23 2002/01/16 16:03:29 edgrif Exp $ |
| 16 |
# |
| 17 |
# To install ACeDB, this file and the appropriate distribution |
| 18 |
# NNNN.tar.gz files should be in the same directory. See the NOTES |
| 19 |
# file to find out which distribution NNNN.tar.gz files you need |
| 20 |
# for your site. You must have write access in the directory to be |
| 21 |
# able to run the INSTALL script. |
| 22 |
# |
| 23 |
# We provide executables for a number of X11-Unix platforms: |
| 24 |
# DEC-Alpha, Linux, SGI & Sun. |
| 25 |
# You can compile for many others using our makefiles. |
| 26 |
# We also provide for compiling for MS-Windows. |
| 27 |
# |
| 28 |
# To run this script, go to the directory containing the script |
| 29 |
# and NNNN.tar.gz files and type script name: |
| 30 |
# |
| 31 |
# ./INSTALL |
| 32 |
# |
| 33 |
################################################################### |
| 34 |
# |
| 35 |
# |
| 36 |
# All download files should be of the pattern: |
| 37 |
# |
| 38 |
# ACEDB-<package>.<version>.tar.gz |
| 39 |
# |
| 40 |
# where |
| 41 |
# <package> is currently source | docs | help | tools | |
| 42 |
# |
| 43 |
# <version> is of the form "version"_"release""update", e.g. 4_8d |
| 44 |
# |
| 45 |
# e.g. ACEDB-source.4_8d.tar.gz |
| 46 |
# ACEDB-binALPHA.4_7l.tar.gz |
| 47 |
# |
| 48 |
|
| 49 |
# Set to non-NULL to turn on debug in whole script. |
| 50 |
debug="" |
| 51 |
|
| 52 |
#-------------------------- functions ------------------------------- |
| 53 |
|
| 54 |
function print_usage |
| 55 |
{ |
| 56 |
if [[ -n $1 ]] |
| 57 |
then |
| 58 |
print |
| 59 |
print "Warning: $1" |
| 60 |
fi |
| 61 |
|
| 62 |
print |
| 63 |
print "Usage: INSTALL [-h]" |
| 64 |
print |
| 65 |
print " -h produces this help message." |
| 66 |
print |
| 67 |
print " You should cd to the directory containing the *tar.gz install file and" |
| 68 |
print " then run INSTALL. INSTALL will try to install all such files that it finds" |
| 69 |
print " in the directory." |
| 70 |
print |
| 71 |
|
| 72 |
exit 1 |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
function bomb_out |
| 77 |
{ |
| 78 |
print |
| 79 |
print "Fatal Error : $1" |
| 80 |
print |
| 81 |
|
| 82 |
exit 1 |
| 83 |
} |
| 84 |
|
| 85 |
function print_divider |
| 86 |
{ |
| 87 |
print |
| 88 |
print '=====================================================================' |
| 89 |
print |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
#------------------------- main routine ------------------------------- |
| 95 |
|
| 96 |
prefix='ACEDB-' |
| 97 |
static_prefix=$prefix'STATIC_' |
| 98 |
srcname='source' |
| 99 |
binname='bin' |
| 100 |
servname='bin' |
| 101 |
helpname='whelp' |
| 102 |
docname='wdoc' |
| 103 |
toolsname='wtools' |
| 104 |
demoname='wdemo' |
| 105 |
|
| 106 |
# probably this is redundant now because we are doing subdirs...anyway it is not |
| 107 |
# safe enough, what about wquery etc. etc., there are other things that should be |
| 108 |
# saved..... |
| 109 |
# wspec names |
| 110 |
wspec="wspec" |
| 111 |
wspecsaved="SAVED-FROM-INSTALL.$wspec" |
| 112 |
wspecnew="$wspec.FROM-INSTALL" |
| 113 |
|
| 114 |
# default is to install from current directory. |
| 115 |
orig_dir=$PWD |
| 116 |
|
| 117 |
|
| 118 |
# Do the flags... (see usage string for description of switches/arguments) |
| 119 |
while getopts :h arguments |
| 120 |
do |
| 121 |
case $arguments in |
| 122 |
'h') print_usage ;; |
| 123 |
|
| 124 |
# garbage input |
| 125 |
'?') print_usage "-$OPTARG is not a valid switch" ;; |
| 126 |
':') print_usage "You forgot the argument for switch -$OPTARG" ;; |
| 127 |
esac |
| 128 |
done |
| 129 |
|
| 130 |
# Unused at the moment... |
| 131 |
# Now do the remaining args... |
| 132 |
#((args_left = OPTIND - 1)) |
| 133 |
#shift $args_left |
| 134 |
|
| 135 |
#if [[ -z $1 ]] |
| 136 |
#then |
| 137 |
# print_usage "You did not specify a directory from which to make the install file" |
| 138 |
#elif [[ -n $2 ]] |
| 139 |
#then |
| 140 |
# print_usage "Too many command line arguments: $*" |
| 141 |
#else |
| 142 |
# source_dir=$1 |
| 143 |
#fi |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
print_divider |
| 148 |
print ' ACEDB installation starting...' |
| 149 |
print_divider |
| 150 |
|
| 151 |
if [[ $USER = "root" ]] |
| 152 |
then |
| 153 |
bomb_out 'You should not be root when installing ACEDB, su to some other user name and try again' |
| 154 |
fi |
| 155 |
|
| 156 |
if [[ -r './' && -w './' && -x './' ]] |
| 157 |
then |
| 158 |
print 'directory permissions OK...' |
| 159 |
else |
| 160 |
bomb_out 'you do not have read/write/execute permissions for '$PWD |
| 161 |
fi |
| 162 |
|
| 163 |
print ' Files will be owned by: "'$USER'"' |
| 164 |
print 'Files will be installed in: '$PWD |
| 165 |
|
| 166 |
print_divider |
| 167 |
|
| 168 |
print 'The available space in this directory is: ' |
| 169 |
df -k . |
| 170 |
print |
| 171 |
print 'The amount of space you need will depend on what data you are installing.' |
| 172 |
print 'For the full source code and binaries, you need around 80 MB.' |
| 173 |
print |
| 174 |
print -n "Should we proceed? Please answer y/n : " |
| 175 |
read answer rubbish |
| 176 |
|
| 177 |
print_divider |
| 178 |
if [[ $answer = 'y' || $answer = 'Y' ]] |
| 179 |
then |
| 180 |
print 'Install proceeding...' |
| 181 |
else |
| 182 |
bomb_out 'Install aborted...' |
| 183 |
fi |
| 184 |
|
| 185 |
|
| 186 |
# check for wspec directory and move it if its there. |
| 187 |
if [[ -d $wspec ]] |
| 188 |
then |
| 189 |
print_divider |
| 190 |
print "Renaming $wspec to $wspecsaved, it will be moved back after INSTALL is finished" |
| 191 |
mv $wspec $wspecsaved || bomb_out "Rename $wspec --> $wspecsaved failed" |
| 192 |
fi |
| 193 |
|
| 194 |
|
| 195 |
# Main install loop. |
| 196 |
|
| 197 |
for i in `ls $prefix*.*.tar.gz` |
| 198 |
do |
| 199 |
# pre install checks... |
| 200 |
case $i in |
| 201 |
$prefix'source'.*.tar.gz) target=$srcname ;; |
| 202 |
$prefix'binary'*.*.tar.gz|$static_prefix'binary'*.*.tar.gz) target=$binname ;; |
| 203 |
$prefix'server'*.*.tar.gz|$static_prefix'server'*.*.tar.gz) target=$servname ;; |
| 204 |
$prefix'help'.*.tar.gz) target=$helpname ;; |
| 205 |
$prefix'doc'.*.tar.gz) target=$docname ;; |
| 206 |
$prefix'tools'.*.tar.gz) target=$toolsname ;; |
| 207 |
$prefix'demo'.*.tar.gz) target=$demoname ;; |
| 208 |
*) continue ;; |
| 209 |
esac |
| 210 |
|
| 211 |
print_divider |
| 212 |
print -n "Do you want to install $i ? Please answer y/n : " |
| 213 |
read answer rubbish |
| 214 |
print |
| 215 |
if [[ $answer != 'y' && $answer != 'Y' ]] |
| 216 |
then |
| 217 |
print |
| 218 |
print "Aborting install of $i..." |
| 219 |
continue |
| 220 |
fi |
| 221 |
|
| 222 |
wdirs=$(ls $target 2> /dev/null) |
| 223 |
if [[ -n $wdirs ]] |
| 224 |
then |
| 225 |
print 'Warning: installing '$i' will overwrite "'$target'"' |
| 226 |
print ' everything in this directory will be lost,' |
| 227 |
print -n ' do you want to continue with the installation (type y/n) ? ' |
| 228 |
read answer rubbish |
| 229 |
if [[ $answer = 'n' || $answer = 'N' ]] |
| 230 |
then |
| 231 |
print |
| 232 |
print "Aborting install of $i..." |
| 233 |
continue |
| 234 |
fi |
| 235 |
print |
| 236 |
fi |
| 237 |
|
| 238 |
# Remove the old version... |
| 239 |
rm -rf $target || bomb_out "Could not remove previous install of $i" |
| 240 |
mkdir $target || bomb_out "Cannot make install target directory $i" |
| 241 |
mv $i $target || bomb_out "Could not move $i to $target for the install" |
| 242 |
cd $target || bomb_out "Cannot cd to $target for install" |
| 243 |
|
| 244 |
# do the install itself... |
| 245 |
print "Installing $i..." |
| 246 |
gunzip -c $i | tar -xf - || bomb_out "gunzip/untar of $i failed." |
| 247 |
|
| 248 |
# post install checks/actions... |
| 249 |
print |
| 250 |
case $i in |
| 251 |
$prefix'source'.*.tar.gz) ln -s wmake/makefile |
| 252 |
print "Installed the source files" ;; |
| 253 |
$prefix'binary'*.*.tar.gz|$static_prefix'binary'*.*.tar.gz) print 'Installed the binaries...' |
| 254 |
print '\tLook in the bin directory for updated versions' |
| 255 |
print '\tof the wspec and other acedb directories.' ;; |
| 256 |
$prefix'server'*.*.tar.gz|$static_prefix'server'*.*.tar.gz) print 'Installed the server binaries...' |
| 257 |
print '\tLook in the bin directory for updated versions' |
| 258 |
print '\tof the wspec and other acedb directories.' ;; |
| 259 |
$prefix'help'.*.tar.gz) print "Installed the help" ;; |
| 260 |
$prefix'docs'.*.tar.gz) print "Installed the docs" ;; |
| 261 |
$prefix'tools'.*.tar.gz) print "Installed the tools" ;; |
| 262 |
$prefix'demo'.*.tar.gz) print "Installed the demo database" ;; |
| 263 |
esac |
| 264 |
|
| 265 |
mv $i ../ || bomb_out "Cannot return $i to $orig_dir." |
| 266 |
cd ../ || bomb_out "Cannot cd to $orig_dir." |
| 267 |
done |
| 268 |
|
| 269 |
|
| 270 |
# check for wspec.saved directory and restore it if its there. |
| 271 |
if [[ -d $wspecsaved ]] |
| 272 |
then |
| 273 |
print_divider |
| 274 |
if [[ -d $wspec ]] |
| 275 |
then |
| 276 |
mv $wspec $wspecnew || bomb_out "mv of $wspec to $wspecnew failed" |
| 277 |
print "The new wspec from the tar file has been saved as $wspecnew." |
| 278 |
fi |
| 279 |
|
| 280 |
mv $wspecsaved $wspec || bomb_out "restore of $wspecsaved to $wspec failed" |
| 281 |
print "Your original $wspec has been restored." |
| 282 |
fi |
| 283 |
|
| 284 |
print_divider |
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
exit 0 |
| 290 |
|