1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Merge pull request #139 from YunoHost-Apps/testing

Remove composer
This commit is contained in:
yalh76 2021-05-19 02:20:30 +02:00 committed by GitHub
commit 8ef41895fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 128 deletions

View file

@ -24,6 +24,8 @@
upgrade=1 from_commit=9c7d0ff114bb0bd3482901fde4bd82b494aa2e6d
# 0.10.10~ynh1
upgrade=1 from_commit=1aa406fb124b92f03b1bb69fc3462936d5227278
# 0.10.10~ynh3
upgrade=1 from_commit=2a796e30dd521a5022586bc7fe59d189210028a4
backup_restore=1
multi_instance=1
port_already_use=0
@ -42,3 +44,5 @@ Notification=all
name=0.10.9~ynh3
; commit=1aa406fb124b92f03b1bb69fc3462936d5227278
name=0.10.10~ynh1
; commit=2a796e30dd521a5022586bc7fe59d189210028a4
name=0.10.10~ynh3

View file

@ -6,7 +6,7 @@
"en": "ActivityPub Federated Image Sharing",
"fr": "Logiciel de partage d'image fédéré via ActivityPub"
},
"version": "0.10.10~ynh3",
"version": "0.10.10~ynh4",
"url": "https://pixelfed.org/",
"license": "AGPL-3.0-or-later",
"maintainer": [
@ -22,7 +22,7 @@
}
],
"requirements": {
"yunohost": ">= 4.1.3"
"yunohost": ">= 4.2.0"
},
"multi_instance": true,
"services": [

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_composer__3
source ynh_supervisor
source /usr/share/yunohost/helpers
@ -68,7 +67,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# CREATE A POSTGRESQL DATABASE
@ -150,7 +149,7 @@ chown $app:$app "$final_path/.env"
ynh_script_progression --message="Configuring a supervisor service..."
# Create a dedicated supervisor config
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion"
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf
#=================================================
# DEPLOY

View file

@ -60,7 +60,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE APP MAIN DIR

View file

@ -7,7 +7,6 @@
#=================================================
source _common.sh
source ynh_composer__3
source ynh_supervisor
source /usr/share/yunohost/helpers
@ -35,18 +34,6 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
@ -62,6 +49,18 @@ ynh_clean_setup () {
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# ENSURE UPGRADE COMPATIBILITY
#=================================================
@ -97,7 +96,7 @@ if dpkg --compare-versions "0.10.9~ynh2" gt "$(ynh_read_manifest --manifest="/et
ynh_script_progression --message="Configuring a supervisor service..."
phpversion=$YNH_PHP_VERSION
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion"
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf
ynh_script_progression --message="Starting a supervisor service..."
ynh_supervisor_action --service_name="${app}-horizon" --action="start" --log_path="systemd" --line_match="success: ${app}-horizon"
@ -236,7 +235,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
ynh_script_progression --message="Upgrading supervisor configuration..."
# Create a dedicated supervisor config
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf --others_var="phpversion"
ynh_add_supervisor_config --service="${app}-horizon" --template=horizon.conf
#=================================================
# GENERIC FINALIZATION

View file

@ -1,61 +0,0 @@
#!/bin/bash
readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17
# Declare the actual composer version to use.
# A packager willing to use another version of composer can override the variable into its _common.sh.
YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION}
# Execute a command with Composer
#
# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
# | arg: -v, --phpversion - PHP version to use with composer
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -c, --commands - Commands to execute.
ynh_composer_exec () {
# Declare an array to define the options of this helper.
local legacy_args=vwc
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
local phpversion
local workdir
local commands
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
COMPOSER_HOME="$workdir/.composer" \
php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
#
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion]
# | arg: -v, --phpversion - PHP version to use with composer
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
# | arg: -c, --composerversion - Composer version to install
ynh_install_composer () {
# Declare an array to define the options of this helper.
local legacy_args=vwa
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=)
local phpversion
local workdir
local install_args
local composerversion
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
install_args="${install_args:-}"
composerversion="${composerversion:-$YNH_COMPOSER_VERSION}"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \
|| ynh_die "Unable to install Composer."
# update dependencies to create composer.lock
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|| ynh_die "Unable to update core dependencies with Composer."
}

View file

