From 736d7908b4f31095e7a7b92fc632b0f6fad05e83 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 01:20:45 +0200 Subject: RUBY_VERSION factorisation --- scripts/restore | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/restore b/scripts/restore index c6e4bc8..bd79e95 100644 --- a/scripts/restore +++ b/scripts/restore @@ -114,9 +114,11 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Installing Ruby..." --weight=393 -ynh_install_ruby --ruby_version=2.6.5 -/opt/rbenv/versions/2.6.5/bin/gem update --system -/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document +ynh_install_ruby --ruby_version=$RUBY_VERSION +pushd "$final_path/live" + gem update --system + gem install bundler:1.17.3 --no-document +popd #================================================= # RESTORE THE POSTGRESQL DATABASE -- cgit v1.2.3-70-g09d2 From b5556ae674f1ca35da8f5e1d5a8a8ce4e69bc580 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 01:24:16 +0200 Subject: BUNDLER_VERSION factorization --- scripts/_common.sh | 2 ++ scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/_common.sh b/scripts/_common.sh index f39b966..bb0fe95 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,6 +9,8 @@ pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git RUBY_VERSION="2.6.5" +BUNDLER_VERSION="1.17.3" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 2e218c6..ab3aaa9 100644 --- a/scripts/install +++ b/scripts/install @@ -157,7 +157,7 @@ ynh_script_progression --message="Installing Ruby..." --weight=424 ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" gem update --system - gem install bundler:1.17.3 --no-document + gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= diff --git a/scripts/restore b/scripts/restore index bd79e95..724afc3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -117,7 +117,7 @@ ynh_script_progression --message="Installing Ruby..." --weight=393 ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" gem update --system - gem install bundler:1.17.3 --no-document + gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f34010b..149c2f5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -252,7 +252,7 @@ ynh_script_progression --message="Installing Ruby..." --weight=424 ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" gem update --system - gem install bundler:1.17.3 --no-document + gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= -- cgit v1.2.3-70-g09d2 From 2eb6680a727a36ac5bcb179d20eec5c6a4c871d3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 18:58:25 +0200 Subject: Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/restore') diff --git a/scripts/restore b/scripts/restore index 724afc3..5a349d4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -105,7 +105,7 @@ ynh_add_swap --size=$swap_needed #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=63 -ynh_install_nodejs --nodejs_version="10" +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -- cgit v1.2.3-70-g09d2 From f7e0cfd553116619409035037643441b1da0be85 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 12:23:48 +0200 Subject: moving to 3.8 new helper --- manifest.json | 2 +- scripts/install | 1 - scripts/remove | 1 - scripts/restore | 1 - scripts/upgrade | 1 - scripts/ynh_add_extra_apt_repos__3 | 294 ------------------------------------- 6 files changed, 1 insertion(+), 299 deletions(-) delete mode 100644 scripts/ynh_add_extra_apt_repos__3 (limited to 'scripts/restore') diff --git a/manifest.json b/manifest.json index 12f7789..b54d843 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,7 @@ } ], "requirements": { - "yunohost": ">= 3.7" + "yunohost": ">= 3.8" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 8b36e56..388b2a3 100644 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_add_extra_apt_repos__3 source ynh_add_swap source ynh_check_ram source /usr/share/yunohost/helpers diff --git a/scripts/remove b/scripts/remove index f2b2e16..d955a8a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_add_extra_apt_repos__3 source ynh_add_swap source /usr/share/yunohost/helpers diff --git a/scripts/restore b/scripts/restore index 5a349d4..dbcd5cb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,7 +9,6 @@ #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source ../settings/scripts/ynh_install_ruby__2 -source ../settings/scripts/ynh_add_extra_apt_repos__3 source ../settings/scripts/ynh_add_swap source ../settings/scripts/ynh_check_ram source /usr/share/yunohost/helpers diff --git a/scripts/upgrade b/scripts/upgrade index 0a19125..c5be012 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_add_extra_apt_repos__3 source ynh_add_swap source ynh_check_ram source /usr/share/yunohost/helpers diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/ynh_add_extra_apt_repos__3 deleted file mode 100644 index 3276f00..0000000 --- a/scripts/ynh_add_extra_apt_repos__3 +++ /dev/null @@ -1,294 +0,0 @@ -#!/bin/bash - -# Pin a repository. -# -# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] -# | arg: -p, --package - Packages concerned by the pin. Or all, *. -# | arg: -i, --pin - Filter for the pin. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. -# -ynh_pin_repo () { - # Declare an array to define the options of this helper. - local legacy_args=pirna - declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) - local package - local pin - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - package="${package:-*}" - priority=${priority:-50} - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/preferences.d" - echo "Package: $package -Pin: $pin -Pin-Priority: $priority" \ - | $append "/etc/apt/preferences.d/$name" -} - -# Add a repository. -# -# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] -# | arg: -u, --uri - Uri of the repository. -# | arg: -s, --suite - Suite of the repository. -# | arg: -c, --component - Component of the repository. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable -# uri suite component -# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable -# -ynh_add_repo () { - # Declare an array to define the options of this helper. - local legacy_args=uscna - declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) - local uri - local suite - local component - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/sources.list.d" - # Add the new repo in sources.list.d - echo "deb $uri $suite $component" \ - | $append "/etc/apt/sources.list.d/$name.list" -} - -# Add an extra repository correctly, pin it and get the key. -# -# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -k, --key - url to get the public key. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -ynh_install_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=rkpna - declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) - local repo - local key - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - key=${key:-0} - priority=${priority:-} - - if [ $append -eq 1 ] - then - append="--append" - wget_append="tee -a" - else - append="" - wget_append="tee" - fi - - # Split the repository into uri, suite and components. - # Remove "deb " at the beginning of the repo. - repo="${repo#deb }" - - # Get the uri - local uri="$(echo "$repo" | awk '{ print $1 }')" - - # Get the suite - local suite="$(echo "$repo" | awk '{ print $2 }')" - - # Get the components - local component="${repo##$uri $suite }" - - # Add the repository into sources.list.d - ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append - - # Pin the new repo with the default priority, so it won't be used for upgrades. - # Build $pin from the uri without http and any sub path - local pin="${uri#*://}" - pin="${pin%%/*}" - # Set a priority only if asked - if [ -n "$priority" ] - then - priority="--priority=$priority" - fi - ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append - - # Get the public key for the repo - if [ -n "$key" ] - then - mkdir -p "/etc/apt/trusted.gpg.d" - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null - fi - - # Update the list of package with the new repo - ynh_package_update -} - -# Remove an extra repository and the assiociated configuration. -# -# usage: ynh_remove_extra_repo [--name=name] -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_remove_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=n - declare -Ar args_array=( [n]=name= ) - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - - ynh_secure_remove "/etc/apt/sources.list.d/$name.list" - ynh_secure_remove "/etc/apt/preferences.d/$name" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" - - # Update the list of package to exclude the old repo - ynh_package_update -} - -# Install packages from an extra repository properly. -# -# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -p, --package - The packages to install from this extra repository -# | arg: -k, --key - url to get the public key. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_install_extra_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=rpkn - declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) - local repo - local package - local key - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - key=${key:-0} - - # Set a key only if asked - if [ -n "$key" ] - then - key="--key=$key" - fi - # Add an extra repository for those packages - ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name - - # Install requested dependencies from this extra repository. - ynh_add_app_dependencies --package="$package" - - # Remove this extra repository after packages are installed - ynh_remove_extra_repo --name=$app -} - -#================================================= - -# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies - -# Define and install dependencies with a equivs control file -# This helper can/should only be called once per app -# -# usage: ynh_install_app_dependencies dep [dep [...]] -# | arg: dep - the package name to install in dependence -# You can give a choice between some package with this syntax : "dep1|dep2" -# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" -# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) -# -# Requires YunoHost version 2.6.4 or higher. -ynh_install_app_dependencies () { - local dependencies=$@ - dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" - dependencies=${dependencies//|/ | } - local manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - - local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. - if [ ${#version} -eq 0 ]; then - version="1.0" - fi - local dep_app=${app//_/-} # Replace all '_' by '-' - - # Handle specific versions - if [[ "$dependencies" =~ [\<=\>] ]] - then - # Replace version specifications by relationships syntax - # https://www.debian.org/doc/debian-policy/ch-relationships.html - # Sed clarification - # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. - # [\<=\>] matches < = or > - # \+ matches one or more occurence of the previous characters, for >= or >>. - # [^,]\+ matches all characters except ',' - # Ex: package>=1.0 will be replaced by package (>= 1.0) - dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" - fi - - cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build -Section: misc -Priority: optional -Package: ${dep_app}-ynh-deps -Version: ${version} -Depends: ${dependencies} -Architecture: all -Description: Fake package for $app (YunoHost app) dependencies - This meta-package is only responsible of installing its dependencies. -EOF - ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ - || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies - rm /tmp/${dep_app}-ynh-deps.control - ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" -} - -ynh_add_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=pr - declare -Ar args_array=( [p]=package= [r]=replace) - local package - local replace - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - replace=${replace:-0} - - local current_dependencies="" - if [ $replace -eq 0 ] - then - local dep_app=${app//_/-} # Replace all '_' by '-' - if ynh_package_is_installed --package="${dep_app}-ynh-deps" - then - current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " - fi - - current_dependencies=${current_dependencies// | /|} - fi - - ynh_install_app_dependencies "${current_dependencies}${package}" -} -- cgit v1.2.3-70-g09d2 From 3d713af143776d074d2f37cb0689d777aa632fdf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:18:02 +0200 Subject: Moving from ynh_check_ram to ynh_get_ram --- manifest.json | 2 +- scripts/install | 6 ++--- scripts/restore | 4 +-- scripts/upgrade | 4 +-- scripts/ynh_check_ram | 72 --------------------------------------------------- 5 files changed, 5 insertions(+), 83 deletions(-) delete mode 100644 scripts/ynh_check_ram (limited to 'scripts/restore') diff --git a/manifest.json b/manifest.json index b54d843..9041ab7 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,7 @@ } ], "requirements": { - "yunohost": ">= 3.8" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 388b2a3..97dee20 100644 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,6 @@ source _common.sh source ynh_install_ruby__2 source ynh_add_swap -source ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -134,12 +133,11 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Adding swap is needed..." --weight=4 -total_memory=$(ynh_check_ram) -total_swap=$(ynh_check_ram --only_swap) +total_memory=$(ynh_get_ram --total) swap_needed=0 if [ $total_memory -lt 2560 ]; then - # Need a minimum of 8Go of memory + # Need a minimum of 2.5Go of memory swap_needed=$((2560 - $total_memory)) fi diff --git a/scripts/restore b/scripts/restore index dbcd5cb..ed0b27d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,7 +10,6 @@ source ../settings/scripts/_common.sh source ../settings/scripts/ynh_install_ruby__2 source ../settings/scripts/ynh_add_swap -source ../settings/scripts/ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -87,8 +86,7 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Adding swap if needed..." --weight=4 -total_memory=$(ynh_check_ram) -total_swap=$(ynh_check_ram --only_swap) +total_memory=$(ynh_get_ram --total) swap_needed=0 if [ $total_memory -lt 2560 ]; then diff --git a/scripts/upgrade b/scripts/upgrade index c5be012..9e02c01 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,7 +9,6 @@ source _common.sh source ynh_install_ruby__2 source ynh_add_swap -source ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -231,8 +230,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Adding swap if needed..." --weight=7 -total_memory=$(ynh_check_ram) -total_swap=$(ynh_check_ram --only_swap) +total_memory=$(ynh_get_ram --total) swap_needed=0 if [ $total_memory -lt 2560 ]; then diff --git a/scripts/ynh_check_ram b/scripts/ynh_check_ram deleted file mode 100644 index 11012a3..0000000 --- a/scripts/ynh_check_ram +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# Check the amount of available RAM -# -# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram] -# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise. -# If --required isn't set, the helper will print the amount of RAM, in Mb. -# | arg: -s, --no_swap - Ignore swap -# | arg: -o, --only_swap - Ignore real RAM, consider only swap. -# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available. -ynh_check_ram () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram ) - local required - local no_swap - local only_swap - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - required=${required:-} - no_swap=${no_swap:-0} - only_swap=${only_swap:-0} - - local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}') - local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}') - local total_ram_swap=$(( total_ram + total_swap )) - - local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}') - local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}') - local free_ram_swap=$(( free_ram + free_swap )) - - # Use the total amount of ram - local ram=$total_ram_swap - if [ $free_ram -eq 1 ] - then - # Use the total amount of free ram - ram=$free_ram_swap - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$free_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$free_swap - fi - else - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$total_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$total_swap - fi - fi - - if [ -n "$required" ] - then - # Return 1 if the amount of ram isn't enough. - if [ $ram -lt $required ] - then - return 1 - else - return 0 - fi - - # If no RAM is required, return the amount of available ram. - else - echo $ram - fi -} -- cgit v1.2.3-70-g09d2 From f2051e67a3a7ee03254677434a35209beff2225b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:19:50 +0200 Subject: $MEMORY_NEEDED factorisation --- scripts/_common.sh | 2 ++ scripts/install | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/_common.sh b/scripts/_common.sh index e0686b2..dc466ba 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,6 +13,8 @@ BUNDLER_VERSION="1.17.3" NODEJS_VERSION="12" +MEMORY_NEEDED="2560" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 97dee20..8c63cde 100644 --- a/scripts/install +++ b/scripts/install @@ -136,9 +136,9 @@ ynh_script_progression --message="Adding swap is needed..." --weight=4 total_memory=$(ynh_get_ram --total) swap_needed=0 -if [ $total_memory -lt 2560 ]; then +if [ $total_memory -lt $MEMORY_NEEDED ]; then # Need a minimum of 2.5Go of memory - swap_needed=$((2560 - $total_memory)) + swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 diff --git a/scripts/restore b/scripts/restore index ed0b27d..ae64eaf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,9 +89,9 @@ ynh_script_progression --message="Adding swap if needed..." --weight=4 total_memory=$(ynh_get_ram --total) swap_needed=0 -if [ $total_memory -lt 2560 ]; then +if [ $total_memory -lt $MEMORY_NEEDED ]; then # Need a minimum of 8Go of memory - swap_needed=$((2560 - $total_memory)) + swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 diff --git a/scripts/upgrade b/scripts/upgrade index 9e02c01..fd58f16 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -233,9 +233,9 @@ ynh_script_progression --message="Adding swap if needed..." --weight=7 total_memory=$(ynh_get_ram --total) swap_needed=0 -if [ $total_memory -lt 2560 ]; then +if [ $total_memory -lt $MEMORY_NEEDED ]; then # Need a minimum of 8Go of memory - swap_needed=$((2560 - $total_memory)) + swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 -- cgit v1.2.3-70-g09d2 From d3ea53c200fd20a61acb4bb1a5dce5aa6ab77752 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:22:20 +0200 Subject: removing not needed cron job description --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/install b/scripts/install index 8c63cde..c78419e 100644 --- a/scripts/install +++ b/scripts/install @@ -219,9 +219,9 @@ ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_k ynh_secure_remove --file="$final_path/live/key.txt" #================================================= -# SETUP CRON JOB FOR REMOVING CACHE +# SETUP CRON JOB #================================================= -ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 +ynh_script_progression --message="Setuping a cron job..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app diff --git a/scripts/restore b/scripts/restore index ae64eaf..f41b2a8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -158,7 +158,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RESTORE THE CRON FILE #================================================= -ynh_script_progression --message="Restoring a cron job for removing cache..." --weight=2 +ynh_script_progression --message="Restoring a cron job..." --weight=2 ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index fd58f16..eff42b3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -302,7 +302,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SETUP CRON JOB FOR REMOVING CACHE #================================================= -ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 +ynh_script_progression --message="Setuping a cron job..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app -- cgit v1.2.3-70-g09d2 From 0c4121ac5234e4351a431f9e6091c426a60aa533 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:40:04 +0200 Subject: Add service description --- scripts/install | 6 +++--- scripts/restore | 6 +++--- scripts/upgrade | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/install b/scripts/install index c78419e..5443717 100644 --- a/scripts/install +++ b/scripts/install @@ -264,9 +264,9 @@ chown -R "$app": "$final_path" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 -yunohost service add "$app-web" -yunohost service add "$app-sidekiq" -yunohost service add "$app-streaming" +yunohost service add "$app-web" --description "$app web service" --log_type "systemd" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" +yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index f41b2a8..175543a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -142,9 +142,9 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 -yunohost service add $app-web -yunohost service add $app-sidekiq -yunohost service add $app-streaming +yunohost service add "$app-web" --description "$app web service" --log_type "systemd" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" +yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index eff42b3..f14c08b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -322,6 +322,15 @@ ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 + +yunohost service add "$app-web" --description "$app web service" --log_type "systemd" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" +yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" + #================================================= # GENERIC FINALIZATION #================================================= -- cgit v1.2.3-70-g09d2 From 5108846acb8628d01aec2f8444e2256be2f13fae Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:44:21 +0200 Subject: cron job to cron file --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/install b/scripts/install index 5443717..77c3cca 100644 --- a/scripts/install +++ b/scripts/install @@ -219,9 +219,9 @@ ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_k ynh_secure_remove --file="$final_path/live/key.txt" #================================================= -# SETUP CRON JOB +# SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping a cron job..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app diff --git a/scripts/restore b/scripts/restore index 175543a..694b649 100644 --- a/scripts/restore +++ b/scripts/restore @@ -158,7 +158,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RESTORE THE CRON FILE #================================================= -ynh_script_progression --message="Restoring a cron job..." --weight=2 +ynh_script_progression --message="Restoring the cron file..." --weight=2 ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index f14c08b..d578415 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -300,9 +300,9 @@ popd ynh_store_file_checksum --file="$config" #================================================= -# SETUP CRON JOB FOR REMOVING CACHE +# SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping a cron job..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app -- cgit v1.2.3-70-g09d2 From 8fea96dcd81f40923ba2f599c3b7ab838429f2de Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Jun 2020 18:34:04 +0200 Subject: apply last example_ynh for ynh_script_progression --- scripts/backup | 7 +++---- scripts/install | 46 ++++++++++++++++++++++------------------------ scripts/remove | 25 ++++++++++++------------- scripts/restore | 36 ++++++++++++++++++------------------ scripts/upgrade | 44 ++++++++++++++++++++++---------------------- 5 files changed, 77 insertions(+), 81 deletions(-) (limited to 'scripts/restore') diff --git a/scripts/backup b/scripts/backup index 9159b31..c1d4f6f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Managing script failure..." --weight=1 ynh_clean_setup () { ynh_clean_check_starting @@ -24,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -68,7 +67,7 @@ ynh_backup --src_path="/etc/cron.d/$app" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Backing up the PostgreSQL database..." --weight=4 +ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql @@ -76,4 +75,4 @@ ynh_psql_dump_db --database="$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 77c3cca..ebc4173 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Managing script failure..." --weight=1 ynh_clean_setup () { ynh_clean_check_starting @@ -25,7 +24,6 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_script_progression --message="Retrieving arguments from the manifest..." --weight=1 domain=$YNH_APP_ARG_DOMAIN path_url="/" @@ -40,7 +38,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=2 +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -51,7 +49,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=2 +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -64,7 +62,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=1 +ynh_script_progression --message="Configuring firewall..." # Find an available port port_web=$(ynh_find_port --port=3000) @@ -76,7 +74,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=86 +ynh_script_progression --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies @@ -85,7 +83,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5 +ynh_script_progression --message="Creating a MySQL database..." # Create postgresql database db_name="${app}_production" @@ -100,7 +98,7 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=5 +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -113,7 +111,7 @@ ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_strin #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=3 +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config 'port_web port_stream' @@ -121,7 +119,7 @@ ynh_add_nginx_config 'port_web port_stream' #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=4 +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path @@ -131,7 +129,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap is needed..." --weight=4 +ynh_script_progression --message="Adding swap is needed..." total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -141,13 +139,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." --weight=424 +ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" @@ -158,7 +156,7 @@ popd #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=2 +ynh_script_progression --message="Modifying a config file..." config="$final_path/live/.env.production" cp -f ../conf/.env.production.sample "$config" @@ -189,7 +187,7 @@ ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="m #================================================= # INSTALLING MASTODON #================================================= -ynh_script_progression --message="Installing Mastodon..." --weight=2230 +ynh_script_progression --message="Installing Mastodon..." chown -R "$app": "$final_path" @@ -221,7 +219,7 @@ ynh_secure_remove --file="$final_path/live/key.txt" #================================================= # SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping the cron file..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app @@ -229,7 +227,7 @@ cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=5 +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" @@ -244,7 +242,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_script_progression --message="Storing the config file checksum..." --weight=1 +ynh_script_progression --message="Storing the config file checksum..." # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config" @@ -254,7 +252,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=9 +ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R "$app": "$final_path" @@ -262,7 +260,7 @@ chown -R "$app": "$final_path" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add "$app-web" --description "$app web service" --log_type "systemd" yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" @@ -271,7 +269,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=47 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing" @@ -280,7 +278,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=2 +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -292,7 +290,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -300,4 +298,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index d955a8a..9fac8f2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=6 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,31 +28,30 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_script_progression --message="Removing service integration in YunoHost..." --weight=2 # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null then - ynh_script_progression --message="Removing $app-web service..." --weight=2 + ynh_script_progression --message="Removing $app-web service..." yunohost service remove "$app-web" fi if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null then - ynh_script_progression --message="Removing $app-sidekiq service..." --weight=2 + ynh_script_progression --message="Removing $app-sidekiq service..." yunohost service remove "$app-sidekiq" fi if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null then - ynh_script_progression --message="Removing $app-streaming service..." --weight=2 + ynh_script_progression --message="Removing $app-streaming service..." yunohost service remove "$app-streaming" fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=27 +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config --service="$app-web" @@ -62,7 +61,7 @@ ynh_remove_systemd_config --service="$app-streaming" #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 +ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" @@ -70,7 +69,7 @@ ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=28 +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_ruby @@ -81,7 +80,7 @@ ynh_remove_extra_repo #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=16 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -89,7 +88,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --weight=2 +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -99,7 +98,7 @@ ynh_remove_nginx_config #================================================= # REMOVE THE CRON FILE #================================================= -ynh_script_progression --message="Removing the cron file..." --weight=2 +ynh_script_progression --message="Removing the cron file..." # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" @@ -112,7 +111,7 @@ ynh_del_swap #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=2 +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app @@ -121,4 +120,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 694b649..513d924 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Managing script failure..." --weight=2 +ynh_script_progression --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -26,7 +26,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=2 +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -40,7 +40,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=2 +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -52,21 +52,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring nginx configuration..." --weight=1 +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=105 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=5 +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -74,7 +74,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE USER RIGHTS #================================================= -ynh_script_progression --message="Restoring users rights..." --weight=4 +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path @@ -84,7 +84,7 @@ chown -R $app: $final_path #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." --weight=4 +ynh_script_progression --message="Adding swap if needed..." total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -94,13 +94,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=63 +ynh_script_progression --message="Reinstalling dependencies..." ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies @@ -109,7 +109,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." --weight=393 +ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" @@ -120,7 +120,7 @@ popd #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=18 +ynh_script_progression --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 @@ -130,7 +130,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=3 +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service" @@ -140,7 +140,7 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add "$app-web" --description "$app web service" --log_type "systemd" yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" @@ -149,7 +149,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=41 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing" @@ -158,7 +158,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RESTORE THE CRON FILE #================================================= -ynh_script_progression --message="Restoring the cron file..." --weight=2 +ynh_script_progression --message="Restoring the cron file..." ynh_restore_file --origin_path="/etc/cron.d/$app" @@ -167,7 +167,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -175,4 +175,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index e4295fe..8441307 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=4 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -40,14 +40,14 @@ vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." config="$final_path/live/.env.production" @@ -131,7 +131,7 @@ ynh_remove_extra_repo #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=442 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -160,7 +160,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=22 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped" @@ -172,7 +172,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=14 + ynh_script_progression --message="Upgrading source files..." # Download Mastodon tmpdir="$(mktemp -d)" @@ -201,14 +201,14 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3 +ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_add_nginx_config 'port_web port_stream' #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=24 +ynh_script_progression --message="Upgrading dependencies..." ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -218,7 +218,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=7 +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -228,7 +228,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." --weight=7 +ynh_script_progression --message="Adding swap if needed..." total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -238,13 +238,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." --weight=424 +ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" @@ -255,7 +255,7 @@ popd #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=1 +ynh_script_progression --message="Modifying a config file..." ynh_backup_if_checksum_is_different --file="$config" cp -f ../conf/.env.production.sample "$config" @@ -280,7 +280,7 @@ ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapi #================================================= # UPGRADE MASTODON #================================================= -ynh_script_progression --message="Upgrading Mastodon..." --weight=2640 +ynh_script_progression --message="Upgrading Mastodon..." chown -R "$app": "$final_path" @@ -302,7 +302,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping the cron file..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app @@ -310,7 +310,7 @@ cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=13 +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" @@ -325,7 +325,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add "$app-web" --description "$app web service" --log_type "systemd" yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" @@ -336,7 +336,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=9 +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path @@ -344,7 +344,7 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -356,7 +356,7 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=48 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing" @@ -365,7 +365,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -373,4 +373,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" -- cgit v1.2.3-70-g09d2