forked from RestyaPlatform/board
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestyaboard.sh
570 lines (512 loc) · 19.6 KB
/
restyaboard.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
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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
#/bin/sh
#
# Install script for Restyaboard
#
# Usage: ./restyaboard.sh
#
# Copyright (c) 2014-2015 Restya.
# Dual License (OSL 3.0 & Commercial License)
{
if [[ $EUID -ne 0 ]];
then
echo "This script must be run as root"
exit 1
fi
set -x
whoami
echo $(cat /etc/issue)
OS_REQUIREMENT=$(cat /etc/issue | awk '{print $1}' | sed 's/Kernel//g')
if ([ "$OS_REQUIREMENT" = "Ubuntu" ] || [ "$OS_REQUIREMENT" = "Debian" ])
then
apt-get install -y curl
else
yum install -y curl
fi
RESTYABOARD_VERSION=$(curl --silent https://api.github.com/repos/RestyaPlatform/board/releases | grep tag_name -m 1 | awk '{print $2}' | sed -e 's/[^v0-9.]//g')
POSTGRES_DBHOST=localhost
POSTGRES_DBNAME=restyaboard
POSTGRES_DBUSER=restya
POSTGRES_DBPASS=hjVl2!rGd
POSTGRES_DBPORT=5432
DOWNLOAD_DIR=/opt/restyaboard
update_version()
{
set +x
echo "A newer version ${RESTYABOARD_VERSION} of Restyaboard is available. Do you want to get it now y/n?"
read -r answer
set -x
case "${answer}" in
[Yy])
set +x
echo "To copy downloaded script, enter your document root path (e.g., /usr/share/nginx/html):"
read -r dir
while [[ -z "$dir" ]]
do
read -r -p "To copy downloaded script, enter your document root path (e.g., /usr/share/nginx/html):" dir
done
set -x
echo "Downloading files..."
curl -v -L -G -d "app=board&ver=${RESTYABOARD_VERSION}" -o /tmp/restyaboard.zip http://restya.com/download.php
unzip /tmp/restyaboard.zip -d ${DOWNLOAD_DIR}
echo "Updating files..."
cp -r ${DOWNLOAD_DIR} "$dir"
echo "Connecting database to run SQL changes..."
psql -U postgres -c "\q"
sleep 1
echo "Setting up cron for every 5 minutes to send email notification to user, if the user chosen notification type as instant..."
if ([ "$OS_REQUIREMENT" = "Ubuntu" ] || [ "$OS_REQUIREMENT" = "Debian" ])
then
echo "*/5 * * * * $dir/server/php/R/shell/instant_email_notification.sh" >> /var/spool/cron/crontabs/root
else
echo "*/5 * * * * $dir/server/php/R/shell/instant_email_notification.sh" >> /var/spool/cron/root
fi
echo "Setting up cron for every 1 hour to send email notification to user, if the user chosen notification type as periodic..."
if ([ "$OS_REQUIREMENT" = "Ubuntu" ] || [ "$OS_REQUIREMENT" = "Debian" ])
then
echo "0 * * * * $dir/server/php/R/shell/periodic_email_notification.sh" >> /var/spool/cron/crontabs/root
else
echo "0 * * * * $dir/server/php/R/shell/periodic_email_notification.sh" >> /var/spool/cron/root
fi
echo "Updating SQL..."
psql -d ${POSTGRES_DBNAME} -f "$dir/sql/${RESTYABOARD_VERSION}.sql" -U ${POSTGRES_DBUSER}
/bin/echo "$RESTYABOARD_VERSION" > /opt/restyaboard/release
esac
}
if [ -d "$DOWNLOAD_DIR" ];
then
version=$(cat /opt/restyaboard/release)
if [[ $version < $RESTYABOARD_VERSION ]];
then
update_version
exit
else
echo "No new version available"
exit;
fi
else
set +x
echo "Already installed Restyaboard y/n?"
read -r answer
set -x
case "${answer}" in
[Yy])
update_version
exit
esac
fi
if ([ "$OS_REQUIREMENT" = "Ubuntu" ] || [ "$OS_REQUIREMENT" = "Debian" ])
then
set +x
echo "Setup script will install version ${RESTYABOARD_VERSION} and create database ${POSTGRES_DBNAME} with user ${POSTGRES_DBUSER} and password ${POSTGRES_DBPASS}. To continue enter \"y\" or to quit the process and edit the version and database details enter \"n\" (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "deb http://mirrors.linode.com/debian/ wheezy main contrib non-free" >> /etc/apt/sources.list
echo "deb-src http://mirrors.linode.com/debian/ wheezy main contrib non-free" >> /etc/apt/sources.list
echo "deb http://mirrors.linode.com/debian-security/ wheezy/updates main contrib non-free" >> /etc/apt/sources.list
echo "deb-src http://mirrors.linode.com/debian-security/ wheezy/updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://mirrors.linode.com/debian/ wheezy-updates main" >> /etc/apt/sources.list
echo "deb-src http://mirrors.linode.com/debian/ wheezy-updates main" >> /etc/apt/sources.list
sed -i -e 's/deb cdrom/#deb cdrom/g' /etc/apt/sources.list
apt-get install debian-keyring debian-archive-keyring
apt-get update -y
apt-get upgrade -y
echo "Checking nginx..."
if ! which nginx > /dev/null 2>&1; then
echo "nginx not installed!"
set +x
echo "Do you want to install nginx (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing nginx..."
apt-get install -y cron nginx
service nginx start
esac
fi
echo "Checking PHP..."
if ! hash php 2>&-; then
echo "PHP is not installed!"
set +x
echo "Do you want to install PHP (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing PHP..."
apt-get install -y php5 php5-fpm php5-common
service php5-fpm start
esac
fi
echo "Checking PHP curl extension..."
php -m | grep curl
if [ "$?" -gt 0 ]; then
echo "Installing php5-curl..."
apt-get install -y php5-curl
fi
echo "Checking PHP pgsql extension..."
php -m | grep pgsql
if [ "$?" -gt 0 ]; then
echo "Installing php5-pgsql..."
apt-get install -y php5-pgsql
fi
echo "Checking PHP mbstring extension..."
php -m | grep mbstring
if [ "$?" -gt 0 ]; then
echo "Installing php5-mbstring..."
apt-get install -y php5-mbstring
fi
echo "Checking PHP ldap extension..."
php -m | grep ldap
if [ "$?" -gt 0 ]; then
echo "Installing php5-ldap..."
apt-get install -y php5-ldap
fi
echo "Checking PHP imagick extension..."
php -m | grep imagick
if [ "$?" -gt 0 ]; then
echo "Installing php5-imagick..."
apt-get install -y php5-imagick
fi
echo "Setting up timezone..."
timezone=$(cat /etc/timezone)
sed -i -e 's/date.timezone/;date.timezone/g' /etc/php5/fpm/php.ini
echo "date.timezone = $timezone" >> /etc/php5/fpm/php.ini
echo "Checking PostgreSQL..."
id -a postgres
if [ $? != 0 ]; then
echo "PostgreSQL not installed!"
set +x
echo "Do you want to install PostgreSQL (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing PostgreSQL..."
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc
apt-key add ACCC4CF8.asc
apt-get update
apt-get install postgresql-9.4
sed -e 's/peer/trust/g' -e 's/ident/trust/g' < /etc/postgresql/9.4/main/pg_hba.conf > /etc/postgresql/9.4/main/pg_hba.conf.1
cd /etc/postgresql/9.4/main || exit
mv pg_hba.conf pg_hba.conf_old
mv pg_hba.conf.1 pg_hba.conf
service postgresql restart
esac
fi
echo "Checking ElasticSearch..."
if ! curl http://localhost:9200 > /dev/null 2>&1; then
echo "ElasticSearch not installed!"
set +x
echo "Do you want to install ElasticSearch (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing ElasticSearch..."
apt-get install openjdk-6-jre
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.deb
dpkg -i elasticsearch-0.90.7.deb
service elasticsearch restart
esac
fi
echo "Downloading Restyaboard script..."
mkdir /opt/restyaboard
curl -v -L -G -d "app=board&ver=${RESTYABOARD_VERSION}" -o /tmp/restyaboard.zip http://restya.com/download.php
unzip /tmp/restyaboard.zip -d /opt/restyaboard
cp /opt/restyaboard/restyaboard.conf /etc/nginx/conf.d
rm /tmp/restyaboard.zip
set +x
echo "To configure nginx, enter your domain name (e.g., www.example.com, 192.xxx.xxx.xxx, etc.,):"
read -r webdir
while [[ -z "$webdir" ]]
do
read -r -p "To configure nginx, enter your domain name (e.g., www.example.com, 192.xxx.xxx.xxx, etc.,):" webdir
done
set -x
echo "$webdir"
echo "Changing server_name in nginx configuration..."
sed -i "s/server_name.*$/server_name $webdir;/" /etc/nginx/conf.d/restyaboard.conf
sed -i "s|listen 80.*$|listen 80;|" /etc/nginx/conf.d/restyaboard.conf
set +x
echo "To copy downloaded script, enter your document root path (e.g., /usr/share/nginx/html):"
read -r dir
while [[ -z "$dir" ]]
do
read -r -p "To copy downloaded script, enter your document root path (e.g., /usr/share/nginx/html):" dir
done
set -x
echo "$dir"
mkdir -p "$dir"
echo "Changing root directory in nginx configuration..."
sed -i "s|root.*html|root $dir|" /etc/nginx/conf.d/restyaboard.conf
echo "Copying Restyaboard script to root directory..."
cp -r /opt/restyaboard/* "$dir"
echo "Installing postfix..."
echo "postfix postfix/mailname string $webdir"\
| debconf-set-selections &&\
echo "postfix postfix/main_mailer_type string 'Internet Site'"\
| debconf-set-selections &&\
apt-get install -y postfix
echo "Changing permission..."
chmod -R go+w "$dir/media"
chmod -R go+w "$dir/client/img"
chmod -R go+w "$dir/tmp/cache"
chmod -R 0755 $dir/server/php/R/shell/*.sh
psql -U postgres -c "\q"
sleep 1
echo "Creating PostgreSQL user and database..."
psql -U postgres -c "CREATE USER ${POSTGRES_DBUSER} WITH ENCRYPTED PASSWORD '${POSTGRES_DBPASS}'"
psql -U postgres -c "CREATE DATABASE ${POSTGRES_DBNAME} OWNER ${POSTGRES_DBUSER} ENCODING 'UTF8' TEMPLATE template0"
if [ "$?" = 0 ];
then
echo "Importing empty SQL..."
psql -d ${POSTGRES_DBNAME} -f "$dir/sql/restyaboard_with_empty_data.sql" -U ${POSTGRES_DBUSER}
fi
echo "Changing PostgreSQL database name, user and password..."
sed -i "s/^.*'R_DB_NAME'.*$/define('R_DB_NAME', '${POSTGRES_DBNAME}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_USER'.*$/define('R_DB_USER', '${POSTGRES_DBUSER}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_PASSWORD'.*$/define('R_DB_PASSWORD', '${POSTGRES_DBPASS}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_HOST'.*$/define('R_DB_HOST', '${POSTGRES_DBHOST}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_PORT'.*$/define('R_DB_PORT', '${POSTGRES_DBPORT}');/g" "$dir/server/php/R/config.inc.php"
echo "Setting up cron for every 5 minutes to update ElasticSearch indexing..."
echo "*/5 * * * * $dir/server/php/R/shell/cron.sh" >> /var/spool/cron/crontabs/root
echo "Setting up cron for every 5 minutes to send email notification to user, if the user chosen notification type as instant..."
echo "*/5 * * * * $dir/server/php/R/shell/instant_email_notification.sh" >> /var/spool/cron/crontabs/root
echo "Setting up cron for every 1 hour to send email notification to user, if the user chosen notification type as periodic..."
echo "0 * * * * $dir/server/php/R/shell/periodic_email_notification.sh" >> /var/spool/cron/crontabs/root
echo "Starting services..."
service cron restart
service php5-fpm restart
service nginx restart
service postfix restart
service elasticsearch restart
esac
else
set +x
echo "Setup script will install version ${RESTYABOARD_VERSION} and create database ${POSTGRES_DBNAME} with user ${POSTGRES_DBUSER} and password ${POSTGRES_DBPASS}. To continue enter \"y\" or to quit the process and edit the version and database details enter \"n\" (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Checking nginx..."
if ! which nginx > /dev/null 2>&1;
then
echo "nginx not installed!"
set +x
echo "Do you want to install nginx (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing nginx..."
yum install -y epel-release
yum install -y zip cron nginx
service nginx start
chkconfig --levels 35 nginx on
esac
fi
echo "Checking PHP..."
if ! hash php 2>&-;
then
echo "PHP is not installed!"
set +x
echo "Do you want to install PHP (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing PHP..."
yum install -y epel-release
yum install -y php-fpm php-cli
service php-fpm start
chkconfig --levels 35 php-fpm on
esac
fi
echo "Checking PHP curl extension..."
php -m | grep curl
if [ "$?" -gt 0 ];
then
echo "Installing php-curl..."
yum install -y php-curl
fi
echo "Checking PHP pgsql extension..."
php -m | grep pgsql
if [ "$?" -gt 0 ];
then
echo "Installing php-pgsql..."
yum install -y php-pgsql
fi
echo "Checking PHP mbstring extension..."
php -m | grep mbstring
if [ "$?" -gt 0 ];
then
echo "Installing php-mbstring..."
yum install -y php-mbstring
fi
echo "Checking PHP ldap extension..."
php -m | grep ldap
if [ "$?" -gt 0 ];
then
echo "Installing php-ldap..."
yum install -y php-ldap
fi
echo "Checking PHP imagick extension..."
php -m | grep imagick
if [ "$?" -gt 0 ];
then
echo "Installing php-imagick..."
yum install -y php-imagick
fi
echo "Setting up timezone..."
timezone=$(cat /etc/sysconfig/clock | grep ZONE | cut -d"\"" -f2)
sed -i -e 's/date.timezone/;date.timezone/g' /etc/php.ini
echo "date.timezone = $timezone" >> /etc/php.ini
PHP_VERSION=$(php -v | grep "PHP 5" | sed 's/.*PHP \([^-]*\).*/\1/' | cut -c 1-3)
echo "Installed PHP version: '$PHP_VERSION'"
echo "Checking PostgreSQL..."
id -a postgres
if [ $? != 0 ];
then
echo "PostgreSQL not installed!"
set +x
echo "Do you want to install PostgreSQL (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing PostgreSQL..."
if [ $(getconf LONG_BIT) = "32" ]; then
yum install -y http://yum.postgresql.org/9.4/redhat/rhel-6.6-i386/pgdg-centos94-9.4-1.noarch.rpm
fi
if [ $(getconf LONG_BIT) = "64" ]; then
yum install -y http://yum.postgresql.org/9.4/redhat/rhel-6.6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
fi
yum install -y postgresql94-server postgresql04-contrib
ps -q 1 | grep -q -c "systemd"
if [ "$?" -eq 0 ]; then
if [ -f /usr/pgsql-9.4/bin/postgresql94-setup ]; then
/usr/pgsql-9.4/bin/postgresql94-setup initdb
fi
systemctl start postgresql-9.4.service
systemctl enable postgresql-9.4.service
else
service postgresql-9.4 initdb
/etc/init.d/postgresql-9.4 start
chkconfig --levels 35 postgresql-9.4 on
fi
sed -e 's/peer/trust/g' -e 's/ident/trust/g' < /var/lib/pgsql/9.4/data/pg_hba.conf > /var/lib/pgsql/9.4/data/pg_hba.conf.1
cd /var/lib/pgsql/9.4/data || exit
mv pg_hba.conf pg_hba.conf_old
mv pg_hba.conf.1 pg_hba.conf
ps -q 1 | grep -q -c "systemd"
if [ "$?" -eq 0 ]; then
systemctl restart postgresql-9.4.service
else
/etc/init.d/postgresql-9.4 restart
fi
esac
fi
echo "Checking ElasticSearch..."
if ! curl http://localhost:9200 > /dev/null 2>&1;
then
echo "ElasticSearch not installed!"
set +x
echo "Do you want to install ElasticSearch (y/n)?"
read -r answer
set -x
case "${answer}" in
[Yy])
echo "Installing ElasticSearch..."
sudo yum install java-1.7.0-openjdk -y
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.10.noarch.rpm
nohup rpm -Uvh elasticsearch-0.90.10.noarch.rpm &
chkconfig elasticsearch on
esac
fi
echo "Downloading Restyaboard script..."
mkdir ${DOWNLOAD_DIR}
curl -v -L -G -d "app=board&ver=${RESTYABOARD_VERSION}" -o /tmp/restyaboard.zip http://restya.com/download.php
if [ ! -f /usr/bin/unzip ];
then
yum install -y unzip
fi
unzip /tmp/restyaboard.zip -d ${DOWNLOAD_DIR}
cp ${DOWNLOAD_DIR}/restyaboard.conf /etc/nginx/conf.d
rm /tmp/restyaboard.zip
set +x
echo "To configure nginx, enter your domain name (e.g., www.example.com, 192.xxx.xxx.xxx, etc.,):"
read -r webdir
while [[ -z "$webdir" ]]
do
read -r -p "To configure nginx, enter your domain name (e.g., www.example.com, 192.xxx.xxx.xxx, etc.,):" webdir
done
set -x
echo "$webdir"
echo "Changing server_name in nginx configuration..."
sed -i "s/server_name.*$/server_name \"$webdir\";/" /etc/nginx/conf.d/restyaboard.conf
sed -i "s|listen 80.*$|listen 80;|" /etc/nginx/conf.d/restyaboard.conf
set +x
echo "To copy downloaded script, enter your document root path (e.g., /usr/share/nginx/html):"
read -r dir
while [[ -z "$dir" ]]
do
read -r -p "To copy downloaded script, enter your document root path (e.g., /usr/share/nginx/html):" dir
done
set -x
echo "$dir"
mkdir -p "$dir"
echo "Changing root directory in nginx configuration..."
sed -i "s|root.*html|root $dir|" /etc/nginx/conf.d/restyaboard.conf
echo "Copying Restyaboard script to root directory..."
cp -r "$DOWNLOAD_DIR"/* "$dir"
echo "Changing permission..."
chmod -R go+w "$dir/media"
chmod -R go+w "$dir/client/img"
chmod -R go+w "$dir/tmp/cache"
chmod -R 0755 $dir/server/php/R/shell/*.sh
psql -U postgres -c "\q"
sleep 1
echo "Creating PostgreSQL user and database..."
psql -U postgres -c "CREATE USER ${POSTGRES_DBUSER} WITH ENCRYPTED PASSWORD '${POSTGRES_DBPASS}'"
psql -U postgres -c "CREATE DATABASE ${POSTGRES_DBNAME} OWNER ${POSTGRES_DBUSER} ENCODING 'UTF8' TEMPLATE template0"
if [ "$?" = 0 ];
then
echo "Importing empty SQL..."
psql -d ${POSTGRES_DBNAME} -f "$dir/sql/restyaboard_with_empty_data.sql" -U ${POSTGRES_DBUSER}
fi
echo "Changing PostgreSQL database name, user and password..."
sed -i "s/^.*'R_DB_NAME'.*$/define('R_DB_NAME', '${POSTGRES_DBNAME}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_USER'.*$/define('R_DB_USER', '${POSTGRES_DBUSER}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_PASSWORD'.*$/define('R_DB_PASSWORD', '${POSTGRES_DBPASS}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_HOST'.*$/define('R_DB_HOST', '${POSTGRES_DBHOST}');/g" "$dir/server/php/R/config.inc.php"
sed -i "s/^.*'R_DB_PORT'.*$/define('R_DB_PORT', '${POSTGRES_DBPORT}');/g" "$dir/server/php/R/config.inc.php"
echo "Setting up cron for every 5 minutes to update ElasticSearch indexing..."
echo "*/5 * * * * $dir/server/php/R/shell/cron.sh" >> /var/spool/cron/root
echo "Setting up cron for every 5 minutes to send email notification to user, if the user chosen notification type as instant..."
echo "*/5 * * * * $dir/server/php/R/shell/instant_email_notification.sh" >> /var/spool/cron/root
echo "Setting up cron for every 1 hour to send email notification to user, if the user chosen notification type as periodic..."
echo "0 * * * * $dir/server/php/R/shell/periodic_email_notification.sh" >> /var/spool/cron/root
echo "Reset php-fpm (use unix socket mode)..."
sed -i "/listen = 127.0.0.1:9000/a listen = /var/run/php5-fpm.sock" /etc/php-fpm.d/www.conf
# Start services
ps -q 1 | grep -q -c "systemd"
if [ "$?" -eq 0 ];
then
echo "Starting services with systemd..."
systemctl start nginx
systemctl start php-fpm
else
echo "Starting services..."
/etc/init.d/php-fpm restart
/etc/init.d/nginx restart
fi
/bin/echo "$RESTYABOARD_VERSION" > /opt/restyaboard/release
esac
fi
set +x
} 2>&1 | tee -a restyaboard_install.log