-
Notifications
You must be signed in to change notification settings - Fork 243
/
Copy pathpostinst
533 lines (451 loc) · 28.6 KB
/
postinst
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
#!/bin/bash
KALTURA_FUNCTIONS_RC=/opt/kaltura/bin/kaltura-functions.rc
if [ ! -r "$KALTURA_FUNCTIONS_RC" ];then
OUT="${BRIGHT_RED}ERROR:could not find $KALTURA_FUNCTIONS_RC so, exiting..${NORMAL}"
echo -en $OUT
exit 3
fi
. $KALTURA_FUNCTIONS_RC
KALTURA_PREFIX=/opt/kaltura
APP_DIR=/opt/kaltura/app
KALTURA_GROUP=kaltura
KALTURA_USER=kaltura
APACHE_USER=www-data
KALTURA_VERSION="`dpkg-query -W -f'${Version}' kaltura-base|awk -F "+" '{print $1}'`"
if [ -d $KALTURA_PREFIX/web/content/clientlibs ];then
mv $KALTURA_PREFIX/web/content/clientlibs $KALTURA_PREFIX/web/content/clientlibs.orig
fi
ln -sf $KALTURA_PREFIX/apps/clientlibs $KALTURA_PREFIX/web/content
ln -sf $KALTURA_PREFIX/app/api_v3/web $KALTURA_PREFIX/app/alpha/web/api_v3
chown $APACHE_USER.kaltura -R $KALTURA_PREFIX/web/content/entry $KALTURA_PREFIX/web/content/uploads/ $KALTURA_PREFIX/web/tmp/ $KALTURA_PREFIX/tmp
find $KALTURA_PREFIX/web/content/entry $KALTURA_PREFIX/web/content/uploads/ $KALTURA_PREFIX/web/tmp/ -type d -exec chmod 775 {} \;
if [ -r $KALTURA_PREFIX/bin/kaltura-base-upgrading ];then
if [ -r "$KALTURA_PREFIX/app/configurations/local.ini" -a -r "$KALTURA_PREFIX/app/configurations/base.ini" ];then
if [ -r $KALTURA_PREFIX/bin/kaltura-functions.rc ];then
. $KALTURA_PREFIX/bin/kaltura-functions.rc
. /usr/share/debconf/confmodule
db_get 'kaltura-base/time_zone'
if [ -n "$RET" ];then
TIME_ZONE=$RET
else
db_set 'kaltura-base/time_zone' $TZGUESS
LOCALTIME_MD5=`md5sum /etc/localtime|awk -F " " '{print $1}'`
TIME_ZONE=`find /usr/share/zoneinfo -type f | xargs md5sum | grep $LOCALTIME_MD5|awk -F " " '{print $2}'|sed 's@/usr/share/zoneinfo/@@g'`
fi
db_stop
send_install_becon "`basename $0`" "install_upgrade" 0
fi
sed -i "s@^\(kaltura_version\).*@\1 = $KALTURA_VERSION@g" $KALTURA_PREFIX/app/configurations/local.ini
echo "Regenarating client libs.. this will take up to 2 minutes to complete."
# stupidly and only for apache2, service apache2 status outputs to PAGER, thus no good for auto upgrades
if /etc/init.d/apache2 status ;then
invoke-rc.d apache2 stop
invoke-rc.d monit stop
RESTART_APACHE=true
fi
# this is read by kaltura-sphinx-schema-update.sh to determine rather or not to run
touch $KALTURA_PREFIX/app/configurations/sphinx_schema_update
rm -rf $KALTURA_PREFIX/app/cache/*
php $KALTURA_PREFIX/app/generator/generate.php
find $KALTURA_PREFIX/app/cache/ $KALTURA_PREFIX/log $KALTURA_PREFIX/var/run -type d -exec chmod 775 {} \;
find $KALTURA_PREFIX/app/cache/ $KALTURA_PREFIX/log -type f -exec chmod 664 {} \;
chown -R $KALTURA_USER.$APACHE_USER $KALTURA_PREFIX/app/cache/ $KALTURA_PREFIX/log $KALTURA_PREFIX/var/run
chmod 775 $KALTURA_PREFIX/web/content
if [ -n "$RESTART_APACHE" ];then
invoke-rc.d apache2 start
fi
invoke-rc.d monit start
sleep 70
# we now need CREATE and DROP priv for 'kaltura' on kaltura.*
if [ -r /etc/kaltura.d/system.ini ];then
. /etc/kaltura.d/system.ini
# disbale Default_Akamai_HLS_direct since we want the nginx vod-module profile to be used [ID 1001, system_name: Kaltura HLS segmentation]
echo "update delivery_profile set is_default=0 where id=1 and system_name='Default_Akamai_HLS_direct';"|mysql -h$DB1_HOST -u $DB1_USER -p$DB1_PASS -P$DB1_PORT $DB1_NAME
echo "GRANT INSERT,UPDATE,DELETE,SELECT,ALTER,DROP,CREATE ON kaltura.* TO '$DB1_USER'@'%';FLUSH PRIVILEGES;"|mysql -h$DB1_HOST -u $SUPER_USER -p$SUPER_USER_PASSWD -P$DB1_PORT
echo "GRANT INSERT,UPDATE,DELETE,SELECT,ALTER,DROP,CREATE ON kaltura_sphinx_log.* TO '$DB1_USER'@'%';FLUSH PRIVILEGES;"|mysql -h$DB1_HOST -u $SUPER_USER -p$SUPER_USER_PASSWD -P$DB1_PORT
echo "ALTER TABLE kaltura_sphinx_log.sphinx_log ADD type INT AFTER created_at;"|mysql -h$DB1_HOST -u $SUPER_USER -p$SUPER_USER_PASSWD -P$DB1_PORT 2>/dev/null|| true
fi
MINUS_2_PARTNER_ADMIN_SECRET=`echo "select admin_secret from partner where id=-2"|mysql -N -h$DB1_HOST -u$DB1_USER -p$DB1_PASS $DB1_NAME -P$DB1_PORT`
CONF_FILES=`find $APP_DIR/deployment/updates/ -type f -name "*template.xml"`
for TMPL_CONF_FILE in $CONF_FILES;do
CONF_FILE=`echo $TMPL_CONF_FILE | sed 's@\(.*\)\.template\(.*\)@\1\2@'`
if [ -r $CONF_FILE ];then
cp $CONF_FILE $CONF_FILE.backup
fi
if `echo $TMPL_CONF_FILE|grep -q template`;then
cp $TMPL_CONF_FILE $CONF_FILE
fi
sed -e "s#@ADMIN_CONSOLE_PARTNER_ADMIN_SECRET@#$MINUS_2_PARTNER_ADMIN_SECRET#g" -e "s#@SERVICE_URL@#$SERVICE_URL#g" -i $CONF_FILE
done
mysql -h$DB1_HOST -u $SUPER_USER -p$SUPER_USER_PASSWD -P$DB1_PORT $DB1_NAME < $KALTURA_PREFIX/app/deployment/updates/fix_version_management.sql 2>/dev/null|| true
php $KALTURA_PREFIX/app/deployment/updates/update.php -i -d >> /opt/kaltura/log/kalt_up.log 2>&1
php $KALTURA_PREFIX/app/deployment/updates/update.php -i -s >> /opt/kaltura/log/kalt_up.log 2>&1
php $KALTURA_PREFIX/app/deployment/base/scripts/installPlugins.php >> /opt/kaltura/log/kalt_up.log 2>&1
fi
rm $KALTURA_PREFIX/bin/kaltura-base-upgrading
exit 0
fi
set -e
if [ "$1" = "configure" ]; then
THE_HOSTAME=`hostname`
if [ -x "`which php5enmod 2>/dev/null`" ];then
php5enmod mcrypt
fi
if [ -x /opt/kaltura/bin/php7enmod ];then
/opt/kaltura/bin/php7enmod mcrypt
fi
. /usr/share/debconf/confmodule
KALT_CONF_DIR=$APP_DIR/configurations/
BEGINNERS_TUTORIAL_URL=http://bit.ly/KalturaUploadMenu
QUICK_START_GUIDE_URL=http://bit.ly/KalturaKmcManual
FORUMS_URLS=http://bit.ly/KalturaForums
db_get 'kaltura-base/cdn_hostname'
if [ -z "$RET" ];then
db_set 'kaltura-base/cdn_hostname' "$THE_HOSTAME"
fi
db_input critical 'kaltura-base/cdn_hostname' || true
db_go || true
db_get 'kaltura-base/cdn_hostname'
CDN_HOST=$RET
db_get 'kaltura-base/apache_hostname'
if [ -z "$RET" ];then
db_set 'kaltura-base/apache_hostname' "$THE_HOSTAME"
fi
db_input critical 'kaltura-base/apache_hostname' || true
db_go || true
#echo "set kaltura-base/apache_hostname $CDN_HOST" | debconf-communicate
db_get 'kaltura-base/apache_hostname'
KALTURA_VIRTUAL_HOST_NAME=$RET
db_get 'kaltura-base/vhost_port'
if [ -z "$RET" ];then
db_set 'kaltura-base/vhost_port' 80
fi
db_input critical 'kaltura-base/vhost_port' || true
db_go || true
db_get 'kaltura-base/vhost_port'
KALTURA_VIRTUAL_HOST_PORT=$RET
if [ "$KALTURA_VIRTUAL_HOST_PORT" -eq 443 ];then
PROTOCOL=https
else
PROTOCOL=http
fi
if [ "$KALTURA_VIRTUAL_HOST_PORT" -eq 443 -o "$KALTURA_VIRTUAL_HOST_PORT" -eq 80 ];then
KALTURA_FULL_VIRTUAL_HOST_NAME="$KALTURA_VIRTUAL_HOST_NAME"
else
KALTURA_FULL_VIRTUAL_HOST_NAME="$KALTURA_VIRTUAL_HOST_NAME:$KALTURA_VIRTUAL_HOST_PORT"
fi
db_get 'kaltura-base/db_hostname'
if [ -z "$RET" ];then
db_set 'kaltura-base/db_hostname' "$THE_HOSTAME"
fi
db_input critical 'kaltura-base/db_hostname' || true
db_go || true
db_get 'kaltura-base/db_hostname'
DB1_HOST=$RET
db_input critical 'kaltura-base/db_port' || true
db_go || true
db_get 'kaltura-base/db_port'
DB1_PORT=$RET
db_input critical 'kaltura-base/mysql_super_user' || true
db_go || true
db_get 'kaltura-base/mysql_super_user'
SUPER_USER=$RET
db_input critical 'kaltura-base/mysql_super_passwd' || true
db_go || true
db_get 'kaltura-base/mysql_super_passwd'
SUPER_USER_PASSWD=$RET
db_get 'kaltura-base/dwh_db_hostname'
if [ -z "$RET" ];then
db_set 'kaltura-base/dwh_db_hostname' "$THE_HOSTAME"
fi
db_input critical 'kaltura-base/dwh_db_hostname' || true
#db_set 'kaltura-base/dwh_db_hostname' $DB1_HOST
db_go || true
db_get 'kaltura-base/dwh_db_hostname'
DWH_HOST=$RET
db_input critical 'kaltura-base/dwh_db_port' || true
db_go || true
db_get 'kaltura-base/dwh_db_port'
DWH_PORT=$RET
db_get 'kaltura-base/sphinx_hostname'
if [ -z "$RET" ];then
db_set 'kaltura-base/sphinx_hostname' "$THE_HOSTAME"
fi
db_input critical 'kaltura-base/sphinx_hostname' || true
db_go || true
db_get 'kaltura-base/sphinx_hostname'
SPHINX_SERVER1=$RET
db_get 'kaltura-base/second_sphinx_hostname'
if [ -z "$RET" ];then
db_set 'kaltura-base/second_sphinx_hostname' "$SPHINX_SERVER1"
fi
db_input critical 'kaltura-base/second_sphinx_hostname' || true
db_go || true
db_get 'kaltura-base/second_sphinx_hostname'
SPHINX_SERVER2=$RET
db_get 'kaltura-base/apache_hostname'
APACHE_HOST="$RET"
db_get 'kaltura-base/vhost_port'
APACHE_PORT="$RET"
db_get 'kaltura-base/service_url'
if [ -z "$RET" ] ;then
if [ "$APACHE_PORT" -eq 443 ];then
DEF_SERVICE_URL="https://$APACHE_HOST"
elif [ "$APACHE_PORT" -eq 80 ];then
DEF_SERVICE_URL="http://$APACHE_HOST"
else
DEF_SERVICE_URL="http://$APACHE_HOST:$APACHE_PORT"
fi
db_set 'kaltura-base/service_url' $DEF_SERVICE_URL
fi
db_input critical 'kaltura-base/service_url' || true
db_go || true
db_get 'kaltura-base/service_url'
SERVICE_URL=$RET
db_input critical 'kaltura-base/ip_range' || true
db_go || true
db_get 'kaltura-base/ip_range'
IP_RANGE=$RET
db_get 'kaltura-base/vod_packager_hostname'
if [ -z "$RET" ];then
db_set 'kaltura-base/vod_packager_hostname' "$THE_HOSTAME"
fi
db_input critical 'kaltura-base/vod_packager_hostname' || true
db_go || true
db_get 'kaltura-base/vod_packager_hostname'
VOD_PACKAGER_HOST=$RET
db_input critical 'kaltura-base/vod_packager_port' || true
db_go || true
db_get 'kaltura-base/vod_packager_port'
VOD_PACKAGER_PORT=$RET
db_input critical 'kaltura-base/admin_console_email' || true
db_go || true
db_get 'kaltura-base/admin_console_email'
ADMIN_CONSOLE_ADMIN_MAIL=$RET
db_get 'kaltura-base/admin_console_passwd'
ADMIN_CONSOLE_PASSWORD=$RET
db_get 'kaltura-base/admin_console_passwd_again'
AGAIN_ADMIN_CONSOLE_PASSWORD=$RET
if [ "$ADMIN_CONSOLE_PASSWORD" != "$AGAIN_ADMIN_CONSOLE_PASSWORD" ];then
unset ADMIN_CONSOLE_PASSWORD
unset AGAIN_ADMIN_CONSOLE_PASSWORD
fi
while [ -z "$AGAIN_ADMIN_CONSOLE_PASSWORD" ];do
db_input critical 'kaltura-base/admin_console_passwd' || true
db_go || true
db_get 'kaltura-base/admin_console_passwd'
ADMIN_CONSOLE_PASSWORD=$RET
if echo $ADMIN_CONSOLE_PASSWORD | grep -q "/\|&\|>\|<" ;then
db_input critical kaltura-base/passwd_invalid_char || true
db_go
unset ADMIN_CONSOLE_PASSWORD
continue
fi
db_input critical 'kaltura-base/admin_console_passwd_again' || true
db_go || true
db_get 'kaltura-base/admin_console_passwd_again'
AGAIN_ADMIN_CONSOLE_PASSWORD=$RET
if [ "$ADMIN_CONSOLE_PASSWORD" != "$AGAIN_ADMIN_CONSOLE_PASSWORD" ];then
db_input critical kaltura-base/passwd_dont_match || true
db_go
unset AGAIN_ADMIN_CONSOLE_PASSWORD
fi
done
db_get 'kaltura-base/time_zone'
if [ -z "$RET" ];then
db_set 'kaltura-base/time_zone' $TZGUESS
LOCALTIME_MD5=`md5sum /etc/localtime|awk -F " " '{print $1}'`
TZGUESS=`find /usr/share/zoneinfo -type f | xargs md5sum | grep $LOCALTIME_MD5|awk -F " " '{print $2}'|sed 's@/usr/share/zoneinfo/@@g'`
fi
set +e
TIME_ZONE="$TZGUESS"
while ! php -r "if (timezone_open('$TIME_ZONE') === false){exit(1);}" >>/dev/null 2>&1;do
db_input critical 'kaltura-base/time_zone' || true
db_go || true
db_get 'kaltura-base/time_zone'
TIME_ZONE=$RET
done
set -e
db_input critical 'kaltura-base/env_name' || true
db_go || true
db_get 'kaltura-base/env_name'
ENVIRONMENT_NAME=$RET
db_input critical 'kaltura-base/contact_url' || true
db_go || true
db_get 'kaltura-base/contact_url'
CONTACT_URL=$RET
db_input critical 'kaltura-base/contact_phone' || true
db_go || true
db_get 'kaltura-base/contact_phone'
CONTACT_PHONE_NUMBER=$RET
db_input critical 'kaltura-base/install_analytics_consent' || true
db_go || true
db_get 'kaltura-base/install_analytics_consent'
USER_CONSENT=$RET
if [ "$USER_CONSENT" = true ];then
echo "USER_CONSENT=1" > $CONSENT_FILE
echo "CONTACT_MAIL=$ADMIN_CONSOLE_ADMIN_MAIL" >> $CONSENT_FILE
else
echo "USER_CONSENT=0" > $CONSENT_FILE
fi
if [ -z "$DB1_PASS" ];then
db_input critical 'kaltura-base/auto_generate_kaltura_mysql_passwd' || true
db_go || true
db_get 'kaltura-base/auto_generate_kaltura_mysql_passwd'
if [ "$RET" = true ];then
DB1_PASS=`< /dev/urandom tr -dc A-Za-z0-9 | head -c15`
set +e
echo "update mysql.user set password=PASSWORD('$DB1_PASS') WHERE user='kaltura';flush PRIVILEGES" | mysql -h$DB1_HOST -P$DB1_PORT -u$SUPER_USER -p$SUPER_USER_PASSWD mysql
set -e
else
while [ -z "$AGAIN_DB1_PASS" ];do
db_input critical 'kaltura-base/kaltura_mysql_passwd' || true
db_go || true
db_get 'kaltura-base/kaltura_mysql_passwd'
DB1_PASS=$RET
if echo $DB1_PASS | grep -q "/" ;then
db_input critical kaltura-base/passwd_invalid_char || true
db_go
unset DB1_PASS
continue
fi
db_input critical 'kaltura-base/kaltura_mysql_passwd_again' || true
db_go || true
db_get 'kaltura-base/kaltura_mysql_passwd_again'
AGAIN_DB1_PASS=$RET
if [ "$DB1_PASS" != "$AGAIN_DB1_PASS" ];then
db_input critical kaltura-base/passwd_dont_match || true
db_go
unset AGAIN_DB1_PASS
fi
done
fi
if [ -z "$DWH_PASS" ];then
DWH_PASS=$DB1_PASS
fi
fi
DB1_NAME=kaltura
DB1_USER=kaltura
db_stop
for INI in /etc/php5/cli/php.ini /etc/php5/apache2/php.ini /opt/kaltura/app/configurations/php/apache2/php.ini /opt/kaltura/app/configurations/php/cli/php.ini;do
if [ -r "$INI_FILE" ];then
sed -i "s#\(date.timezone\)\s*=.*#\1='$TIME_ZONE'#g" $INI_FILE
fi
done
# no added value in putting this on a separate server..
SPHINX_DB_HOST=$DB1_HOST
SPHINX_DB_PORT=$DB1_PORT
APP_REMOTE_ADDR_HEADER_SALT=`echo $SERVICE_URL|base64 -w0`
CONF_FILES=`find $KALT_CONF_DIR -type f -name "*template*"`
CONF_FILES="$CONF_FILES $BASE_DIR/app/batch/batches/Mailer/emails_en.template.ini $BASE_DIR/app/tests/monitoring/config.template.ini $BASE_DIR/bin/sanity_config.template.ini"
#if STUDIO_VER=`dpkg-query -W -f'${Version}' kaltura-html5-studio |awk -F "+" '{print $1}' 2>/dev/null`;then
# CONF_FILES="$CONF_FILES $BASE_DIR/apps/studio/$STUDIO_VER/studio.template.ini"
#fi
CONF_FILES="$CONF_FILES `find $BASE_DIR/app/plugins/monitor/nagios/config -type f -name "*template*"`"
if [ -d "$BASE_DIR/dwh" ];then
CONF_FILES="$CONF_FILES `find $BASE_DIR/dwh -type f -name "*template*"`"
fi
# Now we will sed.
ENCRYPTION_IV=`< /dev/urandom tr -dc "A-Za-z0-9" | head -c16`
for TMPL_CONF_FILE in $CONF_FILES;do
CONF_FILE=`echo $TMPL_CONF_FILE | sed 's@\(.*\)\.template\(.*\)@\1\2@'`
if [ -r $CONF_FILE ];then
cp $CONF_FILE $CONF_FILE.backup
fi
if `echo $TMPL_CONF_FILE|grep -q template`;then
cp $TMPL_CONF_FILE $CONF_FILE
fi
sed -e "s#@ENVIRONMENT_PROTOCOL@#$PROTOCOL#g" -e "s#@PROTOCOL@#$PROTOCOL#g" -e "s#@CDN_HOST@#$CDN_HOST#g" -e "s#@DB[1-9]_HOST@#$DB1_HOST#g" -e "s#@DB[1-9]_NAME@#$DB1_NAME#g" -e "s#@DB[1-9]_USER@#$DB1_USER#g" -e "s#@DB[1-9]_PASS@#$DB1_PASS#g" -e "s#@DB[1-9]_PORT@#$DB1_PORT#g" -e "s#@TIME_ZONE@#$TIME_ZONE#g" -e "s#@KALTURA_FULL_VIRTUAL_HOST_NAME@#$KALTURA_FULL_VIRTUAL_HOST_NAME#g" -e "s#@KALTURA_VIRTUAL_HOST_NAME@#$KALTURA_VIRTUAL_HOST_NAME#g" -e "s#@SERVICE_URL@#$SERVICE_URL#g" -e "s#@WWW_HOST@#$KALTURA_FULL_VIRTUAL_HOST_NAME#g" -e "s#@SPHINX_DB_NAME@#kaltura_sphinx_log#g" -e "s#@SPHINX_DB_HOST@#$SPHINX_DB_HOST#g" -e "s#@SPHINX_DB_PORT@#$DB1_PORT#g" -e "s#@DWH_HOST@#$DWH_HOST#g" -e "s#@DWH_PORT@#$DWH_PORT#g" -e "s#@SPHINX_SERVER1@#$SPHINX_SERVER1#g" -e "s#@SPHINX_SERVER2@#$SPHINX_SERVER2#g" -e "s#@DWH_DATABASE_NAME@#kalturadw#g" -e "s#@DWH_USER@#etl#g" -e "s#@DWH_PASS@#$DWH_PASS#g" -e "s#@ADMIN_CONSOLE_ADMIN_MAIL@#$ADMIN_CONSOLE_ADMIN_MAIL#g" -e "s#@WEB_DIR@#$BASE_DIR/web#g" -e "s#@LOG_DIR@#$BASE_DIR/log#g" -e "s#$BASE_DIR/app#$BASE_DIR/app#g" -e "s#@PHP_BIN@#/usr/bin/php#g" -e "s#@OS_KALTURA_USER@#kaltura#g" -e "s#@BASE_DIR@#$BASE_DIR#" -e "s#@APP_DIR@#$BASE_DIR/app#g" -e "s#@DWH_DIR@#$BASE_DIR/dwh#g" -e "s#@KETTLE_SH@#/opt/kaltura/pentaho/pdi/kitchen.sh#g" -e "s#@EVENTS_LOGS_DIR@#$BASE_DIR/web/logs#g" -e "s#@TMP_DIR@#$BASE_DIR/tmp#g" -e "s#@APACHE_SERVICE@#apache2#g" -e "s#@KALTURA_VIRTUAL_HOST_PORT@#$KALTURA_VIRTUAL_HOST_PORT#g" -e "s#@BIN_DIR@#$BASE_DIR/bin#g" -e "s#@KALTURA_VERSION@#$KALTURA_VERSION#g" -e "s#@SPHINX_SERVER@#$SPHINX_SERVER#g" -e "s#@IMAGE_MAGICK_BIN_DIR@#/usr/bin#g" -e "s#@CURL_BIN_DIR@#/usr/bin#g" -e "s@^\(bin_path_mediainfo\).*@\1=/usr/bin/mediainfo@g" -e "s#@CONTACT_URL@#$CONTACT_URL#g" -e "s#@ENVIRONMENT_NAME@#\"$ENVIRONMENT_NAME\"#g" -e "s#@BEGINNERS_TUTORIAL_URL@#$BEGINNERS_TUTORIAL_URL#g" -e "s#@BEGINNERS_TUTORIAL_URL@#$BEGINNERS_TUTORIAL_URL#g" -e "s#@QUICK_START_GUIDE_URL@#$QUICK_START_GUIDE_URL#g" -e "s#@FORUMS_URLS@#$FORUMS_URLS#g" -e "s#@CONTACT_PHONE_NUMBER@#\"$CONTACT_PHONE_NUMBER\"#g" -e "s#@UNSUBSCRIBE_EMAIL_URL@#$SERVICE_URL/index.php/extwidget/blockMail?e=#g" -e "s#@UICONF_TAB_ACCESS@#SYSTEM_ADMIN_BATCH_CONTROL#g" -e "s#@EVENTS_FETCH_METHOD@#local#g" -e "s#@HTML5_VER@#$HTML5_VER#g" -e "s#@MONIT_PASSWD@#$DB1_PASS#g" -e "s#@VOD_PACKAGER_HOST@#$VOD_PACKAGER_HOST#g" -e "s#@VOD_PACKAGER_PORT@#$VOD_PACKAGER_PORT#g" -e "s#@LIVE_PACKAGER_HOST@#$VOD_PACKAGER_HOST#g" -e "s#@LIVE_PACKAGER_PORT@#$VOD_PACKAGER_PORT#g" -e "s#@IP_RANGE@#$IP_RANGE#g" -e "s#@APP_REMOTE_ADDR_HEADER_SALT@#\"$APP_REMOTE_ADDR_HEADER_SALT\"#g" -e "s#@DEFAULT_IV_16B@#\"$ENCRYPTION_IV\"#g" -e "s#@MEMACHED_HOSTNAME@#127.0.0.1#g" -e "s#@MEMACHED_HOST NAME_FOR_WRITE@#127.0.0.1#g" -e "s#@MEMACHED_PORT@#11211#g" -i $CONF_FILE
done
# these two have passwds in them.
chown $KALTURA_USER.$APACHE_USER $BASE_DIR/app/configurations/system.ini $BASE_DIR/app/configurations/db.ini $BASE_DIR/app/configurations/batch/batch.ini $BASE_DIR/app/configurations/local.ini
chmod 640 $BASE_DIR/app/configurations/system.ini $BASE_DIR/app/configurations/db.ini $BASE_DIR/app/configurations/batch/batch.ini $BASE_DIR/app/configurations/local.ini
# gen secrets
ADMIN_SECRET=`gen_partner_secret`
ADMIN_CONSOLE_PARTNER_SECRET=`gen_partner_secret`
MONITOR_PARTNER_ADMIN_SECRET=`gen_partner_secret`
MONITOR_PARTNER_SECRET=`gen_partner_secret`
PARTNER_MONITORING_PROXY_ADMIN_SECRET=`gen_partner_secret`
PARTNER_MONITORING_PROXY_SECRET=`gen_partner_secret`
PARTNER_KMC_SSO_ADMIN_SECRET=`gen_partner_secret`
PARTNER_KMC_SSO_SECRET=`gen_partner_secret`
PARTNER_ZERO_ADMIN_SECRET=`gen_partner_secret`
PARTNER_ZERO_SECRET=`gen_partner_secret`
BATCH_PARTNER_ADMIN_SECRET=`gen_partner_secret`
BATCH_PARTNER_SECRET=`gen_partner_secret`
MEDIA_PARTNER_ADMIN_SECRET=`gen_partner_secret`
MEDIA_PARTNER_SECRET=`gen_partner_secret`
TEMPLATE_PARTNER_ADMIN_SECRET=`gen_partner_secret`
TEMPLATE_PARTNER_ADMIN_PASSWORD="0+`< /dev/urandom tr -dc "A-Za-z0-9_=@%$" | head -c8`=*1"
TEMPLATE_PARTNER_SECRET=`gen_partner_secret`
HOSTED_PAGES_PARTNER_ADMIN_SECRET=`gen_partner_secret`
HOSTED_PAGES_PARTNER_SECRET=`gen_partner_secret`
PLAY_PARTNER_ADMIN_SECRET=`gen_partner_secret`
PLAY_PARTNER_SECRET=`gen_partner_secret`
# SQL statement files tokens:
for TMPL in `find $BASE_DIR/app/deployment/base/scripts/init_content/ -name "*template*"`;do
DEST_FILE=`echo $TMPL | sed 's@\(.*\)\.template\(.*\)@\1\2@'`
cp $TMPL $DEST_FILE
sed -e "s#@WEB_DIR@#$BASE_DIR/web#g" -e "s#@TEMPLATE_PARTNER_ADMIN_SECRET@#$ADMIN_SECRET#g" -e "s#@ADMIN_CONSOLE_PARTNER_ADMIN_SECRET@#$ADMIN_SECRET#g" -e "s#@MONITORING_PROXY_ADMIN_SECRET@#$PARTNER_MONITORING_PROXY_ADMIN_SECRET#g" -e "s#@MONITORING_PROXY_SECRET@#$PARTNER_MONITORING_PROXY_SECRET#g" -e "s#@KMC_SSO_SERVER_ADMIN_SECRET@#$PARTNER_KMC_SSO_ADMIN_SECRET#g" -e "s#@KMC_SSO_SERVER_SECRET@#$PARTNER_KMC_SSO_SECRET#g" -e "s#@MONITOR_PARTNER_ADMIN_SECRET@#$MONITOR_PARTNER_ADMIN_SECRET#g" -e "s#@SERVICE_URL@#$SERVICE_URL#g" -e "s#@ADMIN_CONSOLE_ADMIN_MAIL@#$ADMIN_CONSOLE_ADMIN_MAIL#g" -e "s#@MONITOR_PARTNER_ADMIN_SECRET@#$MONITOR_PARTNER_ADMIN_SECRET#g" -e "s#@MONITOR_PARTNER_SECRET@#$MONITOR_PARTNER_SECRET#g" -e "s#@PARTNER_ZERO_ADMIN_SECRET@#$PARTNER_ZERO_ADMIN_SECRET#g" -e "s#@BATCH_PARTNER_ADMIN_SECRET@#$BATCH_PARTNER_ADMIN_SECRET#g" -e "s#@MEDIA_PARTNER_ADMIN_SECRET@#$MEDIA_PARTNER_ADMIN_SECRET#g" -e "s#@TEMPLATE_PARTNER_ADMIN_SECRET@#$TEMPLATE_PARTNER_ADMIN_SECRET#g" -e "s#@HOSTED_PAGES_PARTNER_ADMIN_SECRET@#$HOSTED_PAGES_PARTNER_ADMIN_SECRET#g" -e "s#@STORAGE_BASE_DIR@#$BASE_DIR/web#g" -e "s#@DELIVERY_HTTP_BASE_URL@#https://dontknow.com#g" -e "s#@DELIVERY_RTMP_BASE_URL@#rtmp://reallydontknow.com#g" -e "s#@DELIVERY_ISS_BASE_URL@#https://honesttogodihavenoidea.com#g" -e "s/@ADMIN_CONSOLE_PASSWORD@/$ADMIN_CONSOLE_PASSWORD/g" -e "s#@WWW_HOST@#$KALTURA_FULL_VIRTUAL_HOST_NAME#g" -e "s/@PLAY_PARTNER_ADMIN_SECRET@/$PLAY_PARTNER_ADMIN_SECRET/g" -e "s#@TEMPLATE_PARTNER_ADMIN_PASSWORD@#$TEMPLATE_PARTNER_ADMIN_PASSWORD#g" -e "s#@PARTNER_ZERO_SECRET@#$PARTNER_ZERO_SECRET#g" -e "s#@BATCH_PARTNER_SECRET@#$BATCH_PARTNER_SECRET#g" -e "s#@ADMIN_CONSOLE_PARTNER_SECRET@#$ADMIN_CONSOLE_PARTNER_SECRET#g" -e "s#@HOSTED_PAGES_PARTNER_SECRET@#$HOSTED_PAGES_PARTNER_SECRER#g" -e "s#@MEDIA_PARTNER_SECRET@#$MEDIA_PARTNER_SECRET#g" -e "s#@PLAY_PARTNER_SECRET@#$PLAY_PARTNER_SECRET#g" -e "s#@TEMPLATE_PARTNER_SECRET@#$TEMPLATE_PARTNER_SECRET#g" -e "s#@VOD_PACKAGER_HOST@#$VOD_PACKAGER_HOST#g" -e "s#@VOD_PACKAGER_PORT@#$VOD_PACKAGER_PORT#g" -e "s#@LIVE_PACKAGER_HOST@#$VOD_PACKAGER_HOST#g" -e "s#@LIVE_PACKAGER_PORT@#$VOD_PACKAGER_PORT#g" -e "s#@IP_RANGE@#$IP_RANGE#g" -i $DEST_FILE
done
CONFS=`find $BASE_DIR/app/deployment/base/scripts/init_data/ -name "*template*"`
CONFS="$CONFS $BASE_DIR/app/tests/monitoring/config.ini"
for TMPL in $CONFS;do
DEST_FILE=`echo $TMPL | sed 's@\(.*\)\.template\(.*\)@\1\2@'`
if `echo $TMPL|grep -q template`;then
cp $TMPL $DEST_FILE
fi
sed -e "s#@ENVIRONMENT_PROTOCOL@#$PROTOCOL#g" -e "s#@WEB_DIR@#$BASE_DIR/web#g" -e "s#@TEMPLATE_PARTNER_ADMIN_SECRET@#$ADMIN_SECRET#g" -e "s#@ADMIN_CONSOLE_PARTNER_ADMIN_SECRET@#$ADMIN_SECRET#g" -e "s#@MONITOR_PARTNER_ADMIN_SECRET@#$MONITOR_PARTNER_ADMIN_SECRET#g" -e "s#@MONITORING_PROXY_ADMIN_SECRET@#$PARTNER_MONITORING_PROXY_ADMIN_SECRET#g" -e "s#@MONITORING_PROXY_SECRET@#$PARTNER_MONITORING_PROXY_SECRET#g" -e "s#@KMC_SSO_SERVER_ADMIN_SECRET@#$PARTNER_KMC_SSO_ADMIN_SECRET#g" -e "s#@KMC_SSO_SERVER_SECRET@#$PARTNER_KMC_SSO_SECRET#g" -e "s#@SERVICE_URL@#$SERVICE_URL#g" -e "s#@ADMIN_CONSOLE_ADMIN_MAIL@#$ADMIN_CONSOLE_ADMIN_MAIL#g" -e "s#@MONITOR_PARTNER_SECRET@#$MONITOR_PARTNER_SECRET#g" -e "s#@PARTNER_ZERO_ADMIN_SECRET@#$PARTNER_ZERO_ADMIN_SECRET#g" -e "s#@BATCH_PARTNER_ADMIN_SECRET@#$BATCH_PARTNER_ADMIN_SECRET#g" -e "s#@MEDIA_PARTNER_ADMIN_SECRET@#$MEDIA_PARTNER_ADMIN_SECRET#g" -e "s#@TEMPLATE_PARTNER_ADMIN_SECRET@#$TEMPLATE_PARTNER_ADMIN_SECRET#g" -e "s#@KALTURA_VERSION@#$KALTURA_VERSION#g" -e "s#@HOSTED_PAGES_PARTNER_ADMIN_SECRET@#$HOSTED_PAGES_PARTNER_ADMIN_SECRET#g" -e "s#@STORAGE_BASE_DIR@#$BASE_DIR/web#g" -e "s#@DELIVERY_HTTP_BASE_URL@#https://dontknow.com#g" -e "s#@DELIVERY_RTMP_BASE_URL@#rtmp://reallydontknow.com#g" -e "s#@DELIVERY_ISS_BASE_URL@#https://honesttogodihavenoidea.com#g" -e "s/@ADMIN_CONSOLE_PASSWORD@/$ADMIN_CONSOLE_PASSWORD/g" -e "s/@PLAY_PARTNER_ADMIN_SECRET@/$PLAY_PARTNER_ADMIN_SECRET/g" -e "s#@WWW_HOST@#$KALTURA_FULL_VIRTUAL_HOST_NAME#g" -e "s#@TEMPLATE_PARTNER_ADMIN_PASSWORD@#$TEMPLATE_PARTNER_ADMIN_PASSWORD#g" -e "s#@HOSTED_PAGES_PARTNER_SECRET@#$HOSTED_PAGES_PARTNER_SECRET#g" -e "s#@MEDIA_PARTNER_SECRET@#$MEDIA_PARTNER_SECRET#g" -e "s#@PLAY_PARTNER_SECRET@#$PLAY_PARTNER_SECRET#g" -e "s#@TEMPLATE_PARTNER_SECRET@#$TEMPLATE_PARTNER_SECRET#g" -e "s#@PARTNER_ZERO_SECRET@#$PARTNER_ZERO_SECRET#g" -e "s#@BATCH_PARTNER_SECRET@#$BATCH_PARTNER_SECRET#g" -e "s#@ADMIN_CONSOLE_PARTNER_SECRET@#$ADMIN_CONSOLE_PARTNER_SECRET#g" -e "s#@VOD_PACKAGER_HOST@#$VOD_PACKAGER_HOST#g" -e "s#@VOD_PACKAGER_PORT@#$VOD_PACKAGER_PORT#g" -e "s#@LIVE_PACKAGER_HOST@#$VOD_PACKAGER_HOST#g" -e "s#@LIVE_PACKAGER_PORT@#$VOD_PACKAGER_PORT#g" -e "s#@IP_RANGE@#$IP_RANGE#g" -i $DEST_FILE
done
if [ -f "$KALTURA_PREFIX/app/configurations/system.ini" ];then
mkdir -p /etc/kaltura.d
ln -sf $KALTURA_PREFIX/app/configurations/system.ini /etc/kaltura.d/system.ini
fi
#db_input critical 'kaltura-base/generating_client_libs' || true
# stupidly and only for apache2, service apache2 status outputs to PAGER, thus no good for auto upgrades
if /etc/init.d/apache2 status ;then
invoke-rc.d apache2 stop
RESTART_APACHE=true
invoke-rc.d monit stop
fi
rm -rf $KALTURA_PREFIX/app/cache/*
php $BASE_DIR/app/generator/generate.php >> $BASE_DIR/log/generate.php.log 2>&1
if [ -n "$RESTART_APACHE" ];then
invoke-rc.d apache2 start
fi
set +e
ln -sf $BASE_DIR/app/configurations/logrotate/kaltura_base /etc/logrotate.d/
ln -sf $BASE_DIR/app/configurations/logrotate/kaltura_api /etc/logrotate.d/
for MOD_DIR in /etc/php5/mods-available /etc/php/7.0/mods-available /opt/kaltura/app/configurations/php/mods-available;do
if [ -d "$MOD_DIR" ];then
ln -sf $APP_DIR/configurations/php/kaltura.ini $MOD_DIR/zz-kaltura.ini
fi
done
touch "$BASE_DIR/app/base-config.lock"
find $BASE_DIR/app/cache/ $BASE_DIR/log -type d -exec chmod 775 {} \;
find $BASE_DIR/app/cache/ $BASE_DIR/log -type f -exec chmod 664 {} \;
chown -R $KALTURA_USER.$APACHE_USER $BASE_DIR/app/cache/ $BASE_DIR/log
chmod 775 $BASE_DIR/web/content
if [ -d /usr/lib/red5/webapps/oflaDemo ];then
ln -sf $BASE_DIR/web/content/webcam /usr/lib/red5/webapps/oflaDemo/streams
fi
KMC_PATH=`ls -ld $BASE_DIR/web/flash/kmc/v* 2>/dev/null|awk -F " " '{print $NF}' |tail -1`
KMC_LOGIN_PATH=`ls -ld $BASE_DIR/web/flash/kmc/login/v* 2>/dev/null|awk -F " " '{print $NF}' |tail -1`
if [ -d "$KMC_PATH" -a -d "$KMC_LOGIN_PATH" ];then
KMC_VERSION=`basename $KMC_PATH`
KMC_LOGIN_VERSION=`basename $KMC_LOGIN_PATH`
sed -i "s#\(@KMC_VERSION@\)#$KMC_VERSION#g" $BASE_DIR/bin/sanity_config.ini
sed -i "s#\(@KMC_LOGIN_VERSION@\)#$KMC_LOGIN_VERSION#g" $BASE_DIR/bin/sanity_config.ini
fi
#echo -e "${BRIGHT_BLUE}Configuration of $KALTURA_VERSION finished successfully!${NORMAL}"
send_install_becon "`basename $0`" "install_success" 0
echo "
SERVICE_URL=$SERVICE_URL
SPHINX_HOST=$SPHINX_SERVER1
DB1_PORT=$DB1_PORT
SUPER_USER=$SUPER_USER
SUPER_USER_PASSWD=\"$SUPER_USER_PASSWD\"
KALTURA_VIRTUAL_HOST_NAME=$KALTURA_FULL_VIRTUAL_HOST_NAME
RED5_HOST=$RED5_HOST
">> $BASE_DIR/app/configurations/system.ini
fi