-
Notifications
You must be signed in to change notification settings - Fork 0
/
installkSNP
executable file
·182 lines (142 loc) · 4.59 KB
/
installkSNP
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
#!/bin/bash
cat > /dev/null <<IGNOREME
This is a simple script to install kSNP4 onto a computer system in a reliable,
and repeatable way.
In addition, I intend it to be possible for the user to update the links in
the BINDIR in bulk and automatically, e.g. if the user wishes to install more
than one copy of kSNP.
The general policy is:
Put all files in PACKAGEDIR.
Create symbolic links in BINDIR for all scripts or executables that the user is
likely to want to use.
Run the kSNPConfig program to get an initial configuration.
IGNOREME
######################
######################
#
# VARIABLES
#
######################
######################
# The other binaries are all in the kSNP4 directory once it is unpacked.
ARCHIVE=kSNP4
# Default install paths:
# This is the directory where distribution files will be stored. They may be
# referenced from other locations.
PACKAGEDIR=/usr/local/kSNP4Pkg
# This is a directory in the PATH where we will create symbolic links to the
# executables.
BINDIR=/usr/local/bin
# Variables containing lists of files that are required for kSNP to function
USERBINS="checkFileNames checkGenbankFromNCBI extractNthLocus4 fixOldFastaHeaders genomeNames4 getFastaGenomes Kchooser4 kSNP4 ksnpConfig MakeKSNP4infile nodeChiSquare2tree4 parseNCBIcsv rmNodeNamesFromTree4 selectNodeAnnotations4"
# A program to manipulate the kSNP configuration (if any)
RECONFIGURE=ksnpConfig
######################
######################
#
# MAIN
#
######################
######################
SYMLINKS=TRUE
CONFIGURE=TRUE
INSTALL=TRUE
CMDLINE_ERROR=FALSE
USAGE=FALSE
while [ ${#} -gt 0 ] # While we have more arguments to process...
do
case "${1}" in # "switch" / case based on what the argument is.
--symlinks-only) # This is used if the binaries are already in place.
INSTALL=FALSE
CONFIGURE=FALSE
shift
;;
--configure-only) # This is used if we just want to re-configure.
INSTALL=FALSE
SYMLINKS=FALSE
shift
;;
--install-only) # This is used if the user wants to place the symlinks and configure themselves.
SYMLINKS=FALSE
CONFIGURE=FALSE
shift
;;
--installdir)
PACKAGEDIR="${2}"
shift 2 # Argument and value
;;
--bindir)
BINDIR="${2}"
if [ ! -d "${BINDIR}" ]
then
CMDLINE_ERROR=TRUE
echo "Specified target directory ${BINDIR} for binary symlinks does not yet exist."
echo "Did you specify the directory correctly?"
fi
shift 2
;;
--help)
USAGE=TRUE
break
;;
--debug)
DEBUG=1
# Same as specifying -x on the shell shebang above.
set -o xtrace
# Same as specifying -v on the shell shebang above.
set -o verbose
shift # Argument
;;
*) # All other values are errors.
CMDLINE_ERROR=TRUE
USAGE=TRUE
echo "Error: Unrecognized argument (no valid argument: ${1})"
shift
;;
esac
done # Processing arguments
if [ "${USAGE}" = "TRUE" ]
then
cat <<HERETEXT
Usage: installkSNP [--bindir <directory in PATH>] [--installdir <install target>] [--install-only] [--symlinks-only] [--configure-only] [--help] [--debug]
This script is designed to install and initially configure kSNP for your use.
You likely will need to run it as an administrator to install to the default
systemwide folders / directories.
Optional arguments:
--bindir <directory> Directory to place symbolic links to kSNP binaries.
--installdir <directory> Directory to place kSNP binaries and support data.
--install-only Instruct the script to only install binaries without
placing symbolic links or configuring kSNP.
--symlinks-only Replace symbolic links into the --bindir directory.
--configure-only Configure kSNP for the current user, no installation.
--help This text.
--debug Verbose debugging information. Probably useless.
Typical usage is to run without arguments. You may also use it to re-
configure kSNP from the defaults, or to restore the symbolic links if
something happened to disturb them (like another kSNP install)
HERETEXT
# And after displaying help, don't do anything.
exit 0
fi
if [ "${CMDLINE_ERROR}" = "TRUE" ]
then
exit 1 # Error
fi
if [ "${INSTALL}" = "TRUE" ]
then
mkdir -p "${PACKAGEDIR}"
cp "${ARCHIVE}/"* "${PACKAGEDIR}/"
# Make this installer available going forward.
cp "${0}" "${PACKAGEDIR}/"
fi
if [ "${SYMLINKS}" = "TRUE" ]
then
for BINARY in ${USERBINS}
do
ln -s "${PACKAGEDIR}/${BINARY}" "${BINDIR}/${BINARY}"
done
fi
if [ "${CONFIGURE}" = "TRUE" ]
then
"${PACKAGEDIR}/${RECONFIGURE}"
fi