This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
foreground.sh
58 lines (48 loc) · 1.54 KB
/
foreground.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
#!/bin/bash
# COLORS
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
magenta=`tput setaf 5`
reset=`tput sgr0`
echo "placeholder" > /var/moodledata/placeholder
chown -R www-data:www-data /var/moodledata
chmod 777 /var/moodledata
read pid cmd state ppid pgrp session tty_nr tpgid rest < /proc/self/stat
trap "kill -TERM -$pgrp; exit" EXIT TERM KILL SIGKILL SIGTERM SIGQUIT
#start up cron
/usr/sbin/cron
# Install Moodle from CLI saves some time.
if [ ! -f "/opt/moodle_installed" ]; then
echo -e "${green}Start install moodle v34.2 ${reset}"
echo $DB_ENV_MYSQL_DATABASE
sleep 15
commands="--chmod=2777 \
--dataroot=/var/moodledata \
--lang=en \
--wwwroot=$MOODLE_URL \
--dbhost=$DB_PORT_3306_TCP_ADDR \
--dbtype=mysqli \
--dbname=$DB_ENV_MYSQL_DATABASE \
--dbuser=$DB_ENV_MYSQL_USER \
--dbpass=$MYSQL_ROOT_PASSWORD \
--adminemail=$MOODLE_EMAIL \
--fullname=$SITE_FULLNAME \
--shortname=$SITE_FULLNAME \
--agree-license \
--adminuser=$MOODLE_EMAIL \
--adminpass=$MOODLE_PASSWORD \
--non-interactive"
echo $commands
php /var/www/html/admin/cli/install.php ${commands}
chown www-data:www-data /var/www/html/config.php
# Installed.
echo "true" > /opt/moodle_installed
else
echo -e "${red}Already Installed${reset}"
fi
echo -e "${green}Login: $MOODLE_EMAIL ${reset}"
echo -e "${green}Password: $MOODLE_PASSWORD ${reset}"
source /etc/apache2/envvars
tail -F /var/log/apache2/* &
exec apache2 -D FOREGROUND