commit 15596dc229f08f18ec2094d4641eb1d69ae22ff9 parent 55dc15bccb7dbf97cae8ee45b237ecbe9018f8f7 Author: Christian Grothoff <christian@grothoff.org> Date: Thu, 24 Jul 2025 22:15:54 +0200 setup scripts Diffstat:
| A | contrib/setup-drupal.sh | | | 78 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
| A | contrib/setup-drush.sh | | | 32 | ++++++++++++++++++++++++++++++++ |
2 files changed, 110 insertions(+), 0 deletions(-)
diff --git a/contrib/setup-drupal.sh b/contrib/setup-drupal.sh @@ -0,0 +1,78 @@ +#!/bin/bash +set -e + +# Variables +DRUPAL_VERSION=10.3.0 +DB_NAME=drupal +DB_USER=drupaluser +DB_PASS=drupalpass +INSTALL_DIR=/var/www/html +DRUPAL_DIR=$INSTALL_DIR/drupal + +echo "===> Updating packages..." +apt update && apt upgrade -y + +echo "===> Installing dependencies..." +apt install -y nginx php php-fpm php-pgsql php-gd php-xml php-mbstring php-curl php-zip php-apcu php-cli unzip curl wget postgresql postgresql-contrib + +echo "===> Creating PostgreSQL database and user..." +sudo -u postgres psql <<EOF +CREATE USER $DB_USER WITH PASSWORD '$DB_PASS'; +CREATE DATABASE $DB_NAME OWNER $DB_USER ENCODING 'UTF8'; +EOF + +echo "===> Downloading latest Drupal 10..." +cd /tmp + +wget https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz +tar -xzf drupal-${DRUPAL_VERSION}.tar.gz +rm -rf $DRUPAL_DIR +mv drupal-${DRUPAL_VERSION} $DRUPAL_DIR + +echo "===> Setting permissions..." +chown -R www-data:www-data $DRUPAL_DIR +chmod -R 755 $DRUPAL_DIR + +echo "===> Configuring Nginx for Drupal..." +cat > /etc/nginx/sites-available/drupal <<EOF +server { + listen 80; + server_name localhost; + + root $DRUPAL_DIR; + index index.php index.html index.htm; + + location / { + try_files \$uri /index.php?\$query_string; + } + + location ~ \.php\$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/run/php/php8.2-fpm.sock; + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; + include fastcgi_params; + } + + location ~ /\.ht { + deny all; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires max; + log_not_found off; + } +} +EOF + +echo "===> Enabling Drupal Nginx site..." +ln -sf /etc/nginx/sites-available/drupal /etc/nginx/sites-enabled/drupal +rm -f /etc/nginx/sites-enabled/default + +echo "===> Restarting services..." +systemctl restart php8.2-fpm +systemctl restart nginx +systemctl enable php8.2-fpm nginx postgresql + +echo "===> Done!" +echo "Visit http://localhost to finish installing Drupal 10." +echo "Database: $DB_NAME | User: $DB_USER | Password: $DB_PASS" diff --git a/contrib/setup-drush.sh b/contrib/setup-drush.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status +set -e + +echo "Updating package list..." +sudo apt update + +echo "Installing required packages..." +sudo apt install -y curl php-cli unzip git php-mbstring php-xml php-curl + +# Install Composer (PHP package manager) if not already installed +if ! command -v composer &> /dev/null; then + echo "Composer not found, installing Composer..." + curl -sS https://getcomposer.org/installer | php + sudo mv composer.phar /usr/local/bin/composer +else + echo "Composer is already installed." +fi + +# Install Drush Launcher globally +if ! command -v drush &> /dev/null; then + echo "Installing Drush Launcher..." + curl -OL https://github.com/drush-ops/drush-launcher/releases/latest/download/drush.phar + chmod +x drush.phar + sudo mv drush.phar /usr/local/bin/drush +else + echo "Drush is already installed." +fi + +echo "Drush installed successfully. Version:" +drush --version