mirror of
https://github.com/YunoHost-Apps/drupal_ynh.git
synced 2024-09-03 18:35:53 +02:00
Update for 3.8
This commit is contained in:
parent
a1fa36cc52
commit
18974a6afe
12 changed files with 32 additions and 455 deletions
|
@ -58,7 +58,7 @@ location __PATH__/ {
|
|||
|
||||
location ~ '[^/]\.php$|^/update.php' {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php7.3-fpm-__NAME__.sock;
|
||||
fastcgi_pass unix:/var/run/php/php__YNH_PHP_VERSION__-fpm-__NAME__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
|
|
|
@ -33,7 +33,7 @@ group = __USER__
|
|||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php/php7.3-fpm-__NAMETOCHANGE__.sock
|
||||
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"name": "yalh76"
|
||||
},
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.5"
|
||||
"yunohost": ">= 3.8"
|
||||
},
|
||||
"multi_instance": true,
|
||||
"services": [
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
# dependencies used by the app
|
||||
pkg_dependencies="curl"
|
||||
|
||||
extra_pkg_dependencies="php7.3-fpm php7.3-cli php7.3-gd php7.3-mysql php7.3-xml php7.3-ldap php7.3-mbstring php7.3-json php7.3-simplexml php7.3-curl"
|
||||
YNH_PHP_VERSION="7.3"
|
||||
|
||||
extra_php_dependencies="php${YNH_PHP_VERSION}-fpm php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-simplexml php${YNH_PHP_VERSION}-curl"
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
|
|
|
@ -53,7 +53,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
ynh_print_info --message="Backing up php-fpm configuration..."
|
||||
|
||||
ynh_backup --src_path="/etc/php/7.3/fpm/pool.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
|
|
|
@ -86,7 +86,7 @@ then
|
|||
domain="$old_domain"
|
||||
path_url="$new_path"
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
ynh_add_nginx_config YNH_PHP_VERSION
|
||||
fi
|
||||
|
||||
# Change the domain for nginx
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_add_extra_apt_repos__3
|
||||
source ynh_install_php__3
|
||||
source ynh_composer__2
|
||||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
@ -65,17 +63,6 @@ ynh_app_setting_set --app=$app --key=install_profil --value=$install_profil
|
|||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# INSTALL PHP7.3
|
||||
#=================================================
|
||||
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
|
||||
else
|
||||
ynh_print_info --message="Installing PHP7.3..."
|
||||
ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# INSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
@ -108,7 +95,7 @@ ynh_setup_source --dest_dir="$final_path"
|
|||
ynh_print_info --message="Configuring nginx web server..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
ynh_add_nginx_config YNH_PHP_VERSION
|
||||
|
||||
#=================================================
|
||||
# CREATE DEDICATED USER
|
||||
|
@ -118,6 +105,14 @@ ynh_print_info --message="Configuring system user..."
|
|||
# Create a system user
|
||||
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring php-fpm..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_dependencies"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
|
@ -151,7 +146,7 @@ mkdir -p "$final_path/.composer"
|
|||
cp -f "../conf/composer.json" "$final_path/composer.json"
|
||||
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$final_path/composer.json"
|
||||
|
||||
ynh_install_composer --phpversion="7.3" --workdir="$final_path"
|
||||
ynh_install_composer --phpversion="$YNH_PHP_VERSION" --workdir="$final_path"
|
||||
|
||||
export PATH="$final_path/vendor/bin:$PATH"
|
||||
|
||||
|
@ -162,7 +157,7 @@ ynh_print_info --message="Installing Drupal..."
|
|||
|
||||
chown -R $app: $final_path
|
||||
|
||||
update-alternatives --set php /usr/bin/php7.3
|
||||
update-alternatives --set php /usr/bin/php$YNH_PHP_VERSION
|
||||
|
||||
pushd "$final_path"
|
||||
sudo -u $app env PATH=$PATH drush site:install $install_profil --account-name=$admin --account-pass=$password --account-mail=$admin_mail --db-url=mysql://$db_user:$db_pwd@localhost/$db_name --site-name="$app" --locale=$language --yes
|
||||
|
@ -190,14 +185,6 @@ ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php"
|
|||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_print_info --message="Configuring php-fpm..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config --phpversion="7.3"
|
||||
|
||||
#=================================================
|
||||
# SECURE FILES AND DIRECTORIES
|
||||
#=================================================
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_add_extra_apt_repos__3
|
||||
source ynh_install_php__3
|
||||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source ../settings/scripts/ynh_add_extra_apt_repos__3
|
||||
source ../settings/scripts/ynh_install_php__3
|
||||
source ../settings/scripts/ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
|
@ -81,17 +79,6 @@ chown -R $app: $final_path
|
|||
|
||||
#=================================================
|
||||
# SPECIFIC RESTORATION
|
||||
#=================================================
|
||||
# REINSTALL PHP7.3
|
||||
#=================================================
|
||||
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
|
||||
else
|
||||
ynh_print_info --message="Reinstalling PHP7.3..."
|
||||
ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REINSTALL DEPENDENCIES
|
||||
#=================================================
|
||||
|
@ -114,7 +101,9 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
|
|||
#=================================================
|
||||
ynh_print_info --message="Restoring PHP-FPM configuration..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/7.3/fpm/pool.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf"
|
||||
|
||||
ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_dependencies"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE CRON FILE
|
||||
|
@ -136,7 +125,7 @@ ynh_add_swap --size=512
|
|||
#=================================================
|
||||
ynh_print_info --message="Reloading nginx web server and php-fpm..."
|
||||
|
||||
ynh_systemd_action --service_name=php7.3-fpm --action=reload
|
||||
ynh_systemd_action --service_name=php${YNH_PHP_VERSION}-fpm --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source ynh_add_extra_apt_repos__3
|
||||
source ynh_install_php__3
|
||||
source ynh_composer__2
|
||||
source ynh_add_swap
|
||||
source /usr/share/yunohost/helpers
|
||||
|
@ -83,25 +81,7 @@ ynh_abort_if_errors
|
|||
ynh_print_info --message="Upgrading nginx web server configuration..."
|
||||
|
||||
# Create a dedicated nginx config
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
# UPGRADE PHP7.3
|
||||
#=================================================
|
||||
|
||||
if [ "$(lsb_release --codename --short)" = "buster" ]; then
|
||||
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
|
||||
else
|
||||
if [ "$(ynh_app_setting_get --app=$app --key=php_version)" != "7.3" ]; then
|
||||
ynh_print_info --message="Upgrading PHP7.3..."
|
||||
ynh_remove_fpm_config
|
||||
ynh_remove_app_dependencies
|
||||
ynh_remove_php
|
||||
ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies"
|
||||
else
|
||||
ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies"
|
||||
fi
|
||||
fi
|
||||
ynh_add_nginx_config YNH_PHP_VERSION
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DEPENDENCIES
|
||||
|
@ -124,7 +104,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
|
|||
ynh_print_info --message="Upgrading php-fpm configuration..."
|
||||
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config --phpversion="7.3"
|
||||
ynh_add_fpm_config --phpversion="$YNH_PHP_VERSION" --package="$extra_php_dependencies"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
|
@ -140,9 +120,9 @@ ynh_add_swap --size=512
|
|||
#=================================================
|
||||
ynh_print_info --message="Upgrading Composer..."
|
||||
|
||||
update-alternatives --set php /usr/bin/php7.3
|
||||
ynh_install_composer --phpversion="7.3" --workdir="$final_path"
|
||||
update-alternatives --set php /usr/bin/php7.0
|
||||
ynh_install_composer --phpversion="$YNH_PHP_VERSION" --workdir="$final_path"
|
||||
|
||||
export PATH="$final_path/vendor/bin:$PATH"
|
||||
|
||||
#=================================================
|
||||
# UPGRADE DRUPAL
|
||||
|
@ -150,20 +130,13 @@ update-alternatives --set php /usr/bin/php7.0
|
|||
ynh_print_info --message="Upgrading Drupal..."
|
||||
|
||||
ynh_backup_if_checksum_is_different --file="$final_path/$app/sites/default/settings.php"
|
||||
export PATH="$final_path/vendor/bin:$PATH"
|
||||
|
||||
#sudo -u $app env PATH=$PATH drush @$app.prod cache-clear all
|
||||
#sudo -u $app env PATH=$PATH drush @$app.prod pm-update drupal
|
||||
#sudo -u $app env PATH=$PATH drush @$app.prod cache-clear all
|
||||
#sudo -u $app env PATH=$PATH drush @$app.prod l10n-update-refresh
|
||||
#sudo -u $app env PATH=$PATH drush @$app.prod l10n-update
|
||||
|
||||
update-alternatives --set php /usr/bin/php7.3
|
||||
update-alternatives --set php /usr/bin/php$YNH_PHP_VERSION
|
||||
|
||||
pushd "$final_path"
|
||||
sudo -u $app env PATH=$PATH drush @$app.prod state:set system.maintenance_mode 1 --input-format=integer
|
||||
sudo -u $app env PATH=$PATH php7.3 composer.phar update drupal/core webflo/drupal-core-require-dev --with-dependencies
|
||||
sudo -u $app env PATH=$PATH php7.3 composer.phar update --with-dependencies
|
||||
sudo -u $app env PATH=$PATH php composer.phar update drupal/core webflo/drupal-core-require-dev --with-dependencies
|
||||
sudo -u $app env PATH=$PATH php composer.phar update --with-dependencies
|
||||
sudo -u $app env PATH=$PATH drush @$app.prod -y updatedb
|
||||
sudo -u $app env PATH=$PATH drush @$app.prod cache:rebuild
|
||||
sudo -u $app env PATH=$PATH drush @$app.prod state:set system.maintenance_mode 0 --input-format=integer
|
||||
|
|
|
@ -1,294 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Pin a repository.
|
||||
#
|
||||
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
|
||||
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
|
||||
# | arg: -i, --pin - Filter for the pin.
|
||||
# | arg: -p, --priority - Priority for the pin
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
#
|
||||
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
|
||||
#
|
||||
ynh_pin_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pirna
|
||||
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
|
||||
local package
|
||||
local pin
|
||||
local priority
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
package="${package:-*}"
|
||||
priority=${priority:-50}
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="tee -a"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir -p "/etc/apt/preferences.d"
|
||||
echo "Package: $package
|
||||
Pin: $pin
|
||||
Pin-Priority: $priority" \
|
||||
| $append "/etc/apt/preferences.d/$name"
|
||||
}
|
||||
|
||||
# Add a repository.
|
||||
#
|
||||
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
|
||||
# | arg: -u, --uri - Uri of the repository.
|
||||
# | arg: -s, --suite - Suite of the repository.
|
||||
# | arg: -c, --component - Component of the repository.
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
#
|
||||
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
|
||||
# uri suite component
|
||||
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
|
||||
#
|
||||
ynh_add_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=uscna
|
||||
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
|
||||
local uri
|
||||
local suite
|
||||
local component
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="tee -a"
|
||||
else
|
||||
append="tee"
|
||||
fi
|
||||
|
||||
mkdir -p "/etc/apt/sources.list.d"
|
||||
# Add the new repo in sources.list.d
|
||||
echo "deb $uri $suite $component" \
|
||||
| $append "/etc/apt/sources.list.d/$name.list"
|
||||
}
|
||||
|
||||
# Add an extra repository correctly, pin it and get the key.
|
||||
#
|
||||
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
|
||||
# | arg: -r, --repo - Complete url of the extra repository.
|
||||
# | arg: -k, --key - url to get the public key.
|
||||
# | arg: -p, --priority - Priority for the pin
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
# | arg: -a, --append - Do not overwrite existing files.
|
||||
ynh_install_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rkpna
|
||||
declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
|
||||
local repo
|
||||
local key
|
||||
local priority
|
||||
local name
|
||||
local append
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
append=${append:-0}
|
||||
key=${key:-0}
|
||||
priority=${priority:-}
|
||||
|
||||
if [ $append -eq 1 ]
|
||||
then
|
||||
append="--append"
|
||||
wget_append="tee -a"
|
||||
else
|
||||
append=""
|
||||
wget_append="tee"
|
||||
fi
|
||||
|
||||
# Split the repository into uri, suite and components.
|
||||
# Remove "deb " at the beginning of the repo.
|
||||
repo="${repo#deb }"
|
||||
|
||||
# Get the uri
|
||||
local uri="$(echo "$repo" | awk '{ print $1 }')"
|
||||
|
||||
# Get the suite
|
||||
local suite="$(echo "$repo" | awk '{ print $2 }')"
|
||||
|
||||
# Get the components
|
||||
local component="${repo##$uri $suite }"
|
||||
|
||||
# Add the repository into sources.list.d
|
||||
ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append
|
||||
|
||||
# Pin the new repo with the default priority, so it won't be used for upgrades.
|
||||
# Build $pin from the uri without http and any sub path
|
||||
local pin="${uri#*://}"
|
||||
pin="${pin%%/*}"
|
||||
# Set a priority only if asked
|
||||
if [ -n "$priority" ]
|
||||
then
|
||||
priority="--priority=$priority"
|
||||
fi
|
||||
ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append
|
||||
|
||||
# Get the public key for the repo
|
||||
if [ -n "$key" ]
|
||||
then
|
||||
mkdir -p "/etc/apt/trusted.gpg.d"
|
||||
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
|
||||
fi
|
||||
|
||||
# Update the list of package with the new repo
|
||||
ynh_package_update
|
||||
}
|
||||
|
||||
# Remove an extra repository and the assiociated configuration.
|
||||
#
|
||||
# usage: ynh_remove_extra_repo [--name=name]
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
ynh_remove_extra_repo () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=n
|
||||
declare -Ar args_array=( [n]=name= )
|
||||
local name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
|
||||
ynh_secure_remove "/etc/apt/sources.list.d/$name.list"
|
||||
ynh_secure_remove "/etc/apt/preferences.d/$name"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg"
|
||||
ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc"
|
||||
|
||||
# Update the list of package to exclude the old repo
|
||||
ynh_package_update
|
||||
}
|
||||
|
||||
# Install packages from an extra repository properly.
|
||||
#
|
||||
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
|
||||
# | arg: -r, --repo - Complete url of the extra repository.
|
||||
# | arg: -p, --package - The packages to install from this extra repository
|
||||
# | arg: -k, --key - url to get the public key.
|
||||
# | arg: -n, --name - Name for the files for this repo, $app as default value.
|
||||
ynh_install_extra_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=rpkn
|
||||
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
|
||||
local repo
|
||||
local package
|
||||
local key
|
||||
local name
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
name="${name:-$app}"
|
||||
key=${key:-0}
|
||||
|
||||
# Set a key only if asked
|
||||
if [ -n "$key" ]
|
||||
then
|
||||
key="--key=$key"
|
||||
fi
|
||||
# Add an extra repository for those packages
|
||||
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
|
||||
|
||||
# Install requested dependencies from this extra repository.
|
||||
ynh_add_app_dependencies --package="$package"
|
||||
|
||||
# Remove this extra repository after packages are installed
|
||||
ynh_remove_extra_repo --name=$app
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
|
||||
|
||||
# Define and install dependencies with a equivs control file
|
||||
# This helper can/should only be called once per app
|
||||
#
|
||||
# usage: ynh_install_app_dependencies dep [dep [...]]
|
||||
# | arg: dep - the package name to install in dependence
|
||||
# You can give a choice between some package with this syntax : "dep1|dep2"
|
||||
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
||||
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
|
||||
#
|
||||
# Requires YunoHost version 2.6.4 or higher.
|
||||
ynh_install_app_dependencies () {
|
||||
local dependencies=$@
|
||||
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
|
||||
dependencies=${dependencies//|/ | }
|
||||
local manifest_path="../manifest.json"
|
||||
if [ ! -e "$manifest_path" ]; then
|
||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
|
||||
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
|
||||
if [ ${#version} -eq 0 ]; then
|
||||
version="1.0"
|
||||
fi
|
||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
|
||||
# Handle specific versions
|
||||
if [[ "$dependencies" =~ [\<=\>] ]]
|
||||
then
|
||||
# Replace version specifications by relationships syntax
|
||||
# https://www.debian.org/doc/debian-policy/ch-relationships.html
|
||||
# Sed clarification
|
||||
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
|
||||
# [\<=\>] matches < = or >
|
||||
# \+ matches one or more occurence of the previous characters, for >= or >>.
|
||||
# [^,]\+ matches all characters except ','
|
||||
# Ex: package>=1.0 will be replaced by package (>= 1.0)
|
||||
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
|
||||
fi
|
||||
|
||||
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Package: ${dep_app}-ynh-deps
|
||||
Version: ${version}
|
||||
Depends: ${dependencies}
|
||||
Architecture: all
|
||||
Description: Fake package for $app (YunoHost app) dependencies
|
||||
This meta-package is only responsible of installing its dependencies.
|
||||
EOF
|
||||
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|
||||
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
|
||||
rm /tmp/${dep_app}-ynh-deps.control
|
||||
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
|
||||
}
|
||||
|
||||
ynh_add_app_dependencies () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=pr
|
||||
declare -Ar args_array=( [p]=package= [r]=replace)
|
||||
local package
|
||||
local replace
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
replace=${replace:-0}
|
||||
|
||||
local current_dependencies=""
|
||||
if [ $replace -eq 0 ]
|
||||
then
|
||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
||||
then
|
||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
||||
fi
|
||||
|
||||
current_dependencies=${current_dependencies// | /|}
|
||||
fi
|
||||
|
||||
ynh_install_app_dependencies "${current_dependencies}${package}"
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Install another version of php.
|
||||
#
|
||||
# usage: ynh_install_php --phpversion=phpversion [--package=packages]
|
||||
# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3
|
||||
# | arg: -p, --package - Additionnal php packages to install
|
||||
ynh_install_php () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=vp
|
||||
declare -Ar args_array=( [v]=phpversion= [p]=package= )
|
||||
local phpversion
|
||||
local package
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
package=${package:-}
|
||||
|
||||
# Store php_version into the config of this app
|
||||
ynh_app_setting_set $app php_version $phpversion
|
||||
|
||||
if [ "$phpversion" == "7.0" ]
|
||||
then
|
||||
ynh_die "Do not use ynh_install_php to install php7.0"
|
||||
fi
|
||||
|
||||
# Store the ID of this app and the version of php requested for it
|
||||
echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version"
|
||||
|
||||
# Add an extra repository for those packages
|
||||
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version
|
||||
|
||||
# Install requested dependencies from this extra repository.
|
||||
# Install php-fpm first, otherwise php will install apache as a dependency.
|
||||
ynh_add_app_dependencies --package="php${phpversion}-fpm"
|
||||
ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package"
|
||||
|
||||
# Set php7.0 back as the default version for php-cli.
|
||||
update-alternatives --set php /usr/bin/php7.0
|
||||
|
||||
# Pin this extra repository after packages are installed to prevent sury of doing shit
|
||||
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" 200 --name=extra_php_version
|
||||
ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" 600 --name=extra_php_version --append
|
||||
|
||||
# INTEGRATE SERVICE IN YUNOHOST
|
||||
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
|
||||
}
|
||||
|
||||
ynh_remove_php () {
|
||||
# Get the version of php used by this app
|
||||
local phpversion=$(ynh_app_setting_get $app php_version)
|
||||
|
||||
if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ]
|
||||
then
|
||||
if [ "$phpversion" == "7.0" ]
|
||||
then
|
||||
ynh_print_err "Do not use ynh_remove_php to install php7.0"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Remove the line for this app
|
||||
sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version"
|
||||
|
||||
# If no other app uses this version of php, remove it.
|
||||
if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version"
|
||||
then
|
||||
# Purge php dependences for this version.
|
||||
ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common"
|
||||
# Remove the service from the admin panel
|
||||
yunohost service remove php${phpversion}-fpm
|
||||
fi
|
||||
|
||||
# If no other app uses alternate php versions, remove the extra repo for php
|
||||
if [ ! -s "/etc/php/ynh_app_version" ]
|
||||
then
|
||||
ynh_secure_remove /etc/php/ynh_app_version
|
||||
fi
|
||||
}
|
Loading…
Add table
Reference in a new issue