-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·304 lines (251 loc) · 7.02 KB
/
install.sh
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
#!/bin/bash
#
# install.sh
# LorikeeM Installer
#
# Copyright (C) 2013 Coherent Logic Development
#
# Provided under the terms of the GNU Affero General
# Public License V3
#
export installer_caption="LorikeeM M Developer Tools"
function welcome_message
{
installer_text="Welcome to the LorikeeM M Developer Tools installer."
installer_text="${installer_text}\n\n"
installer_text="${installer_text}This program will help you install "
installer_text="${installer_text}LorikeeM onto your computer.\n\n"
installer_text="${installer_text}LorikeeM requires YottaDB 1.10 or FIS GT.M and "
installer_text="${installer_text}GNU Emacs 24 or newer to function.\n"
installer_text="${installer_text}You appear to be running ${DISTRIB_ID}.\n\n"
installer_text="${installer_text}Choose OK to continue."
whiptail --title "${installer_caption}" --msgbox "${installer_text}" 15 75
}
function check_distro
{
DISTRIB_ID=`lsb_release -i -s`
case ${DISTRIB_ID} in
Ubuntu)
export PACKAGE_MANAGER="apt-get install"
;;
Debian)
export PACKAGE_MANAGER="apt-get install"
;;
Fedora)
export PACKAGE_MANAGER="yum install"
;;
CentOS)
export PACKAGE_MANAGER="yum install"
;;
esac
export DISTRIB_ID
}
function check_for_whiptail
{
which whiptail > /dev/null
if [ $? != 0 ]; then
echo "This installer requires whiptail(1) to function."
exit
fi
}
function check_for_root
{
if [ $EUID != 0 ]; then
whiptail --title "${installer_caption}" --msgbox "You must have root privileges in order to install LorikeeM" 12 75
exit
fi
}
function check_for_emacs
{
which emacs > /dev/null
if [ $? != 0 ]; then
whiptail --title "${installer_caption}" \
--yesno "GNU Emacs does not appear to be installed. Do you wish to install it?" 12 75
case $? in
0)
sudo ${PACKAGE_MANAGER} emacs
;;
1)
echo "Please install GNU Emacs 23 or later and try again."
exit
;;
esac
fi
}
function check_create_directories
{
whiptail --title "${installer_caption}" \
--infobox "Creating directories..." 12 75
if [ ! -d "${HOME}/.emacs.d" ]; then
mkdir ${HOME}/.emacs.d
fi
if [ ! -d "${HOME}/.emacs.d/plugins" ]; then
mkdir ${HOME}/.emacs.d/plugins
fi
if [ ! -d "${HOME}/.emacs.d/plugins/lorikeem" ]; then
mkdir ${HOME}/.emacs.d/plugins/lorikeem
fi
if [ ! -d "${HOME}/bin" ]; then
mkdir ${HOME}/bin
fi
if [ ! -d "${HOME}/man/man1" ]; then
mkdir -p ${HOME}/man/man1
fi
if [ ! -f "${HOME}/.emacs" ]; then
touch ${HOME}/.emacs
fi
}
function backup_file
{
BACKUP_TIMESTAMP=`date +%Y%m%d%H%M%S`
BACKUP_EXTENSION="lorikeem.${BACKUP_TIMESTAMP}"
if [ -f "$1" ]; then
mv $1 $1.${BACKUP_EXTENSION}
fi
}
function copy_lorikeem_elisp
{
whiptail --title "${installer_caption}" \
--infobox "Copying LorikeeM..." 12 75
backup_file ${HOME}/.emacs.d/plugins/lorikeem/lorikeem.el
cp src/lorikeem/lorikeem.el ${HOME}/.emacs.d/plugins/lorikeem/
}
function copy_yasnippet
{
whiptail --title "${installer_caption}" \
--infobox "Installing YASnippet..." 12 75
if [ -d "${HOME}/.emacs.d/plugins/yasnippet" ]; then
whiptail --title "${installer_caption}" \
--yesno "YASnippet appears to have been previously installed.\n\nDo you wish to back up the current version?" 12 75
if [ $? == 0 ]; then
BACKUP_TIMESTAMP=`date +%Y%m%d%H%M%S`
BACKUP_FILE="${HOME}/.emacs.d/plugins/yasnippet_${BACKUP_TIMESTAMP}.tar"
tar cvf ${BACKUP_FILE} ${HOME}/.emacs.d/plugins/yasnippet
fi
rm -rf ${HOME}/.emacs.d/plugins/yasnippet
fi
cp -r src/yasnippet ${HOME}/.emacs.d/plugins
}
function parse_gtmroutines
{
local DIR DIRS
for DIR in ${gtmroutines}
do
if [[ ${DIR} != ${DIR/"("/} ]]
then
DIR=`echo ${DIR} | cut -d "(" -f 2 | cut -d ")" -f 1`
elif [[ ${DIR} != ${DIR/")"/} ]]
then
DIR=`echo ${DIR} | cut -d "(" -f 2 | cut -d ")" -f 1`
elif [ "${DIR: -3}" == ".so" ]
then
DIR=`dirname ${DIR}`
elif ! ls ${DIR}/*.m &> /dev/null
then
DIR=`dirname ${DIR}`
fi
DIRS="${DIRS} ${DIR}"
done
export ROUTINE_DIRS=${DIRS}
}
function choose_routine_path
{
parse_gtmroutines
whiptail_cmd="--title \"${installer_caption}\" --noitem --menu \"Where would you like to install Lorikeem's MUMPS routines?\" 15 76 4 "
for DIR in ${ROUTINE_DIRS}
do
whiptail_cmd="${whiptail_cmd} \"${DIR}\" \" \""
done
whiptail_cmd="${whiptail_cmd} \"Other\" \" \""
export CHOSEN_ROUTINE_PATH=$(eval whiptail ${whiptail_cmd} 3>&1 1>&2 2>&3)
if [ ${CHOSEN_ROUTINE_PATH} == "Other" ]; then
export CHOSEN_ROUTINE_PATH=$(whiptail --inputbox "Custom MUMPS routine location:" 8 78 ${HOME} --title "${installer_caption}" 3>&1 1>&2 2>&3)
if [ ! -d "${CHOSEN_ROUTINE_PATH}" ]; then
mkdir "${CHOSEN_ROUTINE_PATH}"
fi
fi
if [ $? != 0 ]; then
exit
fi
}
function copy_mumps_routines
{
choose_routine_path
cp src/mumps/*.m ${CHOSEN_ROUTINE_PATH}
}
function copy_manpages
{
whiptail --title "${installer_caption}" \
--infobox "Installing documentation..." 12 75
cp -p doc/mktags.1 doc/lorikeem.1 doc/KBAWDUMP.1 ${HOME}/man/man1/
gzip -f9 ${HOME}/man/man1/{mktags,KBAWDUMP,lorikeem}.1
if [ "${OS}" == "Ubuntu" -o "${OS}" == "LinuxMint" ]; then
export MANPATH=:~/man
mandb -q
else
if grep -q MANPATH ~/.bashrc
then
# do nothing
echo "do nothing" > /dev/null
else
echo >> ~/.bashrc
echo "export MANPATH=\$HOME/man:`manpath`" >> ~/.bashrc
fi
fi
}
function update_emacs_config
{
whiptail --title "${installer_caption}" \
--infobox "Updating Emacs configuration..." 12 75
cat src/lorikeem/lorikeem-dotemacs.el >> ${HOME}/.emacs
}
function copy_binaries
{
whiptail --title "${installer_caption}" \
--infobox "Installing binaries..." 12 75
cp bin/* ${HOME}/bin
}
function update_search_path
{
whiptail --title "${installer_caption}" \
--infobox "Updating search path..." 12 75
cat src/lorikeem/lorikeem-path.sh >> ${HOME}/.bashrc
}
function install_crontab
{
whiptail --title "${installer_caption}" \
--infobox "Setting up scheduled tasks..." 12 75
crontab -l > tmp_cron
echo "0 * * * * mktags -e -g" >> tmp_cron
crontab tmp_cron
rm tmp_cron
}
function build_tags
{
whiptail --title "${installer_caption}" \
--infobox "Building ${HOME}/.MTAGS for routine cross-referencing..." 12 75
${HOME}/bin/mktags -e -g
}
function done_message
{
installer_text="LorikeeM has been successfully installed.\n\n"
installer_text="${installer_text}You may start LorikeeM by typing\n\nlorikeem [filespec]\n\n"
installer_text="${installer_text}at the shell prompt."
whiptail --title "${installer_caption}" \
--msgbox "${installer_text}" 15 75
}
check_for_whiptail
check_distro
welcome_message
check_for_emacs
copy_mumps_routines
check_create_directories
copy_manpages
update_emacs_config
copy_lorikeem_elisp
copy_yasnippet
copy_binaries
update_search_path
install_crontab
build_tags
done_message