Menu

[r1]: / install.sh  Maximize  Restore  History

Download this file

358 lines (292 with data), 10.9 kB

  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
#!/bin/bash
APACHE=$(type -p apache2ctl)
JAVA=$(type -p java)
MYSQL=$(type -p mysql)
APACHE_USER=www-data
APACHE_GROUP=www-data
DEFAULT_APACHE_CONF="/etc/apache2/sites-enabled/000-default"
DEFAULT_LOG_DIR="/var/log/etherpad"
DEFAULT_INIT_SCRIPT_NAME="etherpad"
DEFAULT_INIT_SCRIPT_LOC="/etc/init.d/$DEFAULT_INIT_SCRIPT_NAME"
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "ERROR: Please, run installation as root" 1>&2
exit 1
fi
echo "Checking prerequisites..."
# Check if apache is installed
if [[ ! -x $APACHE ]]; then
echo "ERROR: Apache not found"
exit 1
fi
if $APACHE -v | grep "Apache/2" > /dev/null; then
echo -ne "\t* "
$APACHE -v | grep "Apache/2"
else
echo "ERROR: Apache 2 is needed"
exit 1
fi
if ! $APACHE -D DUMP_MODULES 2>&1 | grep rewrite_module > /dev/null; then
echo "ERROR: mod_rewrite needed. Try to run as root 'a2enmod rewrite'"
exit 1
fi
if ! $APACHE -D DUMP_MODULES 2>&1 | grep proxy_module > /dev/null; then
echo "ERROR: mod_proxy needed. Try to run as root 'a2enmod proxy'"
exit 1
fi
if ! $APACHE -D DUMP_MODULES 2>&1 | grep proxy_http_module > /dev/null; then
echo "ERROR: mod_proxy_http needed. Try to run as root 'a2enmod proxy_http'"
exit 1
fi
#if [[ ! -a "/etc/apache2/mods-enabled/rewrite.load" ]]; then
# echo "ERROR: mod_rewrite needed"
# exit 1
#fi
# Check if java 1.6 is installed
if [[ ! -x $JAVA ]]; then
echo "ERROR: Java exec not found in path"
exit 1
fi
if $JAVA -version 2>&1 | grep 'java version "1.6' > /dev/null; then
echo -e "\t* Java 1.6 installed"
else
echo "ERROR: Java 1.6 required"
exit 1
fi
# Check if mysql is installed
if [[ -x $MYSQL ]]; then
echo -e "\t* MySQL client installed"
else
echo "ERROR: MySQL client not found in path"
exit 1
fi
if ! ps -ax 2>/dev/null | grep mysqld | grep -v grep > /dev/null; then
echo "WARNING: MySQL is not running. If you're planning to use it at localhost, please stop this installation (Ctr+C) and start mysqld before continue"
fi
echo "Prerequisites checking done"
while [[ true ]]; do
echo -n "Apache web folder [/var/www]: "
read www
if [[ -z $www ]]; then
www="/var/www"
fi
if [[ ! -a "$www" ]]; then
echo "ERROR: $www doesn't exist"
continue;
fi
echo -n "MySQL host [localhost]: "
read mysql_host
if [[ -z $mysql_host ]]; then
mysql_host="localhost"
fi
echo -n "MySQL port [3306]: "
read mysql_port
if [[ -z $mysql_port ]]; then
mysql_port="3306"
fi
echo -n "MySQL root password: "
stty -echo
read mysql_password
stty echo
echo
echo -n "Etherpad admin password: "
stty -echo
read etherpad_password
stty echo
echo
echo -n "Etherpad database name [etherpad]: "
read etherpad_db_name
if [[ -z $etherpad_db_name ]]; then
etherpad_db_name="etherpad"
fi
echo -n "Etherpad database user name [etherpad]: "
read etherpad_db_username
if [[ -z $etherpad_db_username ]]; then
etherpad_db_username="etherpad"
fi
echo -n "Etherpad database user password: "
stty -echo
read etherpad_db_password
stty echo
echo
echo -n "Etherpad server port [9000]: "
read etherpad_port
if [[ -z $etherpad_port ]]; then
etherpad_port="9000"
fi
domain_name=$(hostname)":80"
echo -n "Domain name and port [$domain_name]: "
read domain_name
if [[ -z $domain_name ]]; then
domain_name=$(hostname)":80"
fi
echo -n "Web application name [dokuwiki]: "
read web_name
if [[ -z $web_name ]]; then
web_name="dokuwiki"
fi
echo -e "\t* Apache web folder: $www"
echo -e "\t* MySQL host and port: $mysql_host:$mysql_port"
echo -e "\t* Etherpad database name: $etherpad_db_name"
echo -e "\t* Etherpad database user name: $etherpad_db_username"
echo -e "\t* Etherpad port: $etherpad_port"
echo -e "\t* Domain name and port: $domain_name"
echo -e "\t* Web application name: $web_name"
echo -n "Is this correct? [n]: "
read ans
case $ans in
Y|y) break;;
[Yy][Ee][Ss]) break;;
*)
esac
done
DEFAULT_INIT_SCRIPT_NAME="$DEFAULT_INIT_SCRIPT_NAME""_$etherpad_port.sh"
DEFAULT_INIT_SCRIPT_LOC="/etc/init.d/$DEFAULT_INIT_SCRIPT_NAME"
echo -n "Creating etherpad configuration file..."
etherdoku_conf="dokuwiki/etherpad/trunk/etherpad/etc/etherpad.localdev-default.properties"
echo "ajstdlibHome = ../infrastructure/framework-src/modules" > $etherdoku_conf
echo "appjetHome = ./data/appjet" >> $etherdoku_conf
echo "devMode = true" >> $etherdoku_conf
echo "etherpad.adminPass = $etherpad_password" >> $etherdoku_conf
echo "etherpad.fakeProduction = false" >> $etherdoku_conf
echo "etherpad.isProduction = false" >> $etherdoku_conf
echo "etherpad.SQL_JDBC_DRIVER = com.mysql.jdbc.Driver" >> $etherdoku_conf
echo "etherpad.SQL_JDBC_URL = jdbc:mysql://$mysql_host:$mysql_port/$etherpad_db_name" >> $etherdoku_conf
echo "etherpad.SQL_PASSWORD = $etherpad_db_password" >> $etherdoku_conf
echo "etherpad.SQL_USERNAME = $etherpad_db_username" >> $etherdoku_conf
echo "listen = 0.0.0.0:$etherpad_port" >> $etherdoku_conf
echo "logDir = ./data/logs" >> $etherdoku_conf
echo "modulePath = ./src" >> $etherdoku_conf
echo "transportPrefix = /comet" >> $etherdoku_conf
echo "transportUseWildcardSubdomains = true" >> $etherdoku_conf
echo "useVirtualFileRoot = ./src" >> $etherdoku_conf
echo "wikiurl = http://$domain_name/$web_name/etherpad" >> $etherdoku_conf
echo "wikilockspath= ../../../data/locks/" >> $etherdoku_conf
echo "wikilocktime=900000" >> $etherdoku_conf
echo "etherpad.skipHostnameCheck=true" >> $etherdoku_conf
echo " done"
if [[ -a "$www/$web_name" ]]; then
echo -n "WARNING: $www/$web_name exists. Press Ctr+C now if you want to cancel the installation or ENTER if you wish to overwrite it "
read
if ! rm -fr "$www/$web_name" ; then
echo "ERROR: Can't delete $www/$web_name"
exit 1
else
echo "$www/$web_name deleted"
fi
fi
echo -n "Copying files..."
mkdir "$www/$web_name"
if ! cp -R dokuwiki/* "$www/$web_name/" ; then
echo "ERROR: copying files failed"
exit 1
fi
echo " done"
echo -n "Creating etherpad DB '$etherpad_db_name' if not exists..."
if ! echo "create database if not exists $etherpad_db_name;" | $MYSQL -u root --password="$mysql_password" -h $mysql_host -P $mysql_port ; then
echo "ERROR: Can't create database"
exit 1
fi
echo " done"
echo -n "Removing previous etherpad DB user if exists..."
echo "DROP USER '$etherpad_db_username'@'localhost';" | $MYSQL -u root --password="$mysql_password" -h $mysql_host -P $mysql_port 2>/dev/null
echo "DROP USER '$etherpad_db_username'@'%';" | $MYSQL -u root --password="$mysql_password" -h $mysql_host -P $mysql_port 2>/dev/null
echo " done"
echo -n "Creating etherpad DB user..."
if ! echo "CREATE USER '$etherpad_db_username'@'localhost' identified by '$etherpad_db_password';" | $MYSQL -u root --password="$mysql_password" -h $mysql_host -P $mysql_port ; then
echo "ERROR: Can't create etherpad DB user"
exit 1
fi
if ! echo "CREATE USER '$etherpad_db_username'@'%' identified by '$etherpad_db_password';" | $MYSQL -u root --password="$mysql_password" -h $mysql_host -P $mysql_port ; then
echo "ERROR: Can't create etherpad DB user"
exit 1
fi
if ! echo "grant all privileges on $etherpad_db_name.* to '$etherpad_db_username'@'localhost' identified by '$etherpad_db_password';" | $MYSQL -u root --password="$mysql_password" -h $mysql_host -P $mysql_port ; then
echo "ERROR: Can't grant privileges to etherpad DB user"
exit 1
fi
if ! echo "grant all privileges on $etherpad_db_name.* to '$etherpad_db_username'@'%' identified by '$etherpad_db_password';" | $MYSQL -u root --password="$mysql_password" -h $mysql_host -P $mysql_port ; then
echo "ERROR: Can't grant privileges to etherpad DB user"
exit 1
fi
echo " done"
echo -n "Changing files owner..."
if ! chown -R $APACHE_USER "$www/$web_name" && chown root "$www/$web_name/etherpad/trunk/etherpad/etc/etherpad.localdev-default.properties" ; then
echo "ERROR: Can't change files owner. Maybe $APACHE_USER user doesn't exist"
exit 1
fi
echo " done"
echo -n "Changing files group..."
if ! chgrp -R $APACHE_GROUP "$www/$web_name" && chgrp root "$www/$web_name/etherpad/trunk/etherpad/etc/etherpad.localdev-default.properties" ; then
echo "ERROR: Can't change files group. Maybe $APACHE_GROUP group doesn't exist"
exit 1
fi
echo " done"
echo -n "Setting permissions to config file..."
if ! chmod o=-r "$www/$web_name/etherpad/trunk/etherpad/etc/etherpad.localdev-default.properties" ; then
echo "ERROR: Can't change permissions"
exit 1
fi
echo " done"
echo -n "Setting permissions to startup script..."
if ! chmod +x "$www/$web_name/etherpad/trunk/etherpad/bin/run-local.sh" ; then
echo "ERROR: Can't change permissions"
exit 1
fi
echo " done"
echo -n "Creating apache config file..."
if ! echo -e "RewriteEngine on\nRewriteRule ^(.*)$ http://%{SERVER_NAME}:$etherpad_port/\$1 [P]" > "$www/$web_name/etherpad/.htaccess" ; then
echo "ERROR: Can't create apache config file"
exit 1
fi
echo " done"
if [[ ! -a "$DEFAULT_LOG_DIR" ]] ; then
echo -n "Creating log dir..."
if ! mkdir "$DEFAULT_LOG_DIR" ; then
echo "ERROR: Can't create log dir at $DEFAULT_LOG_DIR"
exit 1
fi
if ! chown -R root "$DEFAULT_LOG_DIR" ; then
echo "ERROR: Can't set root owner to $DEFAULT_LOG_DIR"
exit 1
fi
echo " done"
fi
echo -n "Adding etherpad startup script to $DEFAULT_INIT_SCRIPT_LOC..."
if ! echo "export PATH=$PATH" > "$DEFAULT_INIT_SCRIPT_LOC" ; then
echo "ERROR: Can't create $DEFAULT_INIT_SCRIPT_LOC"
exit 1
fi
if ! echo BASE="$www/$web_name" >> $DEFAULT_INIT_SCRIPT_LOC ; then
echo "ERROR: Can't create $DEFAULT_INIT_SCRIPT_LOC"
exit 1
fi
if ! echo LOG="$DEFAULT_LOG_DIR"/log_"$etherpad_port.log" >> $DEFAULT_INIT_SCRIPT_LOC ; then
echo "ERROR: Can't create $DEFAULT_INIT_SCRIPT_LOC"
exit 1
fi
if ! echo ERROR_LOG="$DEFAULT_LOG_DIR"/error_"$etherpad_port.log" >> $DEFAULT_INIT_SCRIPT_LOC ; then
echo "ERROR: Can't create $DEFAULT_INIT_SCRIPT_LOC"
exit 1
fi
if ! cat "$www/$web_name/etherpad/trunk/etherpad/bin/etherpad.sh" >> $DEFAULT_INIT_SCRIPT_LOC ; then
echo "ERROR: Can't create $DEFAULT_INIT_SCRIPT_LOC"
exit 1
fi
if ! chmod +x $DEFAULT_INIT_SCRIPT_LOC ; then
echo "ERROR: Can't set permissions for $DEFAULT_INIT_SCRIPT_LOC"
exit 1
fi
echo "Removing previous init script"
update-rc.d -f $DEFAULT_INIT_SCRIPT_NAME remove 2>/dev/null
if ! update-rc.d $DEFAULT_INIT_SCRIPT_NAME defaults ; then
echo "ERROR: Can't add etherpad startup script. Please do it manually and start etherpad"
fi
echo " done"
echo -n "Starting etherpad..."
nohup $DEFAULT_INIT_SCRIPT_LOC restart 2>/dev/null >/dev/null &
echo " done"
if ! cat $DEFAULT_APACHE_CONF 2>/dev/null | grep "AllowOverride All" >/dev/null ; then
echo "WARNING: Can't find 'AllowOverride All' directive in $DEFAULT_APACHE_CONF. Please be sure that you have that directive in your apache configuration. Otherwise etherpad won't work"
fi
echo "Installation finished. If you wish to customize your dokuwiki installation, please go to http://$domain_name/$web_name/install.php"
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.