-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_database
executable file
·24 lines (17 loc) · 982 Bytes
/
install_database
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
source config
if ! [[ $(whereis perl) == *perl* ]]; then
echo "Perl is not install."
exit
fi
DBNAME=$(grep 'dbname =' ${LOCAL_MOODLE_PATH}/config.php | perl -pe "s/.*= '(.+)'.*/\$1/;")
DBUSER=$(grep -E 'dbuser\s+=' ${LOCAL_MOODLE_PATH}/config.php | perl -pe "s/.*=\s+'(.+)'.*/\$1/;")
docker exec -i -t postgres /usr/local/bin/dropdb --if-exists -U ${DBUSER} ${DBNAME}
docker exec -i -t postgres /usr/local/bin/createdb -U ${DBUSER} ${DBNAME}
echo Installing: $DBNAME
docker exec -i -t phpfpm php admin/cli/install_database.php --agree-license --fullname=${DBNAME} --shortname=${DBNAME} --adminpass=admin
docker exec -i -t phpfpm php admin/tool/generator/cli/maketestcourse.php --shortname=S --fullname=S --size=S
if [[ ! -z "$MOODLE_EMAIL" ]]; then
echo "MOODLE_EMAIL environment variable is set to: $MOODLE_EMAIL"
docker exec -i -t postgres psql -U postgres -d $DBNAME -c "UPDATE mdl_user SET email = '$MOODLE_EMAIL' WHERE id = 2" > /dev/null
fi