Files
Wordpress-Ansible/start.sh
2025-12-08 07:50:32 +00:00

39 lines
1.1 KiB
Bash

#!/bin/sh
set -e
# Download WordPress files if missing
if [ ! -f /data/index.php ]; then
echo "[INFO] WordPress core files fehlen, lade sie herunter..."
curl -o /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
tar -xzf /tmp/wordpress.tar.gz -C /tmp
cp -r /tmp/wordpress/* /data/
rm -rf /tmp/wordpress /tmp/wordpress.tar.gz
chown -R 101:101 /data
fi
# Generiere wp-config.php if missing
if [ ! -f /data/wp-config.php ]; then
echo "[INFO] wp-config.php wird generiert"
cat > /data/wp-config.php <<EOF
<?php
define( 'DB_NAME', '${WORDPRESS_DB_NAME}' );
define( 'DB_USER', '${WORDPRESS_DB_USER}' );
define( 'DB_PASSWORD', '${WORDPRESS_DB_PASSWORD}' );
define( 'DB_HOST', '${WORDPRESS_DB_HOST}' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );
$(curl -s https://api.wordpress.org/secret-key/1.1/salt/)
\$table_prefix = 'wp_';
define( 'WP_DEBUG', false );
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
require_once ABSPATH . 'wp-settings.php';
EOF
chown 101:101 /data/wp-config.php
fi
# Start services
php-fpm82 --nodaemonize &
nginx -g "daemon off;"