1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/decidim_ynh.git synced 2024-09-03 18:26:00 +02:00

Upgrade to 0.26.2

This commit is contained in:
yalh76 2022-09-02 01:04:03 +02:00
parent e8f8bddb55
commit 871f351d6f
10 changed files with 154 additions and 122 deletions

View file

@ -9,9 +9,6 @@
# Since each app is different, maintainers can adapt its contents so as to perform # Since each app is different, maintainers can adapt its contents so as to perform
# automatic actions when a new upstream release is detected. # automatic actions when a new upstream release is detected.
# Remove this exit command when you are ready to run this Action
exit 1
#================================================= #=================================================
# FETCHING LATEST RELEASE AND ITS ASSETS # FETCHING LATEST RELEASE AND ITS ASSETS
#================================================= #=================================================
@ -21,7 +18,7 @@ current_version=$(cat manifest.json | jq -j '.version|split("~")[0]')
repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]')
# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) # Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions)
version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1)
assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) assets="https://github.com/decidim/decidim/archive/refs/tags/$version.tar.gz"
# Later down the script, we assume the version has only digits and dots # Later down the script, we assume the version has only digits and dots
# Sometimes the release name starts with a "v", so let's filter it out. # Sometimes the release name starts with a "v", so let's filter it out.
@ -48,38 +45,16 @@ elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.
exit 0 exit 0
fi fi
# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.)
echo "${#assets[@]} available asset(s)"
#================================================= #=================================================
# UPDATE SOURCE FILES # UPDATE SOURCE FILES
#================================================= #=================================================
# Here we use the $assets variable to get the resources published in the upstream release. # Let's download source tarball
# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. asset_url=$assets
# Let's loop over the array of assets URLs
for asset_url in ${assets[@]}; do
echo "Handling asset at $asset_url" echo "Handling asset at $asset_url"
# Assign the asset to a source file in conf/ directory
# Here we base the source file name upon a unique keyword in the assets url (admin vs. update)
# Leave $src empty to ignore the asset
case $asset_url in
*"admin"*)
src="app" src="app"
;;
*"update"*)
src="app-upgrade"
;;
*)
src=""
;;
esac
# If $src is not empty, let's process the asset
if [ ! -z "$src" ]; then
# Create the temporary directory # Create the temporary directory
tempdir="$(mktemp -d)" tempdir="$(mktemp -d)"
@ -107,15 +82,10 @@ SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=$extension SOURCE_FORMAT=$extension
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true
SOURCE_FILENAME= SOURCE_FILENAME=
SOURCE_EXTRACT=true
EOT EOT
echo "... conf/$src.src updated" echo "... conf/$src.src updated"
else
echo "... asset ignored"
fi
done
#================================================= #=================================================
# SPECIFIC UPDATE STEPS # SPECIFIC UPDATE STEPS
#================================================= #=================================================

49
.github/workflows/updater.yml vendored Normal file
View file

@ -0,0 +1,49 @@
# This workflow allows GitHub Actions to automagically update your app whenever a new upstream release is detected.
# You need to enable Actions in your repository settings, and fetch this Action from the YunoHost-Apps organization.
# This file should be enough by itself, but feel free to tune it to your needs.
# It calls updater.sh, which is where you should put the app-specific update steps.
name: Check for new upstream releases
on:
# Allow to manually trigger the workflow
workflow_dispatch:
# Run it every day at 6:00 UTC
schedule:
- cron: '0 6 * * *'
jobs:
updater:
runs-on: ubuntu-latest
steps:
- name: Fetch the source code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the updater script
id: run_updater
run: |
# Setting up Git user
git config --global user.name 'yunohost-bot'
git config --global user.email 'yunohost-bot@users.noreply.github.com'
# Run the updater script
/bin/bash .github/workflows/updater.sh
- name: Commit changes
id: commit
if: ${{ env.PROCEED == 'true' }}
run: |
git commit -am "Upgrade to v$VERSION"
- name: Create Pull Request
id: cpr
if: ${{ env.PROCEED == 'true' }}
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update to version ${{ env.VERSION }}
committer: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
author: 'yunohost-bot <yunohost-bot@users.noreply.github.com>'
signoff: false
base: testing
branch: ci-auto-update-v${{ env.VERSION }}
delete-branch: true
title: 'Upgrade to version ${{ env.VERSION }}'
body: |
Upgrade to v${{ env.VERSION }}
draft: false

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/decidim/decidim/archive/refs/tags/v0.26.1.tar.gz SOURCE_URL=https://github.com/decidim/decidim/archive/refs/tags/v0.26.2.tar.gz
SOURCE_SUM=2a646685aa29a96b903bc82a21abe95745ff79d86f650aa5a28e2458de25b8d2 SOURCE_SUM=1dcc49b95543604302bc65df4d2119f90dcb10ad7cc68c4f3e7cc6ffc64eabc5
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -2,7 +2,7 @@
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/live/public ; alias __FINALPATH__/live/public/;
client_max_body_size 32M; client_max_body_size 32M;

