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 #1 from YunoHost-Apps/testing

Testing
This commit is contained in:
yalh76 2019-04-11 16:22:50 +02:00 committed by GitHub
commit 354d71a0c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 285 additions and 259 deletions

View file

@ -9,7 +9,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
## Overview ## Overview
The federated image sharing service Pixelfed, for YunoHost The federated image sharing service Pixelfed, for YunoHost
**Shipped version:** 0.8.4 **Shipped version:** 0.8.6
I'm waiting for an official release (alpha/beta or stable) to invest more time on this package. I'm waiting for an official release (alpha/beta or stable) to invest more time on this package.
Don't hesitate to give a hand if you wish, I assume only the nginx file needs improvments. Don't hesitate to give a hand if you wish, I assume only the nginx file needs improvments.
@ -42,6 +42,11 @@ After being first registered, you need to execute the folloing command to promot
and respond yes to the question ` Add admin privileges to this user?` and respond yes to the question ` Add admin privileges to this user?`
### Allow/Close registration
Registrations are open by default.
To change that setting, edit `/var/www/pixelfed/.env` and set `OPEN_REGISTRATION=false` instead of `true`.
## Documentation ## Documentation
* [Official documentation](https://docs.pixelfed.org/master/) * [Official documentation](https://docs.pixelfed.org/master/)

View file

@ -7,12 +7,12 @@
setup_sub_dir=0 setup_sub_dir=0
setup_root=1 setup_root=1
setup_nourl=0 setup_nourl=0
setup_private=0 setup_private=1
setup_public=0 setup_public=1
upgrade=0 upgrade=1
backup_restore=0 backup_restore=1
multi_instance=0 multi_instance=1
incorrect_path=0 incorrect_path=1
port_already_use=0 port_already_use=0
change_url=0 change_url=0
;;; Levels ;;; Levels

View file

@ -1,7 +1,7 @@
APP_NAME=__APP__ APP_NAME=__APP__
APP_ENV=production APP_ENV=production
APP_KEY= APP_KEY=
APP_DEBUG=true APP_DEBUG=false
APP_URL=https://__DOMAIN__ APP_URL=https://__DOMAIN__
ADMIN_DOMAIN="__DOMAIN__" ADMIN_DOMAIN="__DOMAIN__"
@ -44,11 +44,6 @@ OPEN_REGISTRATION=true
RECAPTCHA_ENABLED=false RECAPTCHA_ENABLED=false
ENFORCE_EMAIL_VERIFICATION=true ENFORCE_EMAIL_VERIFICATION=true
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MAX_PHOTO_SIZE=15000 MAX_PHOTO_SIZE=15000
MAX_CAPTION_LENGTH=150 MAX_CAPTION_LENGTH=150
MAX_ALBUM_LENGTH=4 MAX_ALBUM_LENGTH=4
@ -68,5 +63,9 @@ HORIZON_DARKMODE=true
# php artisan cache:clear # php artisan cache:clear
# php artisan optimize:clear # php artisan optimize:clear
# php artisan optimize # php artisan optimize
ACTIVITY_PUB=false ACTIVITY_PUB=true
REMOTE_FOLLOW=false REMOTE_FOLLOW=true
CS_BLOCKED_DOMAINS='example.org,example.net,example.com'
CS_CW_DOMAINS='example.org,example.net,example.com'
CS_UNLISTED_DOMAINS='example.org,example.net,example.com'

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/ac53aea28884f0c49c110ac6d87a7b40e92171c9.tar.gz SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/v0.8.6.tar.gz
SOURCE_SUM=ca6156026eb1bb8d8995d247a895b88078e93f1127b75af07058d74f57830846 SOURCE_SUM=56acbfe18752693d3312207d6955e65c9f6aa73c7e801a224248b2d4b8e2884f
OURCE_SUM_PRG=sha256sum OURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,4 +1,4 @@
location __PATH__ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/public/ ; alias __FINALPATH__/public/ ;

View file

@ -5,17 +5,17 @@
"description": { "description": {
"en": "ActivityPub Federated Image Sharing" "en": "ActivityPub Federated Image Sharing"
}, },
"version": "0.8.4~ynh1", "version": "0.8.6~ynh2",
"url": "https://pixelfed.org/", "url": "https://pixelfed.org/",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"maintainer": { "maintainer": {
"name": "jibec", "name": "Jean-Baptiste Holcroft",
"email": "jean-baptiste@holcroft.fr" "email": "jean-baptiste@holcroft.fr"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.0.0" "yunohost": ">= 3.5"
}, },
"multi_instance": false, "multi_instance": true,
"services": [ "services": [
"nginx" "nginx"
], ],

View file

@ -5,12 +5,12 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="php7.2-pgsql php7.2-mbstring php7.2-bcmath php7.2-simplexml php7.2-curl postgresql redis-server \ pkg_dependencies="postgresql redis-server \
php7.2-intl php7.2-exif \ libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libmagickwand-6.q16-3 libwebp6 \
libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libwebp6 libmagickwand-6.q16-3 \
php7.2-gd \
pngquant jpegoptim gifsicle" pngquant jpegoptim gifsicle"
extra_pkg_dependencies="php7.2-bcmath php7.2-cli php7.2-curl php7.2-exif php7.2-gd php7.2-intl php7.2-json php7.2-mbstring php7.2-pgsql php7.2-simplexml php7.2-xml php7.2-zip"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
@ -62,83 +62,42 @@ ynh_install_composer () {
|| ynh_die "Unable to update core dependencies with Composer." || ynh_die "Unable to update core dependencies with Composer."
} }
# Install another version of php. # Install another version of php.
# #
# usage: ynh_install_php --phpversion=phpversion # 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: -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 () { ynh_install_php () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=v local legacy_args=vp
declare -Ar args_array=( [v]=phpversion= ) declare -Ar args_array=( [v]=phpversion= [p]=package= )
local phpversion local phpversion
local package
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
package=${package:-}
# Store php_version into the config of this app # Store php_version into the config of this app
ynh_app_setting_set $app php_version $phpversion ynh_app_setting_set $app php_version $phpversion
# Install an extra repo to get multiple php versions if [ "$phpversion" == "7.0" ]
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --name=php then
if [ "$phpversion" == "7.0" ]; then
ynh_die "Do not use ynh_install_php to install php7.0" ynh_die "Do not use ynh_install_php to install php7.0"
# Php 7.1
elif [ "$phpversion" == "7.1" ]; then
# Get the current version available for libpcre3 on packages.sury.org
local libpcre3_version=$(apt-cache madison "libpcre3" | grep "packages.sury.org" | tail -n1 | awk '{print $3}')
# equivs doesn't handle correctly this dependence.
# Force the upgrade of libpcre3 for php7.1
ynh_package_install "libpcre3=$libpcre3_version"
local php_dependencies="php7.1, php7.1-fpm"
# Php 7.2
elif [ "$phpversion" == "7.2" ]; then
# Get the current version available for libpcre3 on packages.sury.org
local libpcre3_version=$(apt-cache madison "libpcre3" | grep "packages.sury.org" | tail -n1 | awk '{print $3}')
# equivs doesn't handle correctly this dependence.
# Force the upgrade of libpcre3 for php7.2
ynh_package_install "libpcre3=$libpcre3_version"
local php_dependencies="php7.2, php7.2-fpm"
# Php 7.3
elif [ "$phpversion" == "7.3" ]; then
# Get the current version available for libpcre2-8-0 on packages.sury.org
local libpcre2_version=$(apt-cache madison "libpcre2-8-0" | grep "packages.sury.org" | tail -n1 | awk '{print $3}')
# equivs doesn't handle correctly this dependence.
# Force the upgrade of libpcre2-8-0 for php7.3
ynh_package_install "libpcre2-8-0=$libpcre2_version"
local php_dependencies="php7.3, php7.3-fpm"
else
ynh_die "The version $phpversion of php isn't handle by this helper."
fi fi
# Store the ID of this app and the version of php requested for it # Store the ID of this app and the version of php requested for it
echo "$YNH_APP_ID:$phpversion" | tee --append "/etc/php/ynh_app_version" echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version"
# Build a control file for equivs-build # Add an extra repository for those packages
echo "Section: misc 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
Priority: optional
Package: php${phpversion}-ynh-deps
Version: 1.0
Depends: $php_dependencies
Architecture: all
Description: Fake package for php_$phpversion dependencies
This meta-package is only responsible of installing its dependencies." \
> /tmp/php_${phpversion}-ynh-deps.control
# Install the fake package for php # Install requested dependencies from this extra repository.
ynh_package_install_from_equivs /tmp/php_${phpversion}-ynh-deps.control \ # Install php-fpm first, otherwise php will install apache as a dependency.
|| ynh_die --message="Unable to install dependencies" ynh_add_app_dependencies --package="php${phpversion}-fpm"
ynh_secure_remove /tmp/php_${phpversion}-ynh-deps.control ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package"
# Remove this extra repository after packages are installed
ynh_remove_extra_repo --name=extra_php_version
# Advertise service in admin panel # Advertise service in admin panel
yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log"
@ -158,37 +117,13 @@ ynh_remove_php () {
fi fi
# Remove the line for this app # Remove the line for this app
sed --in-place "/$YNH_APP_ID:$phpversion/d" "/etc/php/ynh_app_version" 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 no other app uses this version of php, remove it.
if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version"
then then
# Remove the metapackage for php # Purge php dependences for this version.
ynh_package_autopurge php${phpversion}-ynh-deps ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common"
# Then remove php-fpm php-cli for this version.
# The previous command won't remove them, but we have to remove those package to clean php
ynh_package_autopurge php${phpversion}-fpm php${phpversion}-cli
if [ "$phpversion" == "7.1" ] || [ "$phpversion" == "7.2" ]
then
# Do not restore libpcre3 if php7.1 or 7.2 is still used.
if ! grep --quiet --extended-regexp "7.1|7.2" "/etc/php/ynh_app_version"
then
# Get the current version available for libpcre3 on the standard repo
local libpcre3_version=$(apt-cache madison "libpcre3" | grep "debian.org" | tail -n1 | awk '{print $3}')
# Force to reinstall the standard version of libpcre3
ynh_package_install --allow-downgrades libpcre3=$libpcre3_version >&2
fi
elif [ "$phpversion" == "7.3" ]
then
# Get the current version available for libpcre2-8-0 on the standard repo
local libpcre2_version=$(apt-cache madison "libpcre2-8-0" | grep "debian.org" | tail -n1 | awk '{print $3}')
# Force to reinstall the standard version of libpcre2-8-0
ynh_package_install --allow-downgrades libpcre2-8-0=$libpcre2_version
fi
# Remove the service from the admin panel # Remove the service from the admin panel
yunohost service remove php${phpversion}-fpm yunohost service remove php${phpversion}-fpm
fi fi
@ -196,19 +131,16 @@ ynh_remove_php () {
# If no other app uses alternate php versions, remove the extra repo for php # If no other app uses alternate php versions, remove the extra repo for php
if [ ! -s "/etc/php/ynh_app_version" ] if [ ! -s "/etc/php/ynh_app_version" ]
then then
ynh_remove_extra_repo --name=php
ynh_secure_remove /etc/php/ynh_app_version ynh_secure_remove /etc/php/ynh_app_version
fi fi
} }
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================
# Pin a repository. # Pin a repository.
# #
# usage: ynh_pin_repo --package=packages --pin=pin_filter --priority=priority_value [--name=name] [--append] # 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: -p, --package - Packages concerned by the pin. Or all, *.
# | arg: -i, --pin - Filter for the pin. # | arg: -i, --pin - Filter for the pin.
# | arg: -p, --priority - Priority for the pin # | arg: -p, --priority - Priority for the pin
@ -289,17 +221,19 @@ ynh_add_repo () {
# Add an extra repository correctly, pin it and get the key. # Add an extra repository correctly, pin it and get the key.
# #
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--name=name] [--append] # 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: -r, --repo - Complete url of the extra repository.
# | arg: -k, --key - url to get the public key. # | 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: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files. # | arg: -a, --append - Do not overwrite existing files.
ynh_install_extra_repo () { ynh_install_extra_repo () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=rkna local legacy_args=rkpna
declare -Ar args_array=( [r]=repo= [k]=key= [n]=name= [a]=append ) declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append )
local repo local repo
local key local key
local priority
local name local name
local append local append
# Manage arguments with getopts # Manage arguments with getopts
@ -307,6 +241,7 @@ ynh_install_extra_repo () {
name="${name:-$app}" name="${name:-$app}"
append=${append:-0} append=${append:-0}
key=${key:-0} key=${key:-0}
priority=${priority:-}
if [ $append -eq 1 ] if [ $append -eq 1 ]
then then
@ -337,19 +272,18 @@ ynh_install_extra_repo () {
# Build $pin from the uri without http and any sub path # Build $pin from the uri without http and any sub path
local pin="${uri#*://}" local pin="${uri#*://}"
pin="${pin%%/*}" pin="${pin%%/*}"
ynh_pin_repo --package="*" --pin="origin \"$pin\"" --name="$name" $append # 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 # Get the public key for the repo
if [ -n "$key" ] if [ -n "$key" ]
then then
mkdir -p "/etc/apt/trusted.gpg.d" mkdir -p "/etc/apt/trusted.gpg.d"
if [[ "$(basename "$key")" =~ ".asc" ]] wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
then
local key_ext=asc
else
local key_ext=gpg
fi
wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.$key_ext > /dev/null
fi fi
# Update the list of package with the new repo # Update the list of package with the new repo
@ -377,3 +311,122 @@ ynh_remove_extra_repo () {
# Update the list of package to exclude the old repo # Update the list of package to exclude the old repo
ynh_package_update 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}"
}

View file

@ -14,10 +14,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -56,34 +52,12 @@ ynh_print_info "Backing up php-fpm configuration..."
ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf" ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf"
#================================================= #=================================================
# BACKUP THE PostgreSQL DATABASE # BACKUP THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_print_info "Backing up the PostgreSQL database..." ynh_print_info "Backing up the PostgreSQL database..."
ynh_psql_dump_db "$db_name" > db.sql ynh_psql_dump_db "$db_name" > db.sql
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_print_info "Backing up logrotate configuration..."
ynh_backup "/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_print_info "Backing up systemd configuration..."
ynh_backup "/etc/systemd/system/$app.service"
#=================================================
# BACKUP A CRON FILE
#=================================================
ynh_backup "/etc/cron.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -14,10 +14,10 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
old_domain=$YNH_APP_OLD_DOMAIN old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH old_path="/"
new_domain=$YNH_APP_NEW_DOMAIN new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH new_path="/"
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -43,12 +43,6 @@ then
change_domain=1 change_domain=1
fi fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -58,18 +52,6 @@ ynh_print_info "Updating nginx web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Set global variables for nginx helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated nginx config
ynh_add_nginx_config
fi
# Change the domain for nginx # Change the domain for nginx
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
@ -83,9 +65,33 @@ fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
#================================================= #=================================================
# ... # UPDATE CONFIG FILE
#================================================= #=================================================
config="$final_path/.env"
ynh_replace_string "APP_URL=.*" "APP_URL=https://$new_domain" "$config"
ynh_replace_string "ADMIN_DOMAIN=.*" "ADMIN_DOMAIN=\"$new_domain\"" "$config"
ynh_replace_string "APP_DOMAIN=.*" "APP_DOMAIN=\"$new_domain\"" "$config"
ynh_replace_string "MAIL_FROM_ADDRESS=.*" "MAIL_FROM_ADDRESS=\"pixelfed@$new_domain\"" "$config"
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config"
#=================================================
# APPLY CHANGES
#=================================================
pushd "$final_path"
php7.2 artisan config:clear
php7.2 artisan config:cache
php7.2 artisan route:clear
php7.2 artisan route:cache
php7.2 artisan horizon:purge
popd
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================

View file

@ -52,10 +52,15 @@ ynh_app_setting_set "$app" is_public "$is_public"
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_print_info "Installing dependencies..."
ynh_install_php --phpversion="7.2"
ynh_install_app_dependencies "$pkg_dependencies" ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# INSTALL PHP
#=================================================
ynh_print_info "Installing php..."
ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies"
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
@ -106,11 +111,6 @@ ynh_print_info "Configuring php-fpm..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config --phpversion="7.2" ynh_add_fpm_config --phpversion="7.2"
#Ugly move waiting 'ynh_add_fpm_config --phpversion='' released
mv "/etc/php/7.0/fpm/pool.d/$app.conf" "/etc/php/7.2/fpm/pool.d/$app.conf"
systemctl reload php7.0-fpm
systemctl reload php7.2-fpm
#================================================= #=================================================
# INSTALL PHP DEPENDENCIES # INSTALL PHP DEPENDENCIES
#================================================= #=================================================

View file

@ -47,11 +47,6 @@ ynh_remove_nginx_config
#================================================= #=================================================
ynh_print_info "Removing php-fpm configuration" ynh_print_info "Removing php-fpm configuration"
#Ugly move waiting 'ynh_add_fpm_config --phpversion='' released
mv "/etc/php/7.2/fpm/pool.d/$app.conf" "/etc/php/7.0/fpm/pool.d/$app.conf"
systemctl reload php7.2-fpm
systemctl reload php7.0-fpm
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -82,6 +77,14 @@ ynh_print_info "Removing the dedicated system user"
# Delete a system user # Delete a system user
ynh_system_user_delete "$app" ynh_system_user_delete "$app"
#=================================================
# START PHP-FPM 7.0 FPM
#=================================================
ynh_print_info "Start php7.0-fpm"
#Sometimes with package_check php7.0-fpm fail to reload and stop. So starting the service, just in case.
systemctl start php7.0-fpm
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -14,10 +14,6 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -72,7 +68,32 @@ ynh_system_user_create "$app"
#================================================= #=================================================
# Restore permissions on app files # Restore permissions on app files
chown -R root: "$final_path" chown -R "$app": "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies..."
ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# INSTALL PHP
#=================================================
ynh_print_info "Installing php..."
ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_print_info "Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_psql_setup_db "$db_name" "$db_name" "$db_pwd"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
@ -80,51 +101,6 @@ chown -R root: "$final_path"
ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf" ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_print_info "Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# RESTORE THE PostgreSQL DATABASE
#=================================================
ynh_print_info "Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_psql_create_db "$db_name" "$db_name" "$db_pwd"
ynh_psql_execute_file_as_root ./db.sql "$db_name"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_print_info "Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app.service"
systemctl enable "$app".service
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add "$app" --log "/var/log/$app/$app.log"
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_restore_file "/etc/cron.d/$app"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_restore_file "/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -101,6 +101,13 @@ ynh_print_info "Upgrading dependencies..."
ynh_install_app_dependencies "$pkg_dependencies" ynh_install_app_dependencies "$pkg_dependencies"
#=================================================
# UPGRADE PHP
#=================================================
ynh_print_info "Upgrading php..."
ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
@ -115,35 +122,38 @@ ynh_system_user_create "$app"
ynh_print_info "Upgrading php-fpm configuration..." ynh_print_info "Upgrading php-fpm configuration..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config ynh_add_fpm_config --phpversion="7.2"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# ... # INSTALL PHP DEPENDENCIES
#================================================= #=================================================
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. chown -R "$app": "$final_path"
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_install_composer --workdir="$final_path"
#=================================================
# DEPLOYMENT
#=================================================
pushd "$final_path"
php7.2 artisan config:clear
php7.2 artisan config:cache
php7.2 artisan route:clear
php7.2 artisan route:cache
php7.2 artisan storage:link
php7.2 artisan migrate --force
php7.2 artisan update
php7.2 artisan horizon:purge
popd
ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$final_path/CONFIG_FILE" ynh_store_file_checksum "$final_path/.env"
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_print_info "Upgrading logrotate configuration..."
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_print_info "Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_add_systemd_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
@ -152,7 +162,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# Set permissions on app files # Set permissions on app files
chown -R root: "$final_path" chown -R "$app": "$final_path"
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT