1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/drupal_ynh.git synced 2024-09-03 18:35:53 +02:00
This commit is contained in:
Éric Gaspar 2023-05-22 23:00:09 +02:00 committed by Félix Piédallu
parent 5e41b355aa
commit 1530ab3998
6 changed files with 152 additions and 43 deletions

View file

@ -1,13 +1,14 @@
{ {
"name": "drupal/recommended-project", "name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 9 projects with a relocated document root", "description": "Project template for Drupal 10 projects with Composer",
"type": "project", "type": "project",
"license": "GPL-2.0-or-later", "license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/drupal", "authors": [
"support": { {
"docs": "https://www.drupal.org/docs/user_guide/en/index.html", "name": "",
"chat": "https://www.drupal.org/node/314178" "role": ""
}, }
],
"repositories": [ "repositories": [
{ {
"type": "composer", "type": "composer",
@ -15,14 +16,17 @@
} }
], ],
"require": { "require": {
"composer/installers": "^1.9", "php": ">=8.1",
"drupal/core-composer-scaffold": "^9.3", "composer/installers": "^2.1",
"drupal/core-project-message": "^9.3", "cweagans/composer-patches": "^1.7",
"drupal/core-recommended": "^9.3", "drupal/core-composer-scaffold": "^10.0.0",
"drush/drush": "^11.0.0" "drupal/core-recommended": "^10.0.0",
"drush/drush": "^11.4.0",
"vlucas/phpdotenv": "^5.1",
"webflo/drupal-finder": "^1.2"
}, },
"require-dev": { "require-dev": {
"drupal/core-dev": "^9.3" "drupal/core-dev": "^10.0.0"
}, },
"conflict": { "conflict": {
"drupal/drupal": "*" "drupal/drupal": "*"
@ -30,7 +34,35 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"prefer-stable": true, "prefer-stable": true,
"config": { "config": {
"sort-packages": true "discard-changes": true,
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"cweagans/composer-patches": true,
"drupal/core-composer-scaffold": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
}
},
"autoload": {
"classmap": [
"scripts/composer/ScriptHandler.php"
],
"files": ["load.environment.php"]
},
"scripts": {
"pre-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
],
"post-install-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
],
"post-update-cmd": [
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
]
}, },
"extra": { "extra": {
"drupal-scaffold": { "drupal-scaffold": {
@ -46,26 +78,19 @@
"__APP__/themes/contrib/{$name}": ["type:drupal-theme"], "__APP__/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"], "drush/Commands/contrib/{$name}": ["type:drupal-drush"],
"__APP__/modules/custom/{$name}": ["type:drupal-custom-module"], "__APP__/modules/custom/{$name}": ["type:drupal-custom-module"],
"__APP__/themes/custom/{$name}": ["type:drupal-custom-theme"] "__APP__/themes/custom/{$name}": ["type:drupal-custom-theme"],
"web/core": ["type:drupal-core"],
"web/libraries/{$name}": ["type:drupal-library"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/Commands/contrib/{$name}": ["type:drupal-drush"]
}, },
"drupal-core-project-message": { "composer-exit-on-patch-failure": true,
"include-keys": ["homepage", "support"], "patchLevel": {
"post-create-project-cmd-message": [ "drupal/core": "-p2"
"<bg=blue;fg=white> </>", },
"<bg=blue;fg=white> Congratulations, youve installed the Drupal codebase </>", "patches": {
"<bg=blue;fg=white> from the drupal/recommended-project template! </>",
"<bg=blue;fg=white> </>",
"",
"<bg=yellow;fg=black>Next steps</>:",
" * Install the site: https://www.drupal.org/docs/8/install",
" * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
" * Get support: https://www.drupal.org/support",
" * Get involved with the Drupal community:",
" https://www.drupal.org/getting-involved",
" * Remove the plugin that prints this message:",
" composer remove drupal/core-project-message"
]
} }
} }
} }

View file

@ -7,7 +7,7 @@ name = "Drupal"
description.en = "Content management framework" description.en = "Content management framework"
description.fr = "Système de gestion de contenu" description.fr = "Système de gestion de contenu"
version = "9.5.10~ynh2" version = "9.5.3~ynh3"
maintainers = ["yalh76"] maintainers = ["yalh76"]
@ -85,10 +85,8 @@ ram.runtime = "50M"
"php8.2-xml", "php8.2-xml",
"php8.2-ldap", "php8.2-ldap",
"php8.2-mbstring", "php8.2-mbstring",
"php8.2-json",
"php8.2-simplexml", "php8.2-simplexml",
"php8.2-curl", "php8.2-curl",
"php8.2-readline",
] ]
[resources.database] [resources.database]

View file

@ -25,3 +25,95 @@ _ynh_exec_with_drush_php() {
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================
# Add swap
#
# usage: ynh_add_swap --size=SWAP in Mb
# | arg: -s, --size= - Amount of SWAP to add in Mb.
ynh_add_swap () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [s]=size= )
local size
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
local swap_max_size=$(( $size * 1024 ))
local free_space=$(df --output=avail / | sed 1d)
# Because we don't want to fill the disk with a swap file, divide by 2 the available space.
local usable_space=$(( $free_space / 2 ))
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
# Swap on SD card only if it's is specified
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]
then
ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
return
fi
# Compare the available space with the size of the swap.
# And set a acceptable size from the request
if [ $usable_space -ge $swap_max_size ]
then
local swap_size=$swap_max_size
elif [ $usable_space -ge $(( $swap_max_size / 2 )) ]
then
local swap_size=$(( $swap_max_size / 2 ))
elif [ $usable_space -ge $(( $swap_max_size / 3 )) ]
then
local swap_size=$(( $swap_max_size / 3 ))
elif [ $usable_space -ge $(( $swap_max_size / 4 )) ]
then
local swap_size=$(( $swap_max_size / 4 ))
else
echo "Not enough space left for a swap file" >&2
local swap_size=0
fi
# If there's enough space for a swap, and no existing swap here
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]
then
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
if ! fallocate -l ${swap_size}K /swap_$app
then
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
fi
chmod 0600 /swap_$app
# Create the swap
mkswap /swap_$app
# And activate it
swapon /swap_$app
# Then add an entry in fstab to load this swap at each boot.
echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab
fi
}
ynh_del_swap () {
# If there a swap at this place
if [ -e /swap_$app ]
then
# Clean the fstab
sed -i "/#Swap added by $app/d" /etc/fstab
# Desactive the swap file
swapoff /swap_$app
# And remove it
rm /swap_$app
fi
}
# Check if the device of the main mountpoint "/" is an SD card
#
# [internal]
#
# return 0 if it's an SD card, else 1
ynh_is_main_device_a_sd_card () {
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]
then
return 0
else
return 1
fi
}

View file

@ -7,7 +7,6 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ynh_add_swap
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -24,11 +24,6 @@ ynh_remove_fpm_config
# Remove the cron file # Remove the cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE SWAP
#=================================================
ynh_script_progression --message="Removing swap..."
ynh_del_swap ynh_del_swap
#================================================= #=================================================

View file

@ -24,7 +24,7 @@ ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir" --full_replace --keep="app composer.json" ynh_setup_source --dest_dir="$install_dir"
ynh_store_file_checksum --file="$install_dir/composer.json" ynh_store_file_checksum --file="$install_dir/composer.json"
mkdir -p "$install_dir/$app" mkdir -p "$install_dir/$app"