Update start.sh

Improved coloring and using if else for php and tmp files cleaning
This commit is contained in:
finnie2006 authored and GitHub committed 2024-12-28 20:35:54 +01:00
1 parent 34115e88da
commit aed2f66bce
1 file changed
+43 -5
+43 -5
View File
@@ -1,9 +1,47 @@
#!/bin/ash
rm -rf /home/container/tmp/*
echo "⟳ Starting PHP-FPM..."
/usr/sbin/php-fpm8 --fpm-config /home/container/php-fpm/php-fpm.conf --daemonize
# Colors for output
GREEN="\033[0;32m"
YELLOW="\033[1;33m"
RED="\033[0;31m"
RESET="\033[0m"
echo "⟳ Starting Nginx..."
echo "✓ Successfully started"
# Function to print messages with colors
log_success() {
echo -e "${GREEN}[SUCCESS] $1${RESET}"
}
log_warning() {
echo -e "${YELLOW}[WARNING] $1${RESET}"
}
log_error() {
echo -e "${RED}[ERROR] $1${RESET}"
}
# Clean up temp directory
echo "⏳ Cleaning up temporary files..."
if rm -rf /home/container/tmp/*; then
log_success "Temporary files removed successfully."
else
log_error "Failed to remove temporary files."
exit 1
fi
# Start PHP-FPM
echo "⏳ Starting PHP-FPM..."
if /usr/sbin/php-fpm8 --fpm-config /home/container/php-fpm/php-fpm.conf --daemonize; then
log_success "PHP-FPM started successfully."
else
log_error "Failed to start PHP-FPM."
exit 1
fi
# NGINX if else WIP
echo "⏳ Starting Nginx..."
# Final message
log_success "Web server is running. All services started successfully."
/usr/sbin/nginx -c /home/container/nginx/nginx.conf -p /home/container/
# Keep the container running (optional, depending on your container setup)
tail -f /dev/null