403Webshell
Server IP : 104.129.129.72  /  Your IP : 216.73.216.229
Web Server : LiteSpeed
System : Linux 123answers 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
User : answe8064 ( 1002)
PHP Version : 8.2.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/installer/apps/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/installer/apps/moodle-3.6-offisrc-nginx-mysqlserver
#!/bin/bash

# Add this at the begining of all scripts.
if [ -f "include/startup.sh" ]; then
    . include/startup.sh
elif [ -f "../include/startup.sh" ]; then
    . ../include/startup.sh
fi

checkTagExist nginx.success
checkTagExist php.success
checkTagExist mysqld.success
checkTagExist nginx-enable-php-ssl.success

appPath=/var/www/html
appVersion=3.6.8
appBranch=stable36
rootDir=$(rootDir)

echo "Downloading and extracting application" | log
cd $rootDir/temp
curlDownload https://download.moodle.org/$appBranch/moodle-$appVersion.tgz
waitOrStop 0 "File not downloaded from official source"
tar -xzvf moodle-$appVersion.tgz
waitOrStop 0 "Failed to extract application archive"
mkdir -p $appPath
mv moodle $appPath
rm -f moodle-$appVersion.tgz
chown -R www-data:www-data $appPath/moodle/
chmod -R 755 $appPath/moodle/

echo "Setting database and db user " | log
mysql --defaults-file=/root/.my.cnf -h localhost <<EOF
CREATE DATABASE moodle;
CREATE USER 'moodleuser'@'localhost' IDENTIFIED BY '${ADMINPASSWORD}';
GRANT ALL ON moodle.* TO 'moodleuser'@'localhost' IDENTIFIED BY '${ADMINPASSWORD}' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF

echo "Tweaking PHP settings" | log
ini=$(find /etc -type f -name "php.ini" | grep fpm)
sed -i '/file_uploads/s/Off/On/g' $ini
sed -i '/allow_url_fopen/s/Off/On/g' $ini
sed -i '/max_execution_time/s/[0-9]\+/360/g' $ini
sed -i '/cgi.fix_pathinfo/s/^;//g' $ini
sed -i '/cgi.fix_pathinfo/s/[0-9]\+/0/g' $ini
# sed -i '/date.timezone/s/^;//g' $ini
# sed -i '/date.timezone/s/_OLD_/_NEW_/g' $ini

echo "Move phpmyadmin into app if available" | log
if [ -f "$rootDir/temp/phpmyadmin.success" ]; then
    mv $appPath/phpmyadmin $appPath/moodle
fi

echo "Creating nginx configurations" | log
cp -f $rootDir/tweaks/extras/moodle-nginx/moodle.conf /etc/nginx/sites-available/
ln -s /etc/nginx/sites-available/moodle.conf /etc/nginx/sites-enabled/
unlink /etc/nginx/sites-enabled/default
unlink /etc/nginx/sites-enabled/default-ssl
systemctl restart nginx.service
waitOrStop 0 "Restart nginx service failed"

echo "Adding descriptions" | log

descriptionAppend "Moodle web UI: https://${CWM_DISPLAYED_ADDRESS}"
descriptionAppend "Moodle admin user: admin"
descriptionAppend "Moodle admin password: ${ADMINPASSWORD}"
descriptionAppend " "
descriptionAppend "Moodle db user: moodleuser"
descriptionAppend "Moodle db password: ${ADMINPASSWORD}"
descriptionAppend "(On initial setup, enter db user and password in the matching fields. Other fields should remain as is.)"
descriptionAppend " "

tagScript success
exit 0

Youez - 2016 - github.com/yon3zu
LinuXploit