From cbe4796a5629514a61757def9ae71852c2af30bd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Apr 2019 18:18:37 +0200 Subject: [PATCH 01/35] Update version number --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 7bec3d1c..2dfbb7d8 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.8.4~ynh1", + "version": "0.8.4~ynh2", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": { From 945fc891d768eab246eb516e7263f01f51f95db3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Apr 2019 21:19:20 +0200 Subject: [PATCH 02/35] Fix change_url --- scripts/change_url | 48 ++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 60846630..a9530b5c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,10 +14,10 @@ source /usr/share/yunohost/helpers #================================================= old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +old_path="/" new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH +new_path="/" app=$YNH_APP_INSTANCE_NAME @@ -43,12 +43,6 @@ then change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # 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 -# 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 if [ $change_domain -eq 1 ] then @@ -83,9 +65,33 @@ fi #================================================= # 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 #================================================= From 96c861040c0e2a1cfbcb52b44e5017666452a427 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Apr 2019 21:52:18 +0200 Subject: [PATCH 03/35] Activate additional features --- check_process | 8 ++++---- manifest.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/check_process b/check_process index 45e5c5e6..f753394d 100644 --- a/check_process +++ b/check_process @@ -7,12 +7,12 @@ setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=0 - setup_public=0 + setup_private=1 + setup_public=1 upgrade=1 backup_restore=1 - multi_instance=0 - incorrect_path=0 + multi_instance=1 + incorrect_path=1 port_already_use=0 change_url=0 ;;; Levels diff --git a/manifest.json b/manifest.json index e49f9740..7731889c 100644 --- a/manifest.json +++ b/manifest.json @@ -13,9 +13,9 @@ "email": "jean-baptiste@holcroft.fr" }, "requirements": { - "yunohost": ">= 3.0.0" + "yunohost": ">= 3.4" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], From 85d148fd9a49eea7a5586eb245ff6604f787653d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 00:34:59 +0200 Subject: [PATCH 04/35] update helpers --- scripts/_common.sh | 228 +++++++++++++++++++++++++++------------------ 1 file changed, 139 insertions(+), 89 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8e0bc493..05326162 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -78,67 +78,15 @@ ynh_install_php () { # Store php_version into the config of this app ynh_app_setting_set $app php_version $phpversion - # Install an extra repo to get multiple php versions - ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --name=php - - if [ "$phpversion" == "7.0" ]; then + if [ "$phpversion" == "7.0" ] + then 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 # 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 - echo "Section: misc -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 - ynh_package_install_from_equivs /tmp/php_${phpversion}-ynh-deps.control \ - || ynh_die --message="Unable to install dependencies" - ynh_secure_remove /tmp/php_${phpversion}-ynh-deps.control + ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="php$phpversion php${phpversion}-fpm php${phpversion}-common" # Advertise service in admin panel yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" @@ -158,37 +106,13 @@ ynh_remove_php () { fi # 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 ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" then - # Remove the metapackage for php - ynh_package_autopurge php${phpversion}-ynh-deps - # 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 - + # 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 @@ -196,7 +120,6 @@ ynh_remove_php () { # If no other app uses alternate php versions, remove the extra repo for php if [ ! -s "/etc/php/ynh_app_version" ] then - ynh_remove_extra_repo --name=php ynh_secure_remove /etc/php/ynh_app_version fi } @@ -208,7 +131,7 @@ ynh_remove_php () { #================================================= # 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: -i, --pin - Filter for the pin. # | arg: -p, --priority - Priority for the pin @@ -289,17 +212,19 @@ ynh_add_repo () { # 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: -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=rkna - declare -Ar args_array=( [r]=repo= [k]=key= [n]=name= [a]=append ) + 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 @@ -307,6 +232,7 @@ ynh_install_extra_repo () { name="${name:-$app}" append=${append:-0} key=${key:-0} + priority=${priority:-} if [ $append -eq 1 ] then @@ -337,7 +263,12 @@ ynh_install_extra_repo () { # Build $pin from the uri without http and any sub path local pin="${uri#*://}" 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 if [ -n "$key" ] @@ -377,3 +308,122 @@ ynh_remove_extra_repo () { # 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}" +} From df0d304d275cfb010f96bf222dcf852b352efec7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 00:55:10 +0200 Subject: [PATCH 05/35] fix dearmor --- scripts/_common.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 05326162..f6a9538d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -274,13 +274,7 @@ ynh_install_extra_repo () { if [ -n "$key" ] then mkdir -p "/etc/apt/trusted.gpg.d" - if [[ "$(basename "$key")" =~ ".asc" ]] - 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 + 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 From c1070c3eeff62530a9683f8e90b8edccd8e5d046 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 03:04:01 +0200 Subject: [PATCH 06/35] upgrade helper --- scripts/_common.sh | 14 ++++++++++---- scripts/install | 14 +++++++++++++- scripts/restore | 21 ++++++++++++++++----- scripts/upgrade | 14 +++++++++++++- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f6a9538d..f036f1df 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,12 +5,18 @@ #================================================= # 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 \ -php7.2-intl php7.2-exif \ -libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libwebp6 libmagickwand-6.q16-3 \ -php7.2-gd \ +pkg_dependencies="postgresql redis-server \ +libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libwebp6 libmagickwand-6.q16-3\ pngquant jpegoptim gifsicle" +extra_pkg_dependencies="php7.2-pgsql php7.2-mbstring php7.2-bcmath php7.2-simplexml php7.2-curl php7.2-intl php7.2-exif php7.2-gd" +# +# +# +# +# +# +# #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 4c263969..8849cdab 100644 --- a/scripts/install +++ b/scripts/install @@ -52,9 +52,21 @@ ynh_app_setting_set "$app" is_public "$is_public" #================================================= ynh_print_info "Installing dependencies..." +ynh_install_app_dependencies "$pkg_dependencies" + +#================================================= +# INSTALL PHP +#================================================= +ynh_print_info "Installing php..." + ynh_install_php --phpversion="7.2" -ynh_install_app_dependencies "$pkg_dependencies" +#================================================= +# INSTALL PHP DEPENDENCIES +#================================================= +ynh_print_info "Installing php dependencies..." + +ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="$extra_pkg_dependencies" #================================================= # CREATE A POSTGRESQL DATABASE diff --git a/scripts/restore b/scripts/restore index 549039d4..6b36ebf4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -73,15 +73,26 @@ chown -R "$app": "$final_path" #================================================= # SPECIFIC RESTORATION #================================================= -# REINSTALL DEPENDENCIES +# INSTALL DEPENDENCIES #================================================= -ynh_print_info "Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_php --phpversion="7.2" +ynh_print_info "Installing dependencies..." ynh_install_app_dependencies "$pkg_dependencies" +#================================================= +# INSTALL PHP +#================================================= +ynh_print_info "Installing php..." + +ynh_install_php --phpversion="7.2" + +#================================================= +# INSTALL PHP DEPENDENCIES +#================================================= +ynh_print_info "Installing php dependencies..." + +ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="$extra_pkg_dependencies" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index ba7bb706..e39f6a90 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -99,9 +99,21 @@ ynh_add_nginx_config #================================================= ynh_print_info "Upgrading dependencies..." +ynh_install_app_dependencies "$pkg_dependencies" + +#================================================= +# UPGRADE PHP +#================================================= +ynh_print_info "Upgrading php..." + ynh_install_php --phpversion="7.2" -ynh_install_app_dependencies "$pkg_dependencies" +#================================================= +# UPGRADE PHP DEPENDENCIES +#================================================= +ynh_print_info "Upgrading php dependencies..." + +ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="$extra_pkg_dependencies" #================================================= # CREATE DEDICATED USER From d4f59e6baabe2e624f46a37e7a11af1461111d37 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 04:00:07 +0200 Subject: [PATCH 07/35] Fix dependencies --- scripts/_common.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f036f1df..b1ccd2a6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,17 +6,11 @@ # dependencies used by the app pkg_dependencies="postgresql redis-server \ -libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libwebp6 libmagickwand-6.q16-3\ +libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libmagickwand-6.q16-3 libwebp6 \ pngquant jpegoptim gifsicle" -extra_pkg_dependencies="php7.2-pgsql php7.2-mbstring php7.2-bcmath php7.2-simplexml php7.2-curl php7.2-intl php7.2-exif php7.2-gd" -# -# -# -# -# -# -# +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 #================================================= From 0942da60bf49798a65d7061263e8c98270d2ab3a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 04:01:42 +0200 Subject: [PATCH 08/35] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 7731889c..e1337fe9 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.8.4~ynh3", + "version": "0.8.4~ynh5", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": { From bcb6775b6aea926c6db6ed5658a5a9e60ba79273 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Apr 2019 14:39:52 +0200 Subject: [PATCH 09/35] upgrade ynh_install_php helper --- scripts/_common.sh | 23 ++++++++++++++++------- scripts/install | 9 +-------- scripts/restore | 9 +-------- scripts/upgrade | 9 +-------- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b1ccd2a6..926b5524 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -62,18 +62,20 @@ ynh_install_composer () { || ynh_die "Unable to update core dependencies with Composer." } - # 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: -p, --package - Additionnal php packages to install ynh_install_php () { # Declare an array to define the options of this helper. - local legacy_args=v - declare -Ar args_array=( [v]=phpversion= ) + 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 @@ -86,7 +88,16 @@ ynh_install_php () { # 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" - ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="php$phpversion php${phpversion}-fpm php${phpversion}-common" + # 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" + + # Remove this extra repository after packages are installed + ynh_remove_extra_repo --name=extra_php_version # Advertise service in admin panel yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" @@ -124,8 +135,6 @@ ynh_remove_php () { fi } - - #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 8849cdab..18b18b72 100644 --- a/scripts/install +++ b/scripts/install @@ -59,14 +59,7 @@ ynh_install_app_dependencies "$pkg_dependencies" #================================================= ynh_print_info "Installing php..." -ynh_install_php --phpversion="7.2" - -#================================================= -# INSTALL PHP DEPENDENCIES -#================================================= -ynh_print_info "Installing php dependencies..." - -ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="$extra_pkg_dependencies" +ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" #================================================= # CREATE A POSTGRESQL DATABASE diff --git a/scripts/restore b/scripts/restore index 6b36ebf4..6d5ccc72 100644 --- a/scripts/restore +++ b/scripts/restore @@ -84,14 +84,7 @@ ynh_install_app_dependencies "$pkg_dependencies" #================================================= ynh_print_info "Installing php..." -ynh_install_php --phpversion="7.2" - -#================================================= -# INSTALL PHP DEPENDENCIES -#================================================= -ynh_print_info "Installing php dependencies..." - -ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="$extra_pkg_dependencies" +ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" #================================================= # RESTORE THE POSTGRESQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index e39f6a90..f3561f26 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -106,14 +106,7 @@ ynh_install_app_dependencies "$pkg_dependencies" #================================================= ynh_print_info "Upgrading php..." -ynh_install_php --phpversion="7.2" - -#================================================= -# UPGRADE PHP DEPENDENCIES -#================================================= -ynh_print_info "Upgrading php dependencies..." - -ynh_install_extra_app_dependencies --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --package="$extra_pkg_dependencies" +ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" #================================================= # CREATE DEDICATED USER From cd60251b5df58a90f56a28ef8820ecbb25728ce3 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Thu, 4 Apr 2019 11:53:11 +0200 Subject: [PATCH 10/35] fix path traversal --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 67b55d0a..14cbc899 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__ { +location __PATH__/ { # Path to source alias __FINALPATH__/public/ ; From 18ec744550d697be745901be289f281e7efa7aba Mon Sep 17 00:00:00 2001 From: lapineige Date: Tue, 9 Apr 2019 17:52:54 +0200 Subject: [PATCH 11/35] Add registration config information Some people might want to change the registration to false, for instance after creating their (single user instance) account. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 137a97f5..b71d6e9c 100644 --- a/README.md +++ b/README.md @@ -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?` +### 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 * [Official documentation](https://docs.pixelfed.org/master/) From 0754e9d668446004f40ed2a124df996d38674e5b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 02:10:56 +0200 Subject: [PATCH 12/35] Update to 0.8.6 --- README.md | 2 +- conf/.env | 9 ++++----- conf/app.src | 4 ++-- manifest.json | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 137a97f5..9a01d31b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview 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. Don't hesitate to give a hand if you wish, I assume only the nginx file needs improvments. diff --git a/conf/.env b/conf/.env index ccd91fe0..53d5334f 100644 --- a/conf/.env +++ b/conf/.env @@ -44,11 +44,6 @@ OPEN_REGISTRATION=true RECAPTCHA_ENABLED=false ENFORCE_EMAIL_VERIFICATION=true -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= -PUSHER_APP_CLUSTER=mt1 - MAX_PHOTO_SIZE=15000 MAX_CAPTION_LENGTH=150 MAX_ALBUM_LENGTH=4 @@ -70,3 +65,7 @@ HORIZON_DARKMODE=true # php artisan optimize ACTIVITY_PUB=false REMOTE_FOLLOW=false + +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' \ No newline at end of file diff --git a/conf/app.src b/conf/app.src index 30825423..a62243bc 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/ac53aea28884f0c49c110ac6d87a7b40e92171c9.tar.gz -SOURCE_SUM=ca6156026eb1bb8d8995d247a895b88078e93f1127b75af07058d74f57830846 +SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/v0.8.6.tar.gz +SOURCE_SUM=56acbfe18752693d3312207d6955e65c9f6aa73c7e801a224248b2d4b8e2884f OURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true \ No newline at end of file diff --git a/manifest.json b/manifest.json index 7731889c..99aed292 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.8.4~ynh3", + "version": "0.8.6~ynh1", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": { From d79d1a2c24c68a4e171206e4d1a55d146485a98f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 02:25:33 +0200 Subject: [PATCH 13/35] spacing --- scripts/upgrade | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ba7bb706..8eef5ffa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -156,8 +156,6 @@ pushd "$final_path" php7.2 artisan horizon:purge popd - - ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/.env" From 96d964838ce4c758ba3472673db575ceb525da75 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 02:25:54 +0200 Subject: [PATCH 14/35] activate APP_KEY --- conf/.env | 2 +- scripts/install | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/.env b/conf/.env index ccd91fe0..378734cb 100644 --- a/conf/.env +++ b/conf/.env @@ -1,6 +1,6 @@ APP_NAME=__APP__ APP_ENV=production -APP_KEY= +APP_KEY=__APP_KEY__ APP_DEBUG=true APP_URL=https://__DOMAIN__ diff --git a/scripts/install b/scripts/install index 4c263969..63381d08 100644 --- a/scripts/install +++ b/scripts/install @@ -23,6 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC +app_key=$(ynh_string_random --length=32) app=$YNH_APP_INSTANCE_NAME @@ -44,6 +45,7 @@ ynh_webpath_register "$app" "$domain" "$path_url" ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set "$app" app_key "$app_key" #================================================= # STANDARD MODIFICATIONS @@ -129,6 +131,7 @@ config="$final_path/.env" cp ../conf/.env "$config" ynh_replace_string "__APP__" "$app" "$config" +ynh_replace_string "__APP_KEY__" "$app_key" "$config" ynh_replace_string "__DOMAIN__" "$domain" "$config" ynh_replace_string "__PATH__" "$path_url" "$config" ynh_replace_string "__DB_NAME__" "$db_name" "$config" From 77171f736474205c11bf455a37ef266d144a8d4e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 02:35:33 +0200 Subject: [PATCH 15/35] deactivate DEBUG --- conf/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/.env b/conf/.env index ccd91fe0..966ee9e5 100644 --- a/conf/.env +++ b/conf/.env @@ -1,7 +1,7 @@ APP_NAME=__APP__ APP_ENV=production APP_KEY= -APP_DEBUG=true +APP_DEBUG=false APP_URL=https://__DOMAIN__ ADMIN_DOMAIN="__DOMAIN__" From f2e5a39f3592b6437e087e635553cbfa95b30449 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 11:04:23 +0200 Subject: [PATCH 16/35] Activate federation --- conf/.env | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/.env b/conf/.env index ccd91fe0..bbf8080a 100644 --- a/conf/.env +++ b/conf/.env @@ -68,5 +68,5 @@ HORIZON_DARKMODE=true # php artisan cache:clear # php artisan optimize:clear # php artisan optimize -ACTIVITY_PUB=false -REMOTE_FOLLOW=false +ACTIVITY_PUB=true +REMOTE_FOLLOW=true From 1b21d9cf05e94e0229b212645388390bc070a3d8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 13:40:19 +0200 Subject: [PATCH 17/35] Fix ynh_string_random --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 63381d08..0d789cd6 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -app_key=$(ynh_string_random --length=32) +app_key=$(ynh_string_random 32) app=$YNH_APP_INSTANCE_NAME From 14530f541c1bc9714d4d7e9249c22df39730d96f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 14:23:37 +0200 Subject: [PATCH 18/35] Fix spelling --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 7731889c..bd82f4b9 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": { - "name": "jibec", + "name": "Jean-Baptiste Holcroft", "email": "jean-baptiste@holcroft.fr" }, "requirements": { From f29dc5e884098eb4f50b197ac05e440998dd47ed Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Apr 2019 22:16:15 +0200 Subject: [PATCH 19/35] Remove ugly move needed before yunohost 3.5.2 --- manifest.json | 4 ++-- scripts/install | 5 ----- scripts/remove | 5 ----- scripts/upgrade | 12 ------------ 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/manifest.json b/manifest.json index 7731889c..1f08e492 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.8.4~ynh3", + "version": "0.8.4~ynh4", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": { @@ -13,7 +13,7 @@ "email": "jean-baptiste@holcroft.fr" }, "requirements": { - "yunohost": ">= 3.4" + "yunohost": ">= 3.5" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 4c263969..9ef0f9b0 100644 --- a/scripts/install +++ b/scripts/install @@ -106,11 +106,6 @@ ynh_print_info "Configuring php-fpm..." # Create a dedicated php-fpm config 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 #================================================= diff --git a/scripts/remove b/scripts/remove index f8bd8478..0489390e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -47,11 +47,6 @@ ynh_remove_nginx_config #================================================= 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 ynh_remove_fpm_config diff --git a/scripts/upgrade b/scripts/upgrade index ba7bb706..aa0017bb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -116,21 +116,9 @@ ynh_system_user_create "$app" #================================================= ynh_print_info "Upgrading php-fpm configuration..." -#Ugly move waiting 'ynh_add_fpm_config --phpversion='' released -mv -f "/etc/php/7.2/fpm/pool.d/$app.conf" "/etc/php/7.0/fpm/pool.d/$app.conf" -sleep 5 -systemctl reload php7.2-fpm -systemctl reload php7.0-fpm - # Create a dedicated php-fpm config ynh_add_fpm_config --phpversion="7.2" -#Ugly move waiting 'ynh_add_fpm_config --phpversion='' released -mv -f "/etc/php/7.0/fpm/pool.d/$app.conf" "/etc/php/7.2/fpm/pool.d/$app.conf" -sleep 5 -systemctl reload php7.0-fpm -systemctl reload php7.2-fpm - #================================================= # SPECIFIC UPGRADE #================================================= From f41e3bf3387f02c559acba3cb56d66c772d480e6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 19:57:28 +0200 Subject: [PATCH 20/35] upgrade .env configuration file during upgrade --- scripts/upgrade | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 775e04db..3f5ba5ca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ is_public=$(ynh_app_setting_get "$app" is_public) final_path=$(ynh_app_setting_get "$app" final_path) language=$(ynh_app_setting_get "$app" language) db_name=$(ynh_app_setting_get "$app" db_name) +db_user=$db_name #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -134,6 +135,20 @@ chown -R "$app": "$final_path" ynh_install_composer --workdir="$final_path" +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +config="$final_path/.env" +cp -f ../conf/.env "$config" + +ynh_replace_string "__APP__" "$app" "$config" +ynh_replace_string "__DOMAIN__" "$domain" "$config" +ynh_replace_string "__PATH__" "$path_url" "$config" +ynh_replace_string "__DB_NAME__" "$db_name" "$config" +ynh_replace_string "__DB_USER__" "$db_user" "$config" +ynh_replace_string "__DB_PWD__" "$db_pwd" "$config" + #================================================= # DEPLOYMENT #================================================= @@ -149,11 +164,16 @@ pushd "$final_path" php7.2 artisan horizon:purge popd +#================================================= +# STORE THE CHECKSUM OF THE CONFIG FILE +#================================================= +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$config" -ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" +ynh_backup_if_checksum_is_different "$config" # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "$final_path/.env" +ynh_store_file_checksum "$config" #================================================= # GENERIC FINALIZATION From f73ff8dc528e29035f3f7cb6812f746bd87dce31 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 20:31:13 +0200 Subject: [PATCH 21/35] Adding few automations --- .travis.yml | 7 +++++++ pull_request_template.md | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .travis.yml create mode 100644 pull_request_template.md diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..6133a245 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python + +before_install: + - git clone https://github.com/YunoHost/package_linter /tmp/package_linter + +script: +- /tmp/package_linter/package_linter.py ./ \ No newline at end of file diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 00000000..d7433702 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,23 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Validation +--- +- [ ] **Code review** +- [ ] **Approval (LGTM)** +*Code review and approval have to be from a member of @YunoHost/apps group* +- **CI succeeded** : +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/) +*Please replace '-BRANCH-' in this link by the name of the branch used.* +*If the PR is from a forked repository. Please provide public results from package_check.* +When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 871a1afad2fec7a462df8751f272487e2070da5d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 11 Apr 2019 22:01:12 +0200 Subject: [PATCH 22/35] fix db_pwd missing --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 3f5ba5ca..0f38819e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ final_path=$(ynh_app_setting_get "$app" final_path) language=$(ynh_app_setting_get "$app" language) db_name=$(ynh_app_setting_get "$app" db_name) db_user=$db_name +db_pwd=$(ynh_app_setting_get "$app" db_pwd) #================================================= # ENSURE DOWNWARD COMPATIBILITY From 71beeacef078dcb5b5d2dc9405c9fdb96627bfbb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 03:40:31 +0200 Subject: [PATCH 23/35] fix app_key --- scripts/install | 3 ++- scripts/upgrade | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 50dc8c04..d60e5fa4 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -app_key=$(ynh_string_random 32) +app_key=$(ynh_string_random 32 | base64) +app_key="base64:$app_key" app=$YNH_APP_INSTANCE_NAME diff --git a/scripts/upgrade b/scripts/upgrade index 801530bc..87b3e2f8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ language=$(ynh_app_setting_get "$app" language) db_name=$(ynh_app_setting_get "$app" db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get "$app" db_pwd) +app_key=$(ynh_app_setting_get "$app" app_key) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -52,6 +53,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set "$app" final_path "$final_path" fi +# If app_key doesn't exist, retrieve it +if [ -z "$app_key" ]; then + app_key=$(grep -oP "APP_KEY=\Kbase64.*" "$final_path/.env") + ynh_app_setting_set "$app" app_key "$app_key" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -141,9 +148,10 @@ ynh_install_composer --workdir="$final_path" #================================================= config="$final_path/.env" -cp -f ../conf/.env "$config" +cp ../conf/.env "$config" ynh_replace_string "__APP__" "$app" "$config" +ynh_replace_string "__APP_KEY__" "$app_key" "$config" ynh_replace_string "__DOMAIN__" "$domain" "$config" ynh_replace_string "__PATH__" "$path_url" "$config" ynh_replace_string "__DB_NAME__" "$db_name" "$config" From c37d7903bb9ac0b9c26f31f6c2be87035acaaafb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Apr 2019 12:38:58 +0200 Subject: [PATCH 24/35] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index ef4cd63b..b01bab6b 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.8.6~ynh2", + "version": "0.8.6~ynh3", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": { From db7aea98494ef705fc33959e18a06dae2c6def5c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 15 Apr 2019 21:02:55 +0200 Subject: [PATCH 25/35] move to CI dev --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index d7433702..f850ebe0 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -17,7 +17,7 @@ - [ ] **Approval (LGTM)** *Code review and approval have to be from a member of @YunoHost/apps group* - **CI succeeded** : -[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/) +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/pixelfed_ynh%20-BRANCH-/) *Please replace '-BRANCH-' in this link by the name of the branch used.* *If the PR is from a forked repository. Please provide public results from package_check.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From c4f56db3216493f524da1dda5d4c94e31ba65f4b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Apr 2019 22:47:36 +0200 Subject: [PATCH 26/35] Update _common.sh --- scripts/_common.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 926b5524..c084b21c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -96,6 +96,9 @@ ynh_install_php () { 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 + # Remove this extra repository after packages are installed ynh_remove_extra_repo --name=extra_php_version From 5dee139197f49202c197fc519f765a65c30dfc2a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 18 Apr 2019 12:03:56 +0200 Subject: [PATCH 27/35] update to v0.9.0 --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 17bc4fa1..b5264f78 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview The federated image sharing service Pixelfed, for YunoHost -**Shipped version:** 0.8.6 +**Shipped version:** 0.9.0 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. diff --git a/conf/app.src b/conf/app.src index a62243bc..d492ccde 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/v0.8.6.tar.gz -SOURCE_SUM=56acbfe18752693d3312207d6955e65c9f6aa73c7e801a224248b2d4b8e2884f +SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/v0.9.0.tar.gz +SOURCE_SUM=ea69f3441991c9122638b1476ba11ec1b7847fac569fa77a8ed7b03481b19d88 OURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true \ No newline at end of file diff --git a/manifest.json b/manifest.json index ef4cd63b..bcf4123e 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "ActivityPub Federated Image Sharing" }, - "version": "0.8.6~ynh2", + "version": "0.9.0~ynh1", "url": "https://pixelfed.org/", "license": "AGPL-3.0-or-later", "maintainer": { From 6f57b3db7c7fbaa5653523bcbd8796a4e71c6a85 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 23 Apr 2019 15:17:50 +0200 Subject: [PATCH 28/35] Define phpversion for composer to fix error: Your requirements could not be resolved to an installable set of packages --- scripts/_common.sh | 21 ++++++++++++--------- scripts/install | 6 +++++- scripts/upgrade | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c084b21c..7263215e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -21,13 +21,14 @@ extra_pkg_dependencies="php7.2-bcmath php7.2-cli php7.2-curl php7.2-exif php7.2- # Execute a command with Composer # -# usage: ynh_composer_exec [--workdir=$final_path] --commands="commands" +# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" # | 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=wc - declare -Ar args_array=( [w]=workdir= [c]=commands= ) + local legacy_args=vwc + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= ) + local phpversion local workdir local commands # Manage arguments with getopts @@ -35,18 +36,19 @@ ynh_composer_exec () { workdir="${workdir:-$final_path}" COMPOSER_HOME="$workdir/.composer" \ - php "$workdir/composer.phar" $commands \ + php${phpversion} "$workdir/composer.phar" $commands \ -d "$workdir" --quiet --no-interaction } # Install and initialize Composer in the given directory # -# usage: ynh_install_composer [--workdir=$final_path] +# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. ynh_install_composer () { # Declare an array to define the options of this helper. - local legacy_args=w - declare -Ar args_array=( [w]=workdir= ) + local legacy_args=vw + declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local phpversion local workdir # Manage arguments with getopts ynh_handle_getopts_args "$@" @@ -54,14 +56,15 @@ ynh_install_composer () { curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ - php -- --quiet --install-dir="$workdir" \ + php${phpversion} -- --quiet --install-dir="$workdir" \ || ynh_die "Unable to install Composer." # update dependencies to create composer.lock - ynh_composer_exec --workdir="$workdir" --commands="install --no-dev" \ + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ || ynh_die "Unable to update core dependencies with Composer." } + # Install another version of php. # # usage: ynh_install_php --phpversion=phpversion [--package=packages] diff --git a/scripts/install b/scripts/install index 10818d58..c30abeba 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,10 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + read -p "key" +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -117,7 +121,7 @@ ynh_add_fpm_config --phpversion="7.2" chown -R "$app": "$final_path" -ynh_install_composer --workdir="$final_path" +ynh_install_composer --phpversion="7.2" --workdir="$final_path" #================================================= # SPECIFIC SETUP diff --git a/scripts/upgrade b/scripts/upgrade index 775e04db..ae91acb7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,7 +132,7 @@ ynh_add_fpm_config --phpversion="7.2" chown -R "$app": "$final_path" -ynh_install_composer --workdir="$final_path" +ynh_install_composer --phpversion="7.2" --workdir="$final_path" #================================================= # DEPLOYMENT From 158c19ac6f566671e7e0581b92c816417e710d5d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Apr 2019 00:20:56 +0200 Subject: [PATCH 29/35] remove read -p --- scripts/install | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/install b/scripts/install index c30abeba..511df465 100644 --- a/scripts/install +++ b/scripts/install @@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - read -p "key" -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors From 1c2b08f14d75fc43ece067106ec7cd1e2e9b56d7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Apr 2019 00:42:15 +0200 Subject: [PATCH 30/35] fix user admin for php7.2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17bc4fa1..7b5f5358 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ After being first registered, you need to execute the folloing command to promot **Run:** - $ (cd /var/www/pixelfed && php artisan user:admin 1) + $ (cd /var/www/pixelfed && php7.2 artisan user:admin 1) and respond yes to the question ` Add admin privileges to this user?` From f1b70e3a42d8a131f3ca4b6faa750ab7eb66a426 Mon Sep 17 00:00:00 2001 From: lapineige Date: Thu, 16 May 2019 20:24:48 +0200 Subject: [PATCH 31/35] Update readme to current package status --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 137a97f5..a9952506 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview The federated image sharing service Pixelfed, for YunoHost -**Shipped version:** 0.8.4 +**Shipped version:** 0.9.0 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. @@ -19,12 +19,10 @@ Don't hesitate to give a hand if you wish, I assume only the nginx file needs im * works fine: * [x] basic install/remove process + * [x] backup/restore * to be confirmed - * [ ] - -* to be added: - * [ ] everything + * [ ] fail2ban support ## Screenshots From 1f1a2e6c070f6a37fea587c069651f6edff90f0c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 17 May 2019 01:02:03 +0200 Subject: [PATCH 32/35] Apply example_ynh --- README.md | 21 ++------ scripts/_common.sh | 6 +-- scripts/backup | 26 +++++----- scripts/change_url | 37 +++++++------- scripts/install | 66 ++++++++++++------------- scripts/remove | 77 ++++++++++++++--------------- scripts/restore | 66 +++++++++++++------------ scripts/upgrade | 119 +++++++++++++++++++-------------------------- 8 files changed, 194 insertions(+), 224 deletions(-) diff --git a/README.md b/README.md index a2db2750..a8940e9e 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,6 @@ The federated image sharing service Pixelfed, for YunoHost **Shipped version:** 0.9.0 -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. - -# State of this package - -* works fine: - - * [x] basic install/remove process - * [x] backup/restore - -* to be confirmed - * [ ] fail2ban support - ## Screenshots ![](https://camo.githubusercontent.com/c1c2e74057dcff57e103fcbb3239840802fcf752/68747470733a2f2f706978656c6665642e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f6d656469612f53637265656e25323053686f74253230323031392d30322d30352532306174253230362e33342e3539253230504d2e706e67) @@ -53,15 +40,15 @@ To change that setting, edit `/var/www/pixelfed/.env` and set `OPEN_REGISTRATION #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pixelfed%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/pixelfed/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pixelfed%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pixelfed/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/pixelfed%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/pixelfed/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/pixelfed/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/pixelfed/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/pixelfed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/pixelfed/) ## Links * Report a bug about this package: https://github.com/YunoHost-Apps/pixelfed_ynh * Pixelfed website: https://pixelfed.org - * Pixelfed github website: https://github.com/pixelfed/pixelfed + * Upstream app repository: https://github.com/pixelfed/pixelfed * YunoHost website: https://yunohost.org --- diff --git a/scripts/_common.sh b/scripts/_common.sh index 7263215e..23da61d9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -57,11 +57,11 @@ ynh_install_composer () { curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ php${phpversion} -- --quiet --install-dir="$workdir" \ - || ynh_die "Unable to install Composer." + || ynh_die --message="Unable to install Composer." # update dependencies to create composer.lock ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ - || ynh_die "Unable to update core dependencies with Composer." + || ynh_die --message="Unable to update core dependencies with Composer." } @@ -85,7 +85,7 @@ ynh_install_php () { if [ "$phpversion" == "7.0" ] then - ynh_die "Do not use ynh_install_php to install php7.0" + ynh_die --message="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 diff --git a/scripts/backup b/scripts/backup index cdaf227c..3d76e413 100644 --- a/scripts/backup +++ b/scripts/backup @@ -20,46 +20,46 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get "$app" final_path) -domain=$(ynh_app_setting_get "$app" domain) -db_name=$(ynh_app_setting_get "$app" db_name) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +domain=$(ynh_app_setting_get --app="$app" --key=domain) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_print_info --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backing up nginx web server configuration..." +ynh_print_info --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Backing up php-fpm configuration..." +ynh_print_info --message="Backing up php-fpm configuration..." -ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.2/fpm/pool.d/$app.conf" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info "Backing up the PostgreSQL database..." +ynh_print_info --message="Backing up the PostgreSQL database..." -ynh_psql_dump_db "$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index a9530b5c..1ce94241 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,14 +24,14 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get "$app" final_path) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) # Add settings here as needed by your application -#db_name=$(ynh_app_setting_get "$app" db_name) -#db_pwd=$(ynh_app_setting_get $app db_pwd) +#db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +#db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -48,7 +48,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_print_info --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -56,10 +56,10 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + ynh_delete_file_checksum --file="$nginx_conf_path" mv "$nginx_conf_path" "/etc/nginx/conf.d/$new_domain.d/$app.conf" # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -69,17 +69,19 @@ fi #================================================= 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" +ynh_replace_string --match_string="APP_URL=.*" --replace_string="APP_URL=https://$new_domain" --target_file="$config" +ynh_replace_string --match_string="ADMIN_DOMAIN=.*" --replace_string="ADMIN_DOMAIN=\"$new_domain\"" --target_file="$config" +ynh_replace_string --match_string="APP_DOMAIN=.*" --replace_string="APP_DOMAIN=\"$new_domain\"" --target_file="$config" +ynh_replace_string --match_string="MAIL_FROM_ADDRESS=.*" --replace_string="MAIL_FROM_ADDRESS=\"pixelfed@$new_domain\"" --target_file="$config" #================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE +# STORE THE CONFIG FILE CHECKSUM #================================================= -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$config" +ynh_backup_if_checksum_is_different --file="$config" + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$config" #================================================= # APPLY CHANGES @@ -92,17 +94,18 @@ pushd "$final_path" php7.2 artisan route:cache php7.2 artisan horizon:purge popd + #================================================= # GENERIC FINALISATION #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_print_info --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index a0ded1de..01a955c8 100644 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC -app_key=$(ynh_string_random 32 | base64) +app_key=$(ynh_string_random --length=32 | base64) app_key="base64:$app_key" app=$YNH_APP_INSTANCE_NAME @@ -31,69 +31,67 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_print_info --message="Validating installation parameters..." final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register "$app" "$domain" "$path_url" +ynh_webpath_register --app="$app" --domain="$domain" --path_url="$path_url" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_app_setting_set "$app" domain "$domain" -ynh_app_setting_set "$app" path "$path_url" -ynh_app_setting_set "$app" is_public "$is_public" -ynh_app_setting_set "$app" app_key "$app_key" +ynh_app_setting_set --app="$app" --key=domain --value="$domain" +ynh_app_setting_set --app="$app" --key=path --value="$path_url" +ynh_app_setting_set --app="$app" --key=is_public --value="$is_public" +ynh_app_setting_set --app="$app" --key=app_key --value="$app_key" #================================================= # STANDARD MODIFICATIONS #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies..." +ynh_print_info --message="Installing dependencies..." ynh_install_app_dependencies "$pkg_dependencies" #================================================= # INSTALL PHP #================================================= -ynh_print_info "Installing php..." +ynh_print_info --message="Installing php..." ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_print_info "Creating a PostgreSQL database..." +ynh_print_info --message="Creating a PostgreSQL database..." ynh_psql_test_if_first_run db_name=$(ynh_sanitize_dbid "$app") db_user=$db_name db_pwd=$(ynh_string_random) -ynh_app_setting_set "$app" db_name "$db_name" -ynh_app_setting_set "$app" db_pwd "$db_pwd" +ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" +ynh_app_setting_set --app="$app" --key=db_pwd --value="$db_pwd" # Initialize database and store postgres password for upgrade -ynh_psql_setup_db "$db_user" "$db_name" "$db_pwd" - -systemctl reload postgresql +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_app_setting_set "$app" final_path "$final_path" +ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx web server..." +ynh_print_info --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -101,7 +99,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Configuring system user..." +ynh_print_info --message="Configuring system user..." # Create a system user ynh_system_user_create "$app" @@ -109,7 +107,7 @@ ynh_system_user_create "$app" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Configuring php-fpm..." +ynh_print_info --message="Configuring php-fpm..." # Create a dedicated php-fpm config ynh_add_fpm_config --phpversion="7.2" @@ -131,20 +129,20 @@ ynh_install_composer --phpversion="7.2" --workdir="$final_path" config="$final_path/.env" cp ../conf/.env "$config" -ynh_replace_string "__APP__" "$app" "$config" -ynh_replace_string "__APP_KEY__" "$app_key" "$config" -ynh_replace_string "__DOMAIN__" "$domain" "$config" -ynh_replace_string "__PATH__" "$path_url" "$config" -ynh_replace_string "__DB_NAME__" "$db_name" "$config" -ynh_replace_string "__DB_USER__" "$db_user" "$config" -ynh_replace_string "__DB_PWD__" "$db_pwd" "$config" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config" +ynh_replace_string --match_string="__APP_KEY__" --replace_string="$app_key" --target_file="$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE #================================================= # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$config" +ynh_store_file_checksum --file="$config" #================================================= # DEPLOYMENT @@ -174,24 +172,24 @@ chown -R "$app": "$final_path/storage/" #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_print_info --message="Configuring SSOwat..." # Make app public if necessary if [ "$is_public" -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" + ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Installation of $app completed" +ynh_print_info --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 0489390e..18dd058a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,48 +12,29 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -db_name=$(ynh_app_setting_get "$app" db_name) +domain=$(ynh_app_setting_get --app="$app" --key=domain) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_user=$db_name -final_path=$(ynh_app_setting_get "$app" final_path) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) #================================================= # STANDARD REMOVE #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_print_info "Removing the PostgreSQL database" +ynh_print_info --message="Removing the PostgreSQL database..." -ynh_psql_execute_as_root "\connect $db_name -SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" - -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db "$db_user" "$db_name" - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_print_info "Removing nginx web server configuration" - -# Remove the dedicated nginx config -ynh_remove_nginx_config - -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_print_info "Removing php-fpm configuration" - -# Remove the dedicated php-fpm config -ynh_remove_fpm_config + Remove a database if it exists, along with the associated user +ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info "Removing dependencies" +ynh_print_info --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -62,31 +43,47 @@ ynh_remove_php #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_print_info --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_print_info --message="Removing nginx web server configuration..." + +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# REMOVE PHP-FPM CONFIGURATION +#================================================= +ynh_print_info --message="Removing php-fpm configuration..." + +# Remove the dedicated php-fpm config +ynh_remove_fpm_config + +#================================================= +# RESTART PHP-FPM 7.0 FPM +#================================================= +ynh_print_info --message="Start php7.0-fpm..." + +#Sometimes with package_check php7.0-fpm fail to reload and stop. So starting the service, just in case. +ynh_systemd_action --service_name=php7.0-fpm --action=start #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user" +ynh_print_info --message="Removing the dedicated system user..." # Delete a system user -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 +ynh_system_user_delete --username="$app" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_print_info --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 6a44c838..0d574055 100644 --- a/scripts/restore +++ b/scripts/restore @@ -20,25 +20,26 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_print_info --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path) -final_path=$(ynh_app_setting_get "$app" final_path) -db_name=$(ynh_app_setting_get "$app" db_name) -db_pwd=$(ynh_app_setting_get "$app" db_pwd) +domain=$(ynh_app_setting_get --app="$app" --key=domain) +path_url=$(ynh_app_setting_get --app="$app" --key=path) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) +db_user=$db_name +db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_print_info --message="Validating restoration parameters..." -ynh_webpath_available "$domain" "$path_url" \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain="$domain" --path_url="$path_url" \ + || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d "$final_path" \ - || ynh_die "There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -46,22 +47,22 @@ test ! -d "$final_path" \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restoring the app main directory..." +ynh_print_info --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreating the dedicated system user..." +ynh_print_info --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create "$app" +ynh_system_user_create --username="$app" #================================================= # RESTORE USER RIGHTS @@ -73,46 +74,47 @@ chown -R "$app": "$final_path" #================================================= # SPECIFIC RESTORATION #================================================= -# INSTALL DEPENDENCIES +# REINSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies..." +ynh_print_info --message="Reinstalling dependencies..." +# Define and install dependencies ynh_install_app_dependencies "$pkg_dependencies" #================================================= # INSTALL PHP #================================================= -ynh_print_info "Installing php..." +ynh_print_info --message="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 #================================================= -ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" + +#================================================= +# RESTORE THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Restoring the PostgreSQL database..." + +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user"$db_user" --db_name="$db_name" --db_pwd="$db_pwd" +ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_print_info "Reloading nginx web server and php-fpm..." +ynh_print_info --message="Reloading nginx web server and php-fpm..." -systemctl reload php7.2-fpm -systemctl reload nginx +ynh_systemd_action --service_name=php7.2-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_print_info --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index f048c099..babf65d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,57 +12,63 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path) -admin=$(ynh_app_setting_get "$app" admin) -is_public=$(ynh_app_setting_get "$app" is_public) -final_path=$(ynh_app_setting_get "$app" final_path) -language=$(ynh_app_setting_get "$app" language) -db_name=$(ynh_app_setting_get "$app" db_name) +domain=$(ynh_app_setting_get --app="$app" --key=domain) +path_url=$(ynh_app_setting_get --app="$app" --key=path) +admin=$(ynh_app_setting_get --app="$app" --key=admin) +is_public=$(ynh_app_setting_get --app="$app" --key=is_public) +final_path=$(ynh_app_setting_get --app="$app" --key=final_path) +language=$(ynh_app_setting_get --app="$app" --key=language) +db_name=$(ynh_app_setting_get --app="$app" --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get "$app" db_pwd) -app_key=$(ynh_app_setting_get "$app" app_key) +db_pwd=$(ynh_app_setting_get --app="$app" --key=db_pwd) +app_key=$(ynh_app_setting_get --app="$app" --key=app_key) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_print_info --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set "$app" is_public 1 + ynh_app_setting_set --app="$app" --key=is_public --value=1 is_public=1 elif [ "$is_public" = "No" ]; then - ynh_app_setting_set "$app" is_public 0 + ynh_app_setting_set --app="$app" --key=is_public --value=0 is_public=0 fi # If db_name doesn't exist, create it if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid "$app") - ynh_app_setting_set "$app" db_name "$db_name" + db_name=$(ynh_sanitize_dbid --db_name="$app") + ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" fi # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app - ynh_app_setting_set "$app" final_path "$final_path" + ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" fi # If app_key doesn't exist, retrieve it if [ -z "$app_key" ]; then app_key=$(grep -oP "APP_KEY=\Kbase64.*" "$final_path/.env") - ynh_app_setting_set "$app" app_key "$app_key" + ynh_app_setting_set --app="$app" --key=app_key --value="$app_key" fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." +ynh_print_info --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -73,32 +79,24 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -# N.B. : this is for app installations before YunoHost 2.7 -# where this value might be something like /foo/ or foo/ -# instead of /foo .... -# If nobody installed your app before 2.7, then you may -# safely remove this line -path_url=$(ynh_normalize_url_path "$path_url") - #================================================= # STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_print_info --message="Upgrading source files..." + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -106,21 +104,21 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info "Upgrading dependencies..." +ynh_print_info --message="Upgrading dependencies..." ynh_install_app_dependencies "$pkg_dependencies" #================================================= # UPGRADE PHP #================================================= -ynh_print_info "Upgrading php..." +ynh_print_info --message="Upgrading php..." ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create "$app" @@ -128,7 +126,7 @@ ynh_system_user_create "$app" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Upgrading php-fpm configuration..." +ynh_print_info --message="Upgrading php-fpm configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config --phpversion="7.2" @@ -150,28 +148,13 @@ ynh_install_composer --phpversion="7.2" --workdir="$final_path" config="$final_path/.env" cp ../conf/.env "$config" -ynh_replace_string "__APP__" "$app" "$config" -ynh_replace_string "__APP_KEY__" "$app_key" "$config" -ynh_replace_string "__DOMAIN__" "$domain" "$config" -ynh_replace_string "__PATH__" "$path_url" "$config" -ynh_replace_string "__DB_NAME__" "$db_name" "$config" -ynh_replace_string "__DB_USER__" "$db_user" "$config" -ynh_replace_string "__DB_PWD__" "$db_pwd" "$config" - -#================================================= -# MODIFY A CONFIG FILE -#================================================= - -config="$final_path/.env" -cp ../conf/.env "$config" - -ynh_replace_string "__APP__" "$app" "$config" -ynh_replace_string "__APP_KEY__" "$app_key" "$config" -ynh_replace_string "__DOMAIN__" "$domain" "$config" -ynh_replace_string "__PATH__" "$path_url" "$config" -ynh_replace_string "__DB_NAME__" "$db_name" "$config" -ynh_replace_string "__DB_USER__" "$db_user" "$config" -ynh_replace_string "__DB_PWD__" "$db_pwd" "$config" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config" +ynh_replace_string --match_string="__APP_KEY__" --replace_string="$app_key" --target_file="$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" #================================================= # DEPLOYMENT @@ -189,13 +172,13 @@ pushd "$final_path" popd #================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE +# STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_backup_if_checksum_is_different "$config" +ynh_backup_if_checksum_is_different --file="$config" # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "$config" +ynh_store_file_checksum --file="$config" #================================================= # GENERIC FINALIZATION @@ -209,24 +192,24 @@ chown -R "$app": "$final_path" #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_print_info --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set "$app" unprotected_uris "/" + ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Upgrade of $app completed" +ynh_print_info --message="Upgrade of $app completed" From f86c3fce5c53c583fc91947cc9ff6a110bd170be Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 17 May 2019 14:44:40 +0200 Subject: [PATCH 33/35] typo --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1ce94241..6e2df58b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -53,7 +53,7 @@ ynh_print_info --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the domain for nginx -if [ $change_domain -eq 1 ] +if [ "$change_domain" -eq 1 ] then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" diff --git a/scripts/install b/scripts/install index 01a955c8..1bd26616 100644 --- a/scripts/install +++ b/scripts/install @@ -102,7 +102,7 @@ ynh_add_nginx_config ynh_print_info --message="Configuring system user..." # Create a system user -ynh_system_user_create "$app" +ynh_system_user_create --username="$app" #================================================= # PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index babf65d8..c8c33017 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -121,7 +121,7 @@ ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create "$app" +ynh_system_user_create --username="$app" #================================================= # PHP-FPM CONFIGURATION @@ -195,7 +195,7 @@ chown -R "$app": "$final_path" ynh_print_info --message="Upgrading SSOwat configuration..." # Make app public if necessary -if [ $is_public -eq 1 ] +if [ "$is_public" -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway ynh_app_setting_set --app="$app" --key=unprotected_uris --value="/" From f5f40552249e32d2e0714308152836860bd50196 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 18 May 2019 05:17:12 +0200 Subject: [PATCH 34/35] reorder php install step --- scripts/restore | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/restore b/scripts/restore index 0d574055..db9c6b6f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,16 +71,6 @@ ynh_system_user_create --username="$app" # Restore permissions on app files chown -R "$app": "$final_path" -#================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_print_info --message="Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies "$pkg_dependencies" - #================================================= # INSTALL PHP #================================================= @@ -94,6 +84,16 @@ ynh_install_php --phpversion="7.2" --package="$extra_pkg_dependencies" ynh_restore_file --origin_path="/etc/php/7.2/fpm/pool.d/$app.conf" +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info --message="Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies "$pkg_dependencies" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= From 5eea1790ddef99a8c8be2798451c3381d264f416 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 18 May 2019 19:35:55 +0200 Subject: [PATCH 35/35] fix restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index db9c6b6f..d6d993c2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -100,7 +100,7 @@ ynh_install_app_dependencies "$pkg_dependencies" ynh_print_info --message="Restoring the PostgreSQL database..." ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user"$db_user" --db_name="$db_name" --db_pwd="$db_pwd" +ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" --db_pwd="$db_pwd" ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #=================================================