@ -2,27 +2,20 @@
# Create a dedicated supervisor config
#
# usage: ynh_add_supervisor_config [--service=service] [--template=template] [--others_var="list of others variables to replace"]
# | arg: -s, --service= - Service name (optionnal, $app by default)
# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template)
# | arg: -v, --others_var= - List of others variables to replace separated by a space. For example: 'var_1 var_2 ...'
# usage: ynh_add_supervisor_config [--service=service] [--template=template]
# | arg: -s, --service= - Service name (optionnal, `$app` by default)
# | arg: -t, --template= - Name of template file (optionnal, this is 'supervisor' by default, meaning ./conf/supervisor.service will be used as template)
#
# This will use the template ../conf/<templatename>.service
# to generate a supervisor config, by replacing the following keywords
# with global variables that should be defined before calling
# this helper :
# This will use the template `../conf/<templatename>.service`.
#
# __APP__ by $app
# __FINALPATH__ by $final_path
#
# And dynamic variables (from the last example) :
# __VAR_1__ by $var_1
# __VAR_2__ by $var_2
# See the documentation of `ynh_add_config` for a description of the template
# format and how placeholders are replaced with actual variables.
#
# Requires YunoHost version 2.7.11 or higher.
ynh_add_supervisor_config () {
# Declare an array to define the options of this helper.
local legacy_args=stv
local -A args_array=( [s]=service= [t]=template= [v]=others_var= )
local -A args_array=( [s]=service= [t]=template= [v]=others_var=)
local service
local template
local others_var
@ -32,30 +25,10 @@ ynh_add_supervisor_config () {
local template="${template:-supervisor.service}"
others_var="${others_var:-}"
finalsupervisorconf="/etc/supervisor/conf.d/$service.conf"
ynh_backup_if_checksum_is_different --file="$finalsupervisorconf"
cp ../conf/$template "$finalsupervisorconf"
[[ -z "$others_var" ]] || ynh_print_warn --message="Packagers: using --others_var is unecessary since Yunohost 4.2"
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
# Substitute in a nginx config file only if the variable is not empty
if [ -n "${final_path:-}" ]; then
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalsupervisorconf"
fi
if [ -n "${app:-}" ]; then
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$finalsupervisorconf"
fi
ynh_add_config --template="$YNH_APP_BASEDIR/conf/$template" --destination="/etc/supervisor/conf.d/$service.conf"
# Replace all other variables given as arguments
for var_to_replace in $others_var
do
# ${var_to_replace^^} make the content of the variable on upper-cases
# ${!var_to_replace} get the content of the variable named $var_to_replace
ynh_replace_string --match_string="__${var_to_replace^^}__" --replace_string="${!var_to_replace}" --target_file="$finalsupervisorconf"
done
ynh_store_file_checksum --file="$finalsupervisorconf"
chown root: "$finalsupervisorconf"
supervisorctl reread
supervisorctl update
}
@ -63,8 +36,9 @@ ynh_add_supervisor_config () {
# Remove the dedicated supervisor config
#
# usage: ynh_remove_supervisor_config [--service=service]
# | arg: -s, --service= - Service name (optionnal, $app by default)
# | arg: -s, --service= - Service name (optionnal, $app by default)
#
# Requires YunoHost version 2.7.2 or higher.
ynh_remove_supervisor_config () {
# Declare an array to define the options of this helper.
local legacy_args=s
@ -86,14 +60,15 @@ ynh_remove_supervisor_config () {
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
#
# usage: ynh_supervisor_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
# | arg: -n, --service_name= - Name of the service to start. Default : $app
# usage: ynh_supervisor_action [--service_name=service_name] [--action=action] [ [--line_match="line to match"] [--log_path=log_path] [--timeout=300] [--length=20] ]
# | arg: -n, --service_name= - Name of the service to start. Default : `$app`
# | arg: -a, --action= - Action to perform with supervisorctl. Default: start
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started. WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure of the script. The script will then hang forever.
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. If not defined it don't wait until the service is completely started.
# | arg: -p, --log_path= - Log file - Path to the log file. Default : `/var/log/$app/$app.log`
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
# | arg: -e, --length= - Length of the error log : Default : 20
#
# Requires YunoHost version 3.5.0 or higher.
ynh_supervisor_action() {
# Declare an array to define the options of this helper.
local legacy_args=nalpte
@ -118,7 +93,8 @@ ynh_supervisor_action() {
then
local templog="$(mktemp)"
# Following the starting of the app in its log
if [ "$log_path" == "systemd" ] ; then
if [ "$log_path" == "systemd" ]
then
# Read the supervisor journal
journalctl --unit=supervisor --follow --since=-0 --quiet > "$templog" &
# Get the PID of the journalctl command
@ -144,16 +120,16 @@ ynh_supervisor_action() {
# If a log is specified for this service, show also the content of this log
if [ -e "$log_path" ]
then
ynh_print_err --message="--"
ynh_exec_err tail --lines=$length "$log_path"
fi
# Fail the app script, since the service failed.
ynh_die
ynh_clean_check_starting
return 1
fi
# Start the timeout and try to find line_match
if [[ -n "${line_match:-}" ]]
then
set +x
local i=0
for i in $(seq 1 $timeout)
do
@ -171,6 +147,7 @@ ynh_supervisor_action() {
fi
sleep 1
done
set -x
if [ $i -ge 3 ]; then
echo "" >&2
fi