Skip to content

Commit 166d6b1

Browse files
committed
2022-01-20 AC: Adds the Moodle installation script.
1 parent c9e81a0 commit 166d6b1

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

scripts/moodle_LfPHP_setup.sh.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
if [[ ! -d /srv/tempo ]]; then
3+
mkdir /srv/tempo
4+
fi
5+
cd /srv/tempo
6+
sed --follow-symlinks -i 's/mysqli.default_socket =/mysqli.default_socket = \/run\/mysqld\/mysqld.sock/' /etc/php.ini
7+
#cat >>/etc/php.ini << EOF
8+
#[OpCache]
9+
#zend_extension = $( php -i | grep extensions | awk '{print $3}' )/opcache.so
10+
#EOF
11+
sed --follow-symlinks -i 's/memory_limit = 128M/memory_limit = 512M/' /etc/php.ini
12+
sed --follow-symlinks -i 's/max_execution_time = 30/max_execution_time = 600/' /etc/php.ini
13+
sed --follow-symlinks -i 's/max_input_time = 60/max_input_time = 600/' /etc/php.ini
14+
if [[ -z "$1" ]]; then
15+
#echo -e "\n"
16+
#read -r -p "Which version of Moodle do you wish to install?" lms
17+
#lms="${lms//./}"
18+
lms="310"
19+
else
20+
#lms=$1
21+
lms="310"
22+
fi
23+
sleep 10
24+
/etc/init.d/mysql restart
25+
sleep 10
26+
mysql -uroot -e "CREATE DATABASE moodle;"
27+
mysql -uroot -e "CREATE USER 'lmsuser'@'localhost' IDENTIFIED BY 'testpass';"
28+
mysql -uroot -e "GRANT ALL PRIVILEGES ON moodle.* TO 'lmsuser'@'localhost';"
29+
mysql -uroot -e "FLUSH PRIVILEGES;"
30+
mv /srv/www /srv/www.OLD
31+
wget -O moodle.tgz https://download.moodle.org/stable310/moodle-latest-"$lms".tgz
32+
tar -xvf moodle.tgz
33+
rm moodle.tgz
34+
chown -R root:apache moodle
35+
chmod -R 755 moodle
36+
mkdir moodledata
37+
chmod -R 0777 moodledata
38+
cd ..
39+
ln -s tempo/moodle www
40+
echo -e "\n\n\n"
41+
echo -e "Running the installer... Please use the following database credentials :\n"
42+
echo -e "SERVER : localhost\n"
43+
echo -e "DATABASE : moodle\n"
44+
echo -e "USER : lmsuser\n"
45+
echo -e "PASSWORD : testpass\n"
46+
chown apache tempo/moodle
47+
cd tempo/moodle/admin/cli
48+
sed -i 's/apache:x:25:25:Apache Server:\/srv\/www:\/bin\/false/apache:x:25:25:Apache Server:\/srv\/www:\/bin\/bash/' /etc/passwd
49+
su apache -c "/usr/bin/php install.php"
50+
sed -i 's/apache:x:25:25:Apache Server:\/srv\/www:\/bin\/bash/apache:x:25:25:Apache Server:\/srv\/www:\/bin\/false/' /etc/passwd
51+
/etc/init.d/php-fpm restart
52+
chown root:apache /srv/www
53+
chown root:apache /srv/tempo
54+
/etc/init.d/httpd restart

0 commit comments

Comments
 (0)