-
Notifications
You must be signed in to change notification settings - Fork 36
/
install_webwork.sh
248 lines (197 loc) · 6.61 KB
/
install_webwork.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
#!/bin/sh
PREREQUISITES=1
VERBOSE=''
INTERACTIVE=''
MYSQL_ROOT_PW=''
WEBWORK_DB_PW=''
BRANCH=master
WWINSTALLURL=https://github.com/aubreyja/ww_install/archive/$BRANCH.tar.gz
THISDIR="$( pwd )"
usage () {
echo "
NAME
install_webwork.sh
SYNOPSIS
install_webwork.sh [OPTIONS]
DESCRIPTION
install_webwork.sh is the 'controller' that ties together the other scripts
in the ww_install package. It opens an install log, downloads this repo and
opens it in (typically) tmp/. Then it optionally runs install_prerequisites.sh
followed by ww_install.pl. When ww_install.pl exits, install_webwork.sh attempts
to open webwork in the system's default web browser, copies webwork_install.log
to webwork2/logs and then deletes the downloaded installation package.
--h, --help, --usage
Print this help message.
-np, --no-prerequisites
Do not run install_prerequisites.sh before running ww_install.pl. Note that
ww_install.pl will fail if WeBWorK's dependencies are not installed so be
sure that you know all of WeBWorK's prerequisites are installed before using
this option.
-nv, --no-verbose
Turns off vebose output. By default all commands that have the option to provide
verbose output will produce verbose output. This output goes to stdout and to
webwork_install.log and is helpful for debugging if problems arise. If you
want to be all cowboy and throw caution into the wind, then this option will
silence verbose output.
-ni, --no-interactive
Run ww_install.pl non-interactively. This option requires setting both
--mysql_root_pw and --webwork_db_pw. All other webwork configuration
questions asked by ww_install.pl will be answered for you with their
default replies.
--mysql_root_pw PASSWORD
Passes the mysql root password to ww_install.pl. Needed to create the webwork
database. Only required if --no_interactive is set. Otherwise ww_install.pl
will ask you for it.
--webwork_db_pw PASSWORD
Passes the password to use for the webwork database to ww_install.pl. Needed
to grant rights to the webwork db to the webwork db user. Only required
if --no_interactive is set. Otherwise ww_install.pl will ask you for it.
AUTHOR
Written by Jason Aubrey.
REPORTING BUGS
View and report bugs at https://github.com/aubreyja/ww_install/issues
ww_install home page: https://github.com/aubreyja/ww_install
COPYRIGHT
This program is Copyright 2013 by Jason Aubrey. This program is free
software; you can redistribute it and/or modify it under the terms of
the Perl Artistic License or 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.
If you do not have a copy of the GNU General Public License write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
" | less
}
while :
do
case $1 in
-h | --h | --help | -help | --usage | -usage | -\?)
# Call your Help() or usage() function here.
usage
exit 0 # This is not an error, User asked help. Don't do "exit 1"
;;
-np | --no-prerequisites | --no-prereqs)
PREREQUISITES=0
shift
;;
-nv | --no-verbose)
VERBOSE='--no-verbose'
shift
;;
-ni | --no-interactive)
INTERACTIVE='--no-interactive'
shift
;;
--mysql_root_pw)
MYSQL_ROOT_PW="--mysql_root_pw $2"
shift 2
;;
--webwork_db_pw)
WEBWORK_DB_PW="--webwork_db_pw $2"
shift 2
;;
--) # End of all options
shift
break
;;
-*)
echo "WARN: Unknown option (ignored): $1" >&2
shift
;;
*) # no more options. Stop while loop
break
;;
esac
done
if [ "$INTERACTIVE" == "--no-interactive" ]
then
if [ ! "$MYSQL_ROOT_PW" ]
then
echo "ERROR: option --no-interactive requires setting both
--mysql_root_pw and --webwork_db_pw"
exit 1
fi
if [ ! "$WEBWORK_DB_PW" ]
then
echo "ERROR: option --no-interactive requires setting both
--mysql_root_pw and --webwork_db_pw"
exit 1
fi
fi
if [ -z "$TMPDIR" ]; then
if [ -d "/tmp" ]; then
TMPDIR="/tmp"
else
TMPDIR="."
fi
fi
cd $TMPDIR || exit 1
#stdbuf -i0 -o0 -e0 exec 1> >(tee -a webwork_install.log) 2> >(tee -a webwork_install.log >&2)
date
echo "
-----------------------------
This is the WeBWorK installer.
-----------------------------
Please report problems to the issue tracker
at
https://github.com/aubreyja/ww_install
When reporting problems, please include any
relevant output from the webwork_install.log
"
sleep 2
echo "Working in $TMPDIR"
LOCALINSTALLER="ww_install.tar.gz"
echo
if type curl >/dev/null 2>&1; then
WWINSTALLDOWNLOAD="curl -k -f -sS -Lo $LOCALINSTALLER $WWINSTALLURL"
elif type fetch >/dev/null 2>&1; then
WWINSTALLDOWNLOAD="fetch -o $LOCALINSTALLER $WWINSTALLURL"
elif type wget >/dev/null 2>&1; then
WWINSTALLDOWNLOAD="wget --no-check-certificate -O $LOCALINSTALLER $WWINSTALLURL"
else
echo "Need wget or curl to use $0"
exit 1
fi
clean_exit () {
echo "Cleaning up..."
[ -f $LOCALINSTALLER ] && rm $LOCALINSTALLER
[ -d $TMPDIR/ww_install-$BRANCH/ ] && rm -rf $TMPDIR/ww_install-$BRANCH/
[ -f $THISDIR/install_webwork.sh ] && rm $THISDIR/install_webwork.sh
exit $1
}
echo "## Download the latest webwork installer"
$WWINSTALLDOWNLOAD
echo "## Extracting the installer"
tar -xzf $LOCALINSTALLER
rm $LOCALINSTALLER
cd ww_install-$BRANCH/
mv $TMPDIR/webwork_install.log .
if [ $PREREQUISITES -eq 1 ]; then
echo "Installing prerequisites..."
source ./bin/install_prerequisites.sh
wait
fi
perl ./bin/ww_install.pl $VERBOSE $INTERACTIVE $MYSQL_ROOT_PW $WEBWORK_DB_PW
wait
if [ -f "launch_browser.sh" ]; then
echo "Running launch_browser.sh"
bash launch_browser.sh
fi
move_install_log () {
if [ -d "$WEBWORK_ROOT" ]; then
mv $TMPDIR/webwork_install.log $WEBWORK_ROOT/logs
echo "webwork_install.log can be found in $WEBWORK_ROOT/logs"
elif [ -d "$HOME" ]; then
cp $TMPDIR/webwork_install.log $HOME
echo "webwork_install.log can be found in $HOME"
else
echo "webwork_install.log can be found in $TMPDIR"
fi
}
echo
echo "## Done."
move_install_log
clean_exit 1