View file

@ -5,7 +5,7 @@
"description": { "description": {
"en": "Participatory democracy framework," "en": "Participatory democracy framework,"
}, },
"version": "0.26.1~ynh3", "version": "0.26.2~ynh1",
"url": "https://decidim.org/", "url": "https://decidim.org/",
"upstream": { "upstream": {
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
@ -44,7 +44,22 @@
"en": "Choose the application language", "en": "Choose the application language",
"fr": "Choisissez la langue de l'application" "fr": "Choisissez la langue de l'application"
}, },
"choices": ["ca", "cs", "de", "en", "es", "eu", "fi", "fr", "it", "ja", "nl", "pl", "pt", "ro"], "choices": [
"ca",
"cs",
"de",
"en",
"es",
"eu",
"fi",
"fr",
"it",
"ja",
"nl",
"pl",
"pt",
"ro"
],
"default": "en" "default": "en"
}, },
{ {

View file

@ -4,16 +4,15 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app ruby_version=2.7.4
nodejs_version=16
bundler_version=2.2.19
rails_version=6.0.4
# dependencies used by the app (must be on a single line)
pkg_dependencies="postgresql imagemagick redis-server" pkg_dependencies="postgresql imagemagick redis-server"
build_pkg_dependencies="libyaml-dev libreadline6-dev libncurses5-dev libffi-dev libgdbm-dev libpq-dev libicu-dev" build_pkg_dependencies="libyaml-dev libreadline6-dev libncurses5-dev libffi-dev libgdbm-dev libpq-dev libicu-dev"
ruby_version="2.7.4"
nodejs_version="16"
decidim_version="0.26.1"
bundler_version="2.2.19"
rails_version="6.0.4"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -39,7 +39,7 @@ admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -50,7 +50,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain 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=path --value=$path_url
@ -63,7 +63,7 @@ ynh_app_setting_set --app=$app --key=secret_key_base --value=$secret_key_base
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
@ -75,7 +75,7 @@ ynh_install_ruby --ruby_version=$ruby_version
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -83,7 +83,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
db_name=$(ynh_sanitize_dbid --db_name=$app) db_name=$(ynh_sanitize_dbid --db_name=$app)
@ -99,7 +99,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$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 # Download, check integrity, uncompress and patch the source from app.src
@ -112,7 +112,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
@ -122,14 +122,14 @@ ynh_add_nginx_config
#================================================= #=================================================
# INSTALL GEMS # INSTALL GEMS
#================================================= #=================================================
ynh_script_progression --message="Installing gems..." ynh_script_progression --message="Installing gems..." --weight=1
pushd $final_path pushd $final_path
ynh_use_ruby ynh_use_ruby
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less $ynh_gem install bundler --version $bundler_version ynh_exec_warn_less $ynh_gem install bundler --version $bundler_version
ynh_exec_warn_less $ynh_gem install rails --version $rails_version ynh_exec_warn_less $ynh_gem install rails --version $rails_version
ynh_exec_warn_less $ynh_gem install decidim -v $decidim_version ynh_exec_warn_less $ynh_gem install decidim -v $(ynh_app_upstream_version)
ynh_exec_warn_less decidim live ynh_exec_warn_less decidim live
popd popd
@ -140,7 +140,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# CREATE DATA DIRECTORY # CREATE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Creating a data directory..." ynh_script_progression --message="Creating a data directory..." --weight=1
datadir=/home/yunohost.app/$app datadir=/home/yunohost.app/$app
ynh_app_setting_set --app=$app --key=datadir --value=$datadir ynh_app_setting_set --app=$app --key=datadir --value=$datadir
@ -154,7 +154,7 @@ chown -R $app:www-data "$datadir"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/schedule.rb" --destination="$final_path/live/config/schedule.rb" ynh_add_config --template="../conf/schedule.rb" --destination="$final_path/live/config/schedule.rb"
chmod 400 "$final_path/live/config/schedule.rb" chmod 400 "$final_path/live/config/schedule.rb"
@ -180,7 +180,7 @@ chmod 644 "/etc/cron.d/$app"
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..." --weight=1
pushd "$final_path/live" pushd "$final_path/live"
ynh_secure_remove --file="$final_path/live/Gemfile.lock" ynh_secure_remove --file="$final_path/live/Gemfile.lock"
@ -212,7 +212,7 @@ ynh_package_autoremove
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
@ -225,7 +225,7 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -233,4 +233,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" ynh_script_progression --message="Installation of $app completed" --last

View file

@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -28,7 +28,7 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
@ -36,7 +36,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -48,14 +48,14 @@ ynh_secure_remove --file="$final_path"
# Remove the data directory if --purge option is used # Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then then
ynh_script_progression --message="Removing app data directory..." ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir" ynh_secure_remove --file="$datadir"
fi fi
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -63,7 +63,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_nodejs ynh_remove_nodejs
@ -75,7 +75,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file # Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
@ -85,7 +85,7 @@ ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
@ -94,4 +94,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" ynh_script_progression --message="Removal of $app completed" --last

View file

@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting true
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
@ -24,7 +24,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -38,24 +38,17 @@ datadir=$(ynh_app_setting_get --app=$app --key=datadir)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -63,7 +56,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -74,7 +67,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# RESTORE THE DATA DIRECTORY # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the data directory..." ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$datadir" --not_mandatory ynh_restore_file --origin_path="$datadir" --not_mandatory
@ -89,7 +82,7 @@ chown -R $app:www-data "$datadir"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
@ -99,10 +92,17 @@ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2
ynh_install_extra_app_dependencies --repo="deb https://oss-binaries.phusionpassenger.com/apt/passenger $(lsb_release -cs) main" --package="libnginx-mod-http-passenger" ynh_install_extra_app_dependencies --repo="deb https://oss-binaries.phusionpassenger.com/apt/passenger $(lsb_release -cs) main" --package="libnginx-mod-http-passenger"
ynh_install_ruby --ruby_version=$ruby_version ynh_install_ruby --ruby_version=$ruby_version
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
@ -112,20 +112,20 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================
# INSTALL GEMS # INSTALL GEMS
#================================================= #=================================================
ynh_script_progression --message="Installing gems..." ynh_script_progression --message="Installing gems..." --weight=1
pushd $final_path pushd $final_path
ynh_use_ruby ynh_use_ruby
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less $ynh_gem install bundler --version $bundler_version ynh_exec_warn_less $ynh_gem install bundler --version $bundler_version
ynh_exec_warn_less $ynh_gem install rails --version $rails_version ynh_exec_warn_less $ynh_gem install rails --version $rails_version
ynh_exec_warn_less $ynh_gem install decidim -v $decidim_version ynh_exec_warn_less $ynh_gem install decidim -v $(ynh_app_upstream_version)
popd popd
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..." --weight=1
pushd "$final_path/live" pushd "$final_path/live"
ynh_secure_remove --file="$final_path/live/Gemfile.lock" ynh_secure_remove --file="$final_path/live/Gemfile.lock"
@ -140,7 +140,7 @@ ynh_package_autoremove
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
@ -149,7 +149,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -157,4 +157,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -31,19 +31,18 @@ secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..." ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
@ -55,7 +54,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions # Cleaning legacy permissions
if ynh_legacy_permissions_exists; then if ynh_legacy_permissions_exists; then
@ -67,7 +66,7 @@ fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path" ynh_system_user_create --username=$app --home_dir="$final_path"
@ -78,7 +77,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
fi fi
@ -87,18 +86,10 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_nodejs --nodejs_version=$nodejs_version
@ -107,12 +98,20 @@ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2
ynh_install_extra_app_dependencies --repo="deb https://oss-binaries.phusionpassenger.com/apt/passenger $(lsb_release -cs) main" --package="libnginx-mod-http-passenger" ynh_install_extra_app_dependencies --repo="deb https://oss-binaries.phusionpassenger.com/apt/passenger $(lsb_release -cs) main" --package="libnginx-mod-http-passenger"
ynh_install_ruby --ruby_version=$ruby_version ynh_install_ruby --ruby_version=$ruby_version
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# INSTALL GEMS # INSTALL GEMS
#================================================= #=================================================
ynh_script_progression --message="Installing gems..." ynh_script_progression --message="Installing gems..." --weight=1
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
@ -121,7 +120,7 @@ then
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less $ynh_gem install bundler --version $bundler_version ynh_exec_warn_less $ynh_gem install bundler --version $bundler_version
ynh_exec_warn_less $ynh_gem install rails --version $rails_version ynh_exec_warn_less $ynh_gem install rails --version $rails_version
ynh_exec_warn_less $ynh_gem install decidim -v $decidim_version ynh_exec_warn_less $ynh_gem install decidim -v $(ynh_app_upstream_version)
popd popd
fi fi
@ -132,7 +131,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/schedule.rb" --destination="$final_path/live/config/schedule.rb" ynh_add_config --template="../conf/schedule.rb" --destination="$final_path/live/config/schedule.rb"
chmod 400 "$final_path/live/config/schedule.rb" chmod 400 "$final_path/live/config/schedule.rb"
@ -158,7 +157,7 @@ chmod 644 "/etc/cron.d/$app"
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..." --weight=1
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
@ -185,7 +184,7 @@ ynh_package_autoremove
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -193,4 +192,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" ynh_script_progression --message="Upgrade of $app completed" --last