|
#!/bin/bash |
|
|
|
## INSTALLATION: |
|
## ----------------- |
|
## Create a new alias in your Bash/ZSH startup file |
|
## For Bash the startup file can be found here "~/.bashrc" |
|
## and for ZSH it can be found here "~/.zshrc". |
|
## Now copy this script to a local directory, e.g. under: |
|
## |
|
## ~/.shellscripts/typo3/install.sh |
|
## |
|
## and add the following alias to your startup file: |
|
## |
|
## alias install-typo3="bash ~/.shellscripts/typo3/install.sh" |
|
## |
|
## |
|
## USAGE |
|
## ----------------- |
|
## Call the script with one of the version numbers "10", "11", "12", "13" or |
|
## "dev" (for the latest dev version) and any number of following parameters, |
|
## each of which stands for the installation directory name in which typo3 is |
|
## to be installed. |
|
## |
|
## If no directory names are specified, the name typo3-<version>-project |
|
## is used. If no version number is specified, the latest version 13 will |
|
## be installed. |
|
## |
|
## Example for version 12 in directories "first-project" and "second-project": |
|
## install-typo3 12 first-project second-project |
|
## |
|
## |
|
## BACKEND LOGIN: |
|
## ----------------- |
|
## Login-URL: https://directory.ddev.site/typo3/ |
|
## Username: admin |
|
## Password: Password1% |
|
## |
|
## © 2024 Eric Harrer |
|
## |
|
|
|
set -Eeuo pipefail |
|
|
|
# ANSI color codes |
|
RED='\033[0;31m' |
|
GREEN='\033[0;32m' |
|
NC='\033[0m' # No Color |
|
|
|
# Function to execute TYPO3 installation with version check and directory preparation |
|
execute_typo3_installation() { |
|
local version=$1 |
|
local directories=("${@:2}") # Capture all arguments after the first one as directory names |
|
|
|
# Verify if the version is supported before proceeding |
|
if ! [[ $version =~ ^(10|11|12|13|dev)$ ]]; then |
|
printf "\n--- %bThe specified TYPO3 version is not supported: %s%b\n" "$RED" "$version" "$NC" |
|
printf "\n--- Supported versions are %b10, 11, 12, 13, dev%b.\n" "$GREEN" "$NC" |
|
return 1 |
|
fi |
|
|
|
# Default to a directory name based on the version if none specified |
|
if [ ${#directories[@]} -eq 0 ]; then |
|
directories=("typo3-${version}-project") |
|
fi |
|
|
|
# Run the installation process for each directory |
|
for dir in "${directories[@]}"; do |
|
if [ -d "$dir" ] && [ "$(ls -A "$dir")" ]; then |
|
printf "\n--- %bError: The directory %s exists and is not empty. Aborting installation to prevent data loss.%b\n" "$RED" "$dir" "$NC" |
|
return 1 # Abort execution to prevent overwriting existing data |
|
fi |
|
|
|
if [ ! -d "$dir" ]; then |
|
printf "\n--- Creating directory: %b%s%b\n" "$GREEN" "$dir" "$NC" |
|
mkdir -p "$dir" || exit # Exits the script if mkdir fails |
|
else |
|
printf "\n--- Directory %b%s%b exists but is empty. Continuing installation...\n" "$GREEN" "$dir" "$NC" |
|
fi |
|
|
|
printf "\n--- Changing to directory: %b%s%b\n" "$GREEN" "$dir" "$NC" |
|
cd "$dir" || return # Returns if cd fails |
|
|
|
# Determine PHP version based on TYPO3 version |
|
local php_version="8.3" |
|
[ "$version" = "10" ] && php_version="7.4" |
|
|
|
printf "\n--- Executing general installation steps for TYPO3 version %b%s%b in directory %b%s%b...\n" "$GREEN" "$version" "$NC" "$GREEN" "$dir" "$NC" |
|
ddev config \ |
|
--project-type=typo3 \ |
|
--docroot=public \ |
|
--php-version=$php_version \ |
|
--webserver-type=apache-fpm \ |
|
--xdebug-enabled=false \ |
|
--database=mariadb:10.11 \ |
|
--performance-mode=mutagen \ |
|
--webimage-extra-packages=graphicsmagick \ |
|
--use-dns-when-possible=true \ |
|
--timezone=Europe/Berlin \ |
|
--composer-version=2 \ |
|
--web-environment=TYPO3_CONTEXT=Development |
|
|
|
printf "\n--- Install cronjob add-on (https://github.com/drud/ddev-cron)\n" |
|
ddev get drud/ddev-cron |
|
|
|
printf "\n--- Update cron configuration to execute scheduler every minute\n" |
|
printf '* * * * * IS_DDEV_PROJECT=true /var/www/html/vendor/bin/typo3 scheduler:run -vv\n' >.ddev/web-build/typo3-scheduler.cron |
|
|
|
printf "\n--- Install phpMyAdmin add-on (https://github.com/ddev/ddev-phpmyadmin)\n" |
|
ddev get ddev/ddev-phpmyadmin |
|
|
|
printf "\n--- Start environment\n" |
|
ddev start -y |
|
|
|
printf "\n--- Init composer\n" |
|
ddev composer init \ |
|
--name="erhaweb/typo3-$version-autoinstallation" \ |
|
--description="TYPO3 $version Auto-Installation" \ |
|
--author="Eric Harrer <info@eric-harrer.de>" \ |
|
--type="project" \ |
|
--homepage="https://www.eric-harrer.de" \ |
|
--stability="stable" \ |
|
--license="GPL-2.0-or-later" \ |
|
--repository='{"type":"path","url":"packages/*"}' \ |
|
--quiet |
|
|
|
printf "\n--- Allow plugin typo3/class-alias-loader\n" |
|
ddev composer config --no-interaction allow-plugins.typo3/class-alias-loader true |
|
|
|
printf "\n--- Allow plugin typo3/cms-composer-installers\n" |
|
ddev composer config --no-interaction allow-plugins.typo3/cms-composer-installers true |
|
|
|
printf "\n--- Add further default composer settings\n" |
|
ddev composer config --no-interaction platform.php "$php_version" |
|
ddev composer config --no-interaction sort-packages true |
|
|
|
local sitepackage_branch="$version" |
|
[ "$version" = "dev" ] && sitepackage_branch="main" |
|
|
|
printf "\n--- Download sitepackage base structure\n" |
|
ddev exec git clone --branch "$sitepackage_branch" https://github.com/ErHaWeb/sitepackage.git "packages/sitepackage/" |
|
|
|
local typo3_branch="" |
|
case $version in |
|
10) typo3_branch="10.4" ;; |
|
11) typo3_branch="11.5" ;; |
|
12) typo3_branch="12.4" ;; |
|
13) typo3_branch="13.1" ;; |
|
*) typo3_branch="main" ;; |
|
esac |
|
|
|
printf "\n--- Download .editorconfig file from TYPO3 repository branch %b$typo3_branch%b\n" "$GREEN" "$NC" |
|
ddev exec wget "https://raw.githubusercontent.com/TYPO3/typo3/$typo3_branch/.editorconfig" |
|
|
|
local package_version="" |
|
case $version in |
|
10) package_version="^10.4" ;; |
|
11) package_version="^11.5" ;; |
|
12) package_version="^12.4" ;; |
|
13) package_version="^13.1" ;; |
|
*) package_version="dev-main" ;; |
|
esac |
|
|
|
printf "\n--- Add general TYPO3 core packages for version %b$version%b and sitepackage\n" "$GREEN" "$NC" |
|
ddev composer require --no-install \ |
|
"typo3/cms-adminpanel:$package_version" \ |
|
"typo3/cms-backend:$package_version" \ |
|
"typo3/cms-belog:$package_version" \ |
|
"typo3/cms-beuser:$package_version" \ |
|
"typo3/cms-core:$package_version" \ |
|
"typo3/cms-dashboard:$package_version" \ |
|
"typo3/cms-extbase:$package_version" \ |
|
"typo3/cms-extensionmanager:$package_version" \ |
|
"typo3/cms-felogin:$package_version" \ |
|
"typo3/cms-filelist:$package_version" \ |
|
"typo3/cms-filemetadata:$package_version" \ |
|
"typo3/cms-fluid:$package_version" \ |
|
"typo3/cms-fluid-styled-content:$package_version" \ |
|
"typo3/cms-form:$package_version" \ |
|
"typo3/cms-frontend:$package_version" \ |
|
"typo3/cms-impexp:$package_version" \ |
|
"typo3/cms-indexed-search:$package_version" \ |
|
"typo3/cms-info:$package_version" \ |
|
"typo3/cms-install:$package_version" \ |
|
"typo3/cms-linkvalidator:$package_version" \ |
|
"typo3/cms-lowlevel:$package_version" \ |
|
"typo3/cms-opendocs:$package_version" \ |
|
"typo3/cms-recycler:$package_version" \ |
|
"typo3/cms-redirects:$package_version" \ |
|
"typo3/cms-reports:$package_version" \ |
|
"typo3/cms-rte-ckeditor:$package_version" \ |
|
"typo3/cms-scheduler:$package_version" \ |
|
"typo3/cms-seo:$package_version" \ |
|
"typo3/cms-setup:$package_version" \ |
|
"typo3/cms-sys-note:$package_version" \ |
|
"typo3/cms-tstemplate:$package_version" \ |
|
"typo3/cms-viewpage:$package_version" \ |
|
"typo3/cms-workspaces:$package_version" \ |
|
"vendorname/sitepackage:@dev" |
|
|
|
printf "\n--- Add version specific TYPO3 core packages for version %b$version%b\n" "$GREEN" "$NC" |
|
case $version in |
|
10) |
|
ddev composer require --no-install \ |
|
"typo3/cms-t3editor:$package_version" \ |
|
"typo3/cms-recordlist:$package_version" \ |
|
"typo3/cms-about:$package_version" \ |
|
"helhum/typo3-console:^6.7" |
|
;; |
|
11) |
|
ddev composer require --no-install \ |
|
"typo3/cms-t3editor:$package_version" \ |
|
"typo3/cms-recordlist:$package_version" \ |
|
"typo3/cms-composer-installers:4.0.x@dev" \ |
|
"helhum/typo3-console:^8.0" |
|
;; |
|
12) |
|
ddev composer require --no-install \ |
|
"typo3/cms-t3editor:$package_version" \ |
|
"typo3/cms-reactions:$package_version" \ |
|
"typo3/cms-webhooks:$package_version" |
|
;; |
|
|
|
*) |
|
ddev composer require --no-install \ |
|
"typo3/cms-reactions:$package_version" \ |
|
"typo3/cms-webhooks:$package_version" |
|
;; |
|
esac |
|
|
|
printf "\n--- Install all packages\n" |
|
ddev composer update |
|
|
|
local additional_path="" |
|
case "$version" in |
|
10 | 11) additional_path="public/typo3conf/AdditionalConfiguration.php" ;; |
|
*) additional_path="config/system/additional.php" ;; |
|
esac |
|
|
|
printf "\n--- Rerun ddev config to create \"%s\"\n" "$additional_path" |
|
ddev config --auto |
|
|
|
local typo3_command="typo3" |
|
[[ $version == 10 ]] && typo3_command="typo3cms" |
|
|
|
printf "\n--- Run through TYPO3 installation process and take current directory name \"%s\" as site name\n" "${PWD##*/}" |
|
case $version in |
|
10 | 11) |
|
ddev $typo3_command install:setup \ |
|
--use-existing-database \ |
|
--database-driver="mysqli" \ |
|
--database-host-name="db" \ |
|
--database-port="3306" \ |
|
--database-socket="" \ |
|
--database-name="db" \ |
|
--database-user-name="db" \ |
|
--database-user-password="db" \ |
|
--admin-user-name="admin" \ |
|
--admin-password="Password1%" \ |
|
--site-name="${PWD##*/}" \ |
|
--site-setup-type="no" \ |
|
--site-base-url="/" \ |
|
--web-server-config="apache" \ |
|
--force \ |
|
--no-interaction |
|
;; |
|
*) |
|
# Tip: You may want to add the option --create-site="https://${PWD##*/}.ddev.site/" |
|
# to create a site configuration independently of the initialization of my site package |
|
ddev $typo3_command setup \ |
|
--driver="mysqli" \ |
|
--host="db" \ |
|
--port=3306 \ |
|
--dbname="db" \ |
|
--username="db" \ |
|
--password="db" \ |
|
--admin-username="admin" \ |
|
--admin-user-password="Password1%" \ |
|
--admin-email="info@eric-harrer.de" \ |
|
--project-name="${PWD##*/}" \ |
|
--server-type="apache" \ |
|
--force \ |
|
--no-interaction |
|
;; |
|
esac |
|
|
|
local extension_setup_param="" |
|
[[ $version == 10 ]] && extension_setup_param="sitepackage" |
|
|
|
printf "\n--- Run typo3 extension:setup to initialise pre-configured sitepackage data\n" |
|
ddev $typo3_command extension:setup $extension_setup_param |
|
|
|
printf "\n--- Flush TYPO3 Cache\n" |
|
ddev $typo3_command cache:flush |
|
|
|
printf "\n--- TYPO3 Backend-Login:\nUsername: admin\nPassword: Password1%s\n" "%" |
|
printf "\n--- Launch environment in browser\n" |
|
ddev launch |
|
|
|
cd - >/dev/null || return # Returns if cd fails |
|
done |
|
} |
|
|
|
# Main script logic to handle arguments |
|
if [ $# -eq 0 ]; then |
|
execute_typo3_installation 13 |
|
elif [ $# -eq 1 ] && [[ $1 =~ ^[0-9]+$ ]]; then |
|
execute_typo3_installation "$1" |
|
else |
|
execute_typo3_installation "$@" |
|
fi |
This is great. Thank you for the updates @ErHaWeb