-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall
executable file
·387 lines (310 loc) · 8.26 KB
/
install
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
#! /bin/bash -
#
# Package: Axiom
# File: install
# Summary: install script for the Axiom package
# Maintainer: David Wicksell <dlw@linux.com>
# Last Modified: Oct 22, 2012
#
# Written by David Wicksell <dlw@linux.com>
# Copyright © 2011,2012 Fourth Watch Software, LC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License (AGPL)
# as published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# This script is written to be run in a Red Hat or Ubuntu environment.
# Tweaks maybe needed for other distributions.
# Usage message
function Usage
{
echo "Usage: ${SCRIPT} [-q]"
echo " or ${SCRIPT} -h"
} # End of Usage
#find out if they want to overwrite, backup, or append configuration files
function Question
{
echo "There is a $1 file installed already."
echo "Would you like to make a backup of it, and install the"
echo "package version, append the options that are required"
echo "to the end of it, or overwrite the file completely?"
echo
echo "Please choose the number of the option you want."
select ANSWER in backup append overwrite quit
do
case ${ANSWER} in
backup)
cp -p ~/$1 ~/$1.orig
echo "Your old $1 is now ${HOME}/$1.orig"
cp -p ${1/"."/} ~/$1
echo "Installed new $1 file"
echo
break
;;
append)
cat ${1/"."/} | sed "s/^set/\"set/" >> ~/$1 #don't set things in append
echo "Appended the relevant configuration options to"
echo "the end of $1"
echo
break
;;
overwrite)
#be extra careful with the overwrite option
echo -n "You have chosen to ${ANSWER} ${HOME}/$1, proceed? [Y]/N "
read ANS
ANS=`echo ${ANS} | tr [:lower:] [:upper:]`
if [ "${ANS}" == "Y" -o "${ANS}" == "YES" -o "${ANS}" == "" ]
then
cp -p ${1/"."/} ~/$1
echo "Installed new $1 file"
echo
break
else
continue
fi
;;
quit)
cd - > /dev/null #change back to the directory we started from
exit 0
;;
*)
echo -n "Please choose the number of the option you want. "
echo
esac
done
} # End of Question
#install script starts here
SCRIPT=`basename $0`
QUIET=off
#only care about -q (quiet mode), or -h (help) but ignore all other arguments
while getopts :hq OPT
do
case ${OPT} in
h) #help
Usage
exit 0
;;
q) #Quiet mode
QUIET=on
;;
'?') #invalid option
echo "-${OPTARG} is not a valid option"
Usage
exit 1
;;
esac
done
if [ "${QUIET}" == "off" ]
then
clear
fi
cd `find ~/ -type d -name axiom -print` #need to install from the repository
OS=`lsb_release -is` #Ubuntu and Red Hat do a few things differently
if [ -z "${gtmroutines}" ]
then
if [ "${QUIET}" == "off" ]
then
echo The \$gtmroutines environment variable is not defined. In order to use
echo the global dumping functionality of Axiom you have to install GT.M
echo and KBAWDUMP.m, as well as define \$gtmroutines. See the documentation:
echo http://www.fisglobal.com/products-technologyplatforms-gtm/
echo
fi
else
DIR=`echo ${gtmroutines} | awk '{print $1}'`
if [[ ${DIR} != ${DIR/"("/} ]] #$gtmroutines with "()" source syntax
then
DIR=`echo ${DIR} | cut -d "(" -f 2 | cut -d ")" -f 1`
fi
cp -p KBAWDUMP.m ${DIR}/
if [ "${QUIET}" == "off" ]
then
echo Copied the KBAWDUMP.m global dumping routine to ${DIR}/
echo See the man page for details on how to use it. E.g. $ man KBAWDUMP
echo
fi
fi
if [ ! -d ~/bin ]
then
mkdir ~/bin
fi
cp -p mktags ~/bin/
if [ "${QUIET}" == "off" ]
then
echo Copied the mktags shell script to ${HOME}/bin/
echo
echo Run mktags to build the tags file for the mtags functionality.
echo See the man page for details on how to use it. E.g. $ man mktags
echo
fi
if [[ $PATH == ${PATH/"${HOME}/bin"/} ]] #does $PATH contain ~/bin?
then
if [ "${OS}" == "Ubuntu" -o "${OS}" == "LinuxMint" ]
then
echo "export PATH=\$HOME/bin:\$PATH" >> ~/.profile
if [ "${QUIET}" == "off" ]
then
echo Appended a command to add \$HOME/bin to \$PATH in ~/.profile
echo
fi
else
echo "export PATH=\$HOME/bin:\$PATH" >> ~/.bash_profile
if [ "${QUIET}" == "off" ]
then
echo Appended a command to add \$HOME/bin to \$PATH in ~/.bash_profile
echo
fi
fi
fi
if [ ! -d ~/man/man1 ]
then
mkdir -p ~/man/man1
fi
cp -p mktags.1 KBAWDUMP.1 ~/man/man1/
gzip -f9 ~/man/man1/{mktags,KBAWDUMP}.1 #compress the man pages
if [ "${QUIET}" == "off" ]
then
echo Copied the mktags and KBAWDUMP man pages to $HOME/man/man1/
echo
echo In order to install them system-wide, you need to be root. Consult the
echo SEE ALSO section of the man page on how to do this. E.g. $ man man
echo
fi
if [ "${OS}" == "Ubuntu" -o "${OS}" == "LinuxMint" ]
then
export MANPATH=:~/man #putting a colon at the beginning is a trick
mandb -q
if [ "${QUIET}" == "off" ]
then
echo Added the ~/man/ directory to \$MANPATH, and rebuilt the database
echo
fi
else
if grep -q MANPATH ~/.bash_profile
then
if [ "${QUIET}" == "off" ]
then
echo Make sure \$HOME/man is in the \$MANPATH variable in ~/.bash_profile
fi
else
echo >> ~/.bash_profile
echo "export MANPATH=\$HOME/man:`manpath`" >> ~/.bash_profile
if [ "${QUIET}" == "off" ]
then
echo Appended a command to add \$HOME/man to \$MANPATH in ~/.bash_profile
fi
fi
if [ "${QUIET}" == "off" ]
then
echo To access your man pages now, type: $ source ~/.bash_profile
echo
fi
fi
if [ "${QUIET}" == "off" ]
then
if [ -f ~/.vimrc ]
then
echo -n "Please type <Enter> to continue: "
read X
clear
Question .vimrc
else
cp -p vimrc ~/.vimrc
echo "Installed new .vimrc file"
echo
fi
if [ ! -d ~/.vim ]
then
cp -aT vim ~/.vim
echo Copied the Vim utility package to ~/.vim/
echo
else
if [ -f ~/.vim/filetype.vim ]
then
echo -n "Please type <Enter> to continue: "
read X
clear
Question .vim/filetype.vim
else
cp -p vim/filetype.vim ~/.vim/
echo "Installed new filetype.vim file"
echo
fi
if [ -f ~/.vim/scripts.vim ]
then
echo -n "Please type <Enter> to continue: "
read X
clear
Question .vim/scripts.vim
else
cp -p vim/scripts.vim ~/.vim/
echo "Installed new scripts.vim file"
echo
fi
if [ ! -d ~/.vim/doc ]
then
mkdir ~/.vim/doc
fi
cp -p vim/doc/axiom.txt ~/.vim/doc/
echo Copied vim/doc/axiom.txt to ~/.vim/doc/
echo
if [ ! -d ~/.vim/ftplugin ]
then
mkdir ~/.vim/ftplugin
fi
cp -a vim/ftplugin/mumps ~/.vim/ftplugin/
echo Copied vim/ftplugin/mumps/*.vim to ~/.vim/ftplugin/mumps/
echo
if [ ! -d ~/.vim/plugin ]
then
mkdir ~/.vim/plugin
fi
if [ -f ~/.vim/plugin/templates.vim ]
then
echo -n "Please type <Enter> to continue: "
read X
clear
Question .vim/plugin/templates.vim
else
cp -p vim/plugin/templates.vim ~/.vim/plugin/
echo "Installed new templates.vim file"
echo
fi
if [ ! -d ~/.vim/syntax ]
then
mkdir ~/.vim/syntax
fi
cp -p vim/syntax/mumps.vim ~/.vim/syntax/
echo Copied vim/syntax/mumps.vim to ~/.vim/syntax/
echo
if [ ! -d ~/.vim/templates ]
then
mkdir ~/.vim/templates
fi
cp -p vim/templates/*.{tpl,pat} ~/.vim/templates/
echo Copied vim/templates/*.{tpl,pat}
echo to ~/.vim/templates/
echo
fi
else
cp -p vimrc ~/.vimrc
cp -aT vim ~/.vim
fi
vim "+helptags ${HOME}/.vim/doc" "+quit"
if [ "${QUIET}" == "off" ]
then
echo "Installed the Vim help documentation"
echo
echo "Finished installing the Axiom package"
fi
cd - > /dev/null #change back to the directory we started from
exit 0