sharex-php-uploader/docker/start.sh
Lee f83830443b
All checks were successful
/ docker (push) Successful in 2m7s
revert d89ed9e17df3b995c9c4ed185afb0a1a7c2a6d12
revert alpine tests
2023-07-07 23:04:51 +00:00

40 lines
1.3 KiB
Bash

if [[ -z "${MAX_UPLOAD_SIZE}" ]]; then
MAX_UPLOAD_SIZE="8M" # Default fallback value
fi
echo "Checking if upload script exists in /var/www/html"
if [ -f "/var/www/html/upload.php" ]; then
echo "Upload script was found, ignoring copy."
else
cp /tmp/upload.php /var/www/html
echo "Upload script was not found, copying it."
fi
# Letting php know that we are running in docker
echo "env[DOCKER] = true" >> /etc/php/8.1/fpm/pool.d/www.conf
echo "clear_env = no" >> /etc/php/8.1/fpm/pool.d/www.conf
echo "Setting permissions for upload script"
chmod 777 /var/www/html/upload.php
echo "Setting max upload size to ${MAX_UPLOAD_SIZE}"
# Set max upload size for php
sed -i "s/^upload_max_filesize = .*/upload_max_filesize = ${MAX_UPLOAD_SIZE}/" /etc/php/8.1/fpm/php.ini
sed -i "s/^post_max_size = .*/post_max_size = ${MAX_UPLOAD_SIZE}/" /etc/php/8.1/fpm/php.ini
# Set max upload size for nginx
sed -i "s/client_max_body_size 500M;/client_max_body_size ${MAX_UPLOAD_SIZE};/" /etc/nginx/nginx.conf
function start() {
echo "Starting PHP & Nginx"
/etc/init.d/php8.1-fpm start &&
chmod 777 /run/php/php8.1-fpm.sock &&
nginx -g 'daemon off;'
}
# Start Nginx and retry if it fails
until start; do
echo "Nginx failed to start, retrying in 5 seconds..."
sleep 5
done