From f023dda2759ce1d087f40fe76e1033eab63b3ca3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 19 Apr 2020 05:16:46 +0200 Subject: [PATCH 01/30] Apply example_ynh --- README.md | 1 - check_process | 13 +-- manifest.json | 8 +- scripts/_common.sh | 101 ++----------------- scripts/actions/change_password | 2 +- scripts/actions/change_theme | 2 +- scripts/actions/public_private | 2 +- scripts/backup | 40 ++++---- scripts/change_url | 105 +++++++++++-------- scripts/install | 172 +++++++++++++++++--------------- scripts/remove | 76 +++++++------- scripts/restore | 100 ++++++++++--------- scripts/upgrade | 163 +++++++++++++++++------------- 13 files changed, 382 insertions(+), 403 deletions(-) diff --git a/README.md b/README.md index faa676f..c5485ae 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Can the app be used by multiple users? **Yes** * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lstu%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lstu/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lstu%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lstu/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/lstu%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/lstu/) **More information on the documentation page:** diff --git a/check_process b/check_process index 4df7923..02a052a 100644 --- a/check_process +++ b/check_process @@ -17,17 +17,10 @@ upgrade=1 from_commit=7410eb674fc4670fcc0398e8e1d086e2560c7f28 backup_restore=1 multi_instance=1 - incorrect_path=1 + # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. + # incorrect_path=1 port_already_use=1 (8095) change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=1 + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 diff --git a/manifest.json b/manifest.json index 3c95efc..53988ea 100644 --- a/manifest.json +++ b/manifest.json @@ -2,20 +2,20 @@ "name": "Lstu", "id": "lstu", "packaging_format": 1, - "version": "0.21-4~ynh4", - "requirements": { - "yunohost": ">= 3.0" - }, "description": { "en": "URL Shortener", "fr": "Raccoursisseur d'URL" }, + "version": "0.21-4~ynh4", "url": "https://lstu.fr", "license": "WTFPL", "maintainer": { "name": "frju365", "email": "abld@abld.info" }, + "requirements": { + "yunohost": ">= 3.5" + }, "multi_instance": true, "services": [ "nginx" diff --git a/scripts/_common.sh b/scripts/_common.sh index 2bfa0f4..50159c9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,98 +1,15 @@ #!/bin/bash -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] -# | arg: -n, --service_name= - Name of the service to reload. Default : $app -# | arg: -a, --action= - Action to perform with systemctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# If not defined it don't wait until the service is completely started. -# WARNING: When using --line_match, you should always add `ynh_clean_check_starting` into your -# `ynh_clean_setup` at the beginning of the script. Otherwise, tail will not stop in case of failure -# of the script. The script will then hang forever. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout +#================================================= +# COMMON VARIABLES +#================================================= - # Manage arguments with getopts - ynh_handle_getopts_args "$@" +# dependencies used by the app +pkg_dependencies="build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql cpanminus" - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} - - # Start to read the log - if [[ -n "${line_match:-}" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] ; then - # Read the systemd journal - journalctl --unit=$service_name --follow --since=-0 --quiet > "$templog" & - # Get the PID of the journalctl command - local pid_tail=$! - else - # Read the specified log file - tail -F -n0 "$log_path" > "$templog" & - # Get the PID of the tail command - local pid_tail=$! - fi - fi - - echo "${action^} the service $service_name" >&2 - systemctl $action $service_name \ - || ( journalctl --no-pager --lines=$length -u $service_name >&2 \ - ; test -e "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ - ; false ) - - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - echo "Please find here an extract of the end of the log of the service $service_name:" - journalctl --no-pager --lines=$length -u $service_name >&2 - test -e "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 - fi - - echo "" - ynh_clean_check_starting - fi -} - -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} +#================================================= +# PERSONAL HELPERS +#================================================= #================================================= # EXPERIMENTAL HELPERS @@ -231,4 +148,4 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service # Send the email to the recipients cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" -} \ No newline at end of file +} diff --git a/scripts/actions/change_password b/scripts/actions/change_password index 8df1ce3..212c0d0 100755 --- a/scripts/actions/change_password +++ b/scripts/actions/change_password @@ -29,7 +29,7 @@ hashed_password_old=$(ynh_app_setting_get $app hashed_password) if [ "$hashed_password" == "$hashed_password_old" ] then - ynh_die "Same password." 0 + ynh_die --message="Same password." 0 fi #================================================= diff --git a/scripts/actions/change_theme b/scripts/actions/change_theme index d4774a6..979b6ec 100755 --- a/scripts/actions/change_theme +++ b/scripts/actions/change_theme @@ -28,7 +28,7 @@ theme_old=$(ynh_app_setting_get $app theme) if [ "$theme" == "$theme_old" ] then - ynh_die "Same theme." 0 + ynh_die --message="Same theme." 0 fi #================================================= diff --git a/scripts/actions/public_private b/scripts/actions/public_private index b06a9c0..3a8a6a1 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -41,7 +41,7 @@ is_public_old=$(ynh_app_setting_get $app is_public) if [ $is_public -eq $is_public_old ] then - ynh_die "is_public is already set as $is_public." 0 + ynh_die --message="is_public is already set as $is_public." 0 fi #================================================= diff --git a/scripts/backup b/scripts/backup index 39ca1b9..23329cc 100644 --- a/scripts/backup +++ b/scripts/backup @@ -12,9 +12,9 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. true } # Exit if an error occurs during the execution of the script @@ -23,56 +23,62 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_print_info --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backing up nginx web server configuration..." +ynh_print_info --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_print_info "Backing up the PostgreSQL database..." +ynh_print_info --message="Backing up the PostgreSQL database..." -ynh_psql_dump_db "$db_name" > db.sql +ynh_psql_dump_db --database="$db_name" > db.sql #================================================= # SPECIFIC BACKUP #================================================= # BACKUP LOGROTATE #================================================= -ynh_print_info "Backing up logrotate configuration..." +ynh_print_info --message="Backing up logrotate configuration..." -ynh_backup "/etc/logrotate.d/$app" +ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_print_info "Backing up systemd configuration..." +ynh_print_info --message="Backing up systemd configuration..." -ynh_backup "/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." - +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index ba5ab9d..0949d17 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -24,29 +25,37 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Needed for lstu conf -port=$(ynh_app_setting_get $app port) -is_public=$(ynh_app_setting_get $app is_public) -db_name=$(ynh_app_setting_get "$app" db_name) -db_pwd=$(ynh_app_setting_get $app psqlpwd) +port=$(ynh_app_setting_get --app=$app --key=port) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_user=$db_name -secret=$(ynh_app_setting_get $app secret) -theme=$(ynh_app_setting_get $app theme) -hashed_password=$(ynh_app_setting_get $app hashed_password) +secret=$(ynh_app_setting_get --app=$app --key=secret) +theme=$(ynh_app_setting_get --app=$app --key=theme) +hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= -# CHECK THE SYNTAX OF THE PATHS +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info --message="Backing up the app before changing its url (may take a while)..." -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -66,10 +75,17 @@ fi #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_print_info --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -77,7 +93,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_path -eq 1 ] then # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" @@ -89,10 +105,10 @@ fi if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -100,37 +116,44 @@ fi #================================================= # SETUP LSTU #================================================= -ynh_print_info "Updating lstu configuration..." +ynh_print_info --message="Updating lstu configuration..." domain="$new_domain" path_url="$new_path" -ynh_backup_if_checksum_is_different "$final_path/lstu.conf" -cp ../conf/lstu.conf.template "${final_path}/lstu.conf" -ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lstu.conf" -ynh_replace_string "__PATH__" "$path_url" "${final_path}/lstu.conf" -ynh_replace_string "__PORT__" "$port" "${final_path}/lstu.conf" -ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lstu.conf" -ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lstu.conf" -ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lstu.conf" -ynh_replace_string "__SELECTED_THEME__" "$theme" "${final_path}/lstu.conf" -ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.conf" - -ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf" +config="${final_path}/lstu.conf" +ynh_backup_if_checksum_is_different --file="$config" +cp ../conf/lstu.conf.template "$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string="$theme" --target_file="$config" +ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string="$hashed_password" --target_file="$config" +ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lstu.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else - ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lstu.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi -ynh_store_file_checksum "${final_path}/lstu.conf" +ynh_store_file_checksum --file="$config" #================================================= # GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting hot deployment for Hypnotoad server" + #================================================= # UPDATE SSOWAT #================================================= -ynh_print_info "Reconfigure SSOwat" +ynh_print_info --message="Reconfigure SSOwat" if [ $is_public -eq 0 ] then @@ -144,21 +167,15 @@ then ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" fi -#================================================= -# RESTART LSTU -#================================================= - -ynh_systemd_action -n $app -a reload -l "Starting hot deployment for Hypnotoad server" -p "systemd" - #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_print_info --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 56aefc0..618c69a 100644 --- a/scripts/install +++ b/scripts/install @@ -12,11 +12,10 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting - - true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,90 +23,95 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC theme=$YNH_APP_ARG_THEME password=$YNH_APP_ARG_PASSWORD +secret=$(ynh_string_random 24) +hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1) app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_print_info --message="Validating installation parameters..." final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path --path_url=$path_url) # Check web path availability -ynh_webpath_available $domain $path_url +ynh_webpath_available --domain=$domain --path_url=$path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url - -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_print_info "Configuring firewall..." - -# Find a free port -port=$(ynh_find_port 8095) -# Open this port -yunohost firewall allow --no-upnp TCP $port 2>&1 +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info "Storing installation settings..." +ynh_print_info --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app port $port -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app theme $theme -hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1) -ynh_app_setting_set $app hashed_password $hashed_password +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=port --value=$port +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=theme --value=$theme +ynh_app_setting_set --app=$app --key=secret --value=$secret +ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_print_info --message="Configuring firewall..." + +# Find an available port +port=$(ynh_find_port --port=8095) +# Open this port +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info "Installing dependencies..." +ynh_print_info --message="Installing dependencies..." + +ynh_install_app_dependencies $pkg_dependencies -ynh_install_app_dependencies build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql cpanminus # Install Carton echo yes | cpanm Carton #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_print_info "Creating a PostgreSQL database..." +ynh_print_info --message="Creating a PostgreSQL database..." # Create postgresql database ynh_psql_test_if_first_run -db_name=$(ynh_sanitize_dbid "$app") +db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -# Initialize database and store postgres password for upgrade -ynh_psql_setup_db "$db_name" "$db_user" -ynh_app_setting_set "$app" db_name "$db_name" -db_pwd=$(ynh_app_setting_get $app psqlpwd) # Password created in ynh_psql_setup_db function +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_print_info --message="Setting up source files..." -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx web server..." +ynh_print_info --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -115,74 +119,91 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Configuring system user..." +ynh_print_info --message="Configuring system user..." # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= ## Copy and fix variable into lstu config #================================================= -ynh_print_info "Configuring lstu..." +ynh_print_info --message="Configuring lstu..." -cp ../conf/lstu.conf.template "${final_path}/lstu.conf" -ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lstu.conf" -ynh_replace_string "__PATH__" "$path_url" "${final_path}/lstu.conf" -ynh_replace_string "__PORT__" "$port" "${final_path}/lstu.conf" -ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lstu.conf" -ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lstu.conf" -ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lstu.conf" -ynh_replace_string "__SELECTED_THEME__" "$theme" "${final_path}/lstu.conf" -ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.conf" - -secret=$(ynh_string_random 24) -ynh_app_setting_set $app secret $secret -ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf" +config="${final_path}/lstu.conf" +cp ../conf/lstu.conf.template "$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string"$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string"$path_url" --target_file="$config" +ynh_replace_string --match_string="__PORT__" --replace_string"$port" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string"$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string"$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string"$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string"$theme" --target_file="$config" +ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string"$hashed_password" --target_file="$config" +ynh_replace_string --match_string="__SECRET__" --replace_string"$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lstu.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string"" --target_file="$config" else - ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lstu.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string"#" --target_file="$config" fi -ynh_store_file_checksum "${final_path}/lstu.conf" +ynh_store_file_checksum --file="$config" #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info "Configuring a systemd service..." +ynh_print_info --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config #================================================= -# Install lstu's dependencies via carton +# BUILD LSTU #================================================= -ynh_print_info "Installing lstu..." +ynh_print_info --message="Building lstu..." pushd $final_path -carton install --deployment --without=sqlite --without=mysql + carton install --deployment --without=sqlite --without=mysql popd +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= +ynh_print_info --message="Securing files and directories..." + +# Set permissions to app files +chown -R www-data $final_path + #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info "Configuring log rotation..." +ynh_print_info --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/production.log" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" + #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_print_info --message="Configuring SSOwat..." -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris--value= "/" if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. @@ -192,33 +213,18 @@ then fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" + ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" fi -#================================================= -# Configure owner -#================================================= - -chown -R www-data $final_path - -#================================================= -# Start lstu -#================================================= - -systemctl enable $app.service -ynh_systemd_action -n $app -a start -l "Server available at" -p "systemd" - #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -# Reload Nginx -systemctl reload nginx -yunohost app ssowatconf +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Installation of $app completed" +ynh_print_info --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index c85dd20..c5d7b72 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,63 +12,74 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -port=$(ynh_app_setting_get $app port) -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= +ynh_print_info --message="Removing service integration in YunoHost..." -# Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status | grep -q $app +# 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 >/dev/null then - echo "Remove $app service" + ynh_print_info --message="Removing $app service..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info "Stopping and removing the systemd service" +ynh_print_info --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Removing the PostgreSQL database..." + +# Remove a database if it exists, along with the associated user +ynh_psql_remove_db --db_name=$db_name --db_user=$db_user + +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info --message="Removing dependencies..." + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_print_info --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_print_info --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# Delete Log -#================================================= - -ynh_secure_remove "/var/log/$app.log" - #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_print_info "Removing logrotate configuration" +ynh_print_info --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -76,40 +87,35 @@ ynh_remove_logrotate #================================================= # CLOSE A PORT #================================================= +ynh_print_info --message="Closing a port..." if yunohost firewall list | grep -q "\- $port$" then - echo "Close port $port" - yunohost firewall disallow TCP $port 2>&1 + ynh_print_info --message="Closing port $port..." + ynh_exec_warn_less yunohost firewall disallow TCP $port fi #================================================= -# REMOVE DEPENDENCIES +# SPECIFIC REMOVE #================================================= -ynh_print_info "Removing dependencies" - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - +# REMOVE LOG FILES #================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_print_info "Removing the PostgreSQL database" +ynh_print_info --message="Removing log files..." -ynh_psql_remove_db $db_name $db_user +ynh_secure_remove --file="/var/log/$app.log" #================================================= # GENERIC FINALIZATION #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user" +ynh_print_info --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_print_info --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index ff4b7c1..2b3d8df 100644 --- a/scripts/restore +++ b/scripts/restore @@ -12,11 +12,10 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting - - true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,110 +23,121 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_print_info --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_print_info --message="Validating restoration parameters..." -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_print_info "Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql cpanminus -# Install Carton -echo yes | cpanm Carton - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_print_info --message="Restoring the nginx configuration..." -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restoring the app main directory..." +ynh_print_info --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreating the dedicated system user..." +ynh_print_info --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create $app - -#================================================= -# RESTORE THE POSTGRESQL DATABASE -#================================================= -ynh_print_info "Restoring the PostregSQL database..." - -db_pwd=$(ynh_app_setting_get $app psqlpwd) -ynh_psql_test_if_first_run -ynh_psql_setup_db $db_name $db_name $db_pwd -ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= +ynh_print_info --message="Restoring user rights..." # Restore permissions on app files chown -R www-data $final_path #================================================= # SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info --message="Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +# Install Carton +echo yes | cpanm Carton + +#================================================= +# RESTORE THE POSTGRESQL DATABASE +#================================================= +ynh_print_info --message="Restoring the PostregSQL database..." + +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql + #================================================= # RESTORE SYSTEMD #================================================= -ynh_print_info "Restoring the systemd configuration..." +ynh_print_info --message="Restoring the systemd configuration..." -ynh_restore_file "/etc/systemd/system/$app.service" +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service -ynh_systemd_action -n $app -a start -l "Server available at" -p "systemd" #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/production.log" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" + #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= +ynh_print_info --message="Restoring the logrotate configuration..." -ynh_restore_file "/etc/logrotate.d/$app" +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx -yunohost app ssowatconf +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_print_info --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index fe98d8a..6c109c5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,38 +12,47 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) -port=$(ynh_app_setting_get $app port) -final_path=$(ynh_app_setting_get $app final_path) -secret=$(ynh_app_setting_get $app secret) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +port=$(ynh_app_setting_get --app=$app --key=port) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +secret=$(ynh_app_setting_get --app=$app --key=secret) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name -db_pwd=$(ynh_app_setting_get $app psqlpwd) -theme=$(ynh_app_setting_get $app theme) -hashed_password=$(ynh_app_setting_get $app hashed_password) +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +theme=$(ynh_app_setting_get --app=$app theme) +hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= -# FIX OLD THINGS +# CHECK VERSION #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_print_info --message="Checking version..." +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_print_info --message="Ensuring downward compatibility..." + +# Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 # Fixe is_public en booléen + ynh_app_setting_set --app=$app --key=is_public --value=1 is_public=1 elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 + ynh_app_setting_set --app=$app --key=is_public --value=0 is_public=0 fi -if [ "${#final_path}" -eq 0 ] -then # Si final_path n'est pas renseigné dans la config yunohost, cas d'ancien script, code final_path en dur +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi if [ -z "$db_pwd" ]; then @@ -83,7 +92,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." +ynh_print_info --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -97,106 +106,116 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." -ynh_install_app_dependencies build-essential libssl-dev zlib1g-dev libpng-dev libpq-dev memcached postgresql cpanminus +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_print_info --message="Upgrading source files..." -ynh_setup_source "$final_path" + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info --message="Upgrading dependencies..." + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # SPECIFIC UPGRADE #================================================= -# SETUP LSTU +# UPGRADE LSTU CONFIGURATION #================================================= -ynh_print_info "Upgrading lstu configuration..." +ynh_print_info --message="Upgrading lstu configuration..." -ynh_backup_if_checksum_is_different "$final_path/lstu.conf" -cp ../conf/lstu.conf.template "${final_path}/lstu.conf" -ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lstu.conf" -ynh_replace_string "__PATH__" "$path_url" "${final_path}/lstu.conf" -ynh_replace_string "__PORT__" "$port" "${final_path}/lstu.conf" -ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lstu.conf" -ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lstu.conf" -ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lstu.conf" -ynh_replace_string "__SELECTED_THEME__" "$theme" "${final_path}/lstu.conf" -ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.conf" - -ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf" +config="${final_path}/lstu.conf" +ynh_backup_if_checksum_is_different --file="$config" +cp ../conf/lstu.conf.template "$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$configf" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string="$theme" --target_file="$config" +ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string="$hashed_password" --target_file="$config" +ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lstu.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else - ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lstu.conf" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi -ynh_store_file_checksum "${final_path}/lstu.conf" +ynh_store_file_checksum --file="$config" #================================================= -# SECURING FILES AND DIRECTORIES -#================================================= - -chown -R www-data $final_path - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_print_info "Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# Install lstu's dependencies via carton +# BUILD LSU #================================================= +ynh_print_info --message="Building lstu..." pushd $final_path -carton install --deployment --without=sqlite --without=mysql + carton install --deployment --without=sqlite --without=mysql popd #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info "Upgrading logrotate configuration..." +ynh_print_info --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# SETUP SYSTEMD #================================================= +ynh_print_info --message="Upgrading systemd configuration..." -yunohost service add $app --log "/var/log/$app.log" +# Create a dedicated systemd config +ynh_add_systemd_config #================================================= -# RESTART LSTU +# GENERIC FINALIZATION #================================================= +# SECURING FILES AND DIRECTORIES +#================================================= +ynh_print_info --message="Securing files and directories..." -ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "systemd" +# Set permissions on app files +chown -R www-data $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_print_info --message="Upgrading SSOwat configuration..." -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. @@ -206,19 +225,25 @@ then fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') - ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" + ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" fi +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "systemd" + #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx -yunohost app ssowatconf +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Upgrade of $app completed" +ynh_print_info --message="Upgrade of $app completed" From 1dad5ffde13bdb4544056e657fedabb6e7a76f05 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 19 Apr 2020 21:54:21 +0200 Subject: [PATCH 02/30] Add arguments --- scripts/install | 2 +- scripts/remove | 2 +- scripts/upgrade | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/install b/scripts/install index 618c69a..63e226d 100644 --- a/scripts/install +++ b/scripts/install @@ -125,7 +125,7 @@ ynh_print_info --message="Configuring system user..." ynh_system_user_create --username=$app #================================================= -## Copy and fix variable into lstu config +# Copy and fix variable into lstu config #================================================= ynh_print_info --message="Configuring lstu..." diff --git a/scripts/remove b/scripts/remove index c5d7b72..e46d36b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -50,7 +50,7 @@ ynh_remove_systemd_config ynh_print_info --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_name=$db_name --db_user=$db_user +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/upgrade b/scripts/upgrade index 6c109c5..2d389b6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,28 +56,28 @@ if [ -z "$final_path" ]; then fi if [ -z "$db_pwd" ]; then - db_pwd=$(ynh_app_setting_get $app db_pwd) # Fix old db_pwd + db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) # Fix old db_pwd if [ -z "$db_pwd" ]; then - db_name=$(ynh_sanitize_dbid "$app") + db_name=$(ynh_sanitize_dbid --db_name="$app") db_user=$db_name # Initialize database and store postgres password for upgrade - ynh_psql_setup_db "$db_name" "$db_user" - ynh_app_setting_set "$app" db_name "$db_name" - db_pwd=$(ynh_app_setting_get $app psqlpwd) # Password created in ynh_psql_setup_db function + ynh_psql_setup_db --db_user="$db_user" --db_name="$db_name" + ynh_app_setting_set --app="$app" --key=db_name --value="$db_name" + db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh_psql_setup_db function else - ynh_app_setting_delete $app db_pwd - ynh_app_setting_set $app psqlpwd $db_pwd + ynh_app_setting_delete --app=$app --key=db_pwd + ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd fi fi if [ -z "$theme" ]; then theme="milligram" - ynh_app_setting_set $app theme $theme + ynh_app_setting_set --app=$app --key=theme --value=$theme fi if [ -z "$hashed_password" ]; then # Generate random password - password=$(ynh_string_random 8) + password=$(ynh_string_random --length=8) hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1) echo "The new version of LSTU provide an admin and a stats area which required a password." > mail_to_send @@ -86,7 +86,7 @@ if [ -z "$hashed_password" ]; then ynh_send_readme_to_admin --app_message="mail_to_send" --type="upgrade" - ynh_app_setting_set $app hashed_password $hashed_password + ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password fi #================================================= @@ -233,7 +233,7 @@ fi #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "systemd" +ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd" #================================================= # RELOAD NGINX From a8b4f0732996cef11665bb35752e47d36cdee290 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 20 Apr 2020 17:51:05 +0200 Subject: [PATCH 03/30] Fix install ./install: line 61: port: unbound variable --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 63e226d..7fc7205 100644 --- a/scripts/install +++ b/scripts/install @@ -57,9 +57,8 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url ynh_print_info --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=is_public --value=$is_public -ynh_app_setting_set --app=$app --key=port --value=$port ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=theme --value=$theme ynh_app_setting_set --app=$app --key=secret --value=$secret ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password @@ -73,6 +72,7 @@ ynh_print_info --message="Configuring firewall..." # Find an available port port=$(ynh_find_port --port=8095) +ynh_app_setting_set --app=$app --key=port --value=$port # Open this port ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port From 9732ae4a86a059710b44f396a4015e8c4eeba5bd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 01:30:07 +0200 Subject: [PATCH 04/30] missing = :/ --- scripts/install | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 7fc7205..f54a92b 100644 --- a/scripts/install +++ b/scripts/install @@ -73,7 +73,12 @@ ynh_print_info --message="Configuring firewall..." # Find an available port port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port -# Open this port + +# Optional: Expose this port publicly +# (N.B. : you only need to do this if the app actually needs to expose the port publicly. +# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) + +# Open the port ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port #================================================= @@ -131,20 +136,20 @@ ynh_print_info --message="Configuring lstu..." config="${final_path}/lstu.conf" cp ../conf/lstu.conf.template "$config" -ynh_replace_string --match_string="__DOMAIN__" --replace_string"$domain" --target_file="$config" -ynh_replace_string --match_string="__PATH__" --replace_string"$path_url" --target_file="$config" -ynh_replace_string --match_string="__PORT__" --replace_string"$port" --target_file="$config" -ynh_replace_string --match_string="__DB_NAME__" --replace_string"$db_name" --target_file="$config" -ynh_replace_string --match_string="__DB_USER__" --replace_string"$db_user" --target_file="$config" -ynh_replace_string --match_string="__DB_PWD__" --replace_string"$db_pwd" --target_file="$config" -ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string"$theme" --target_file="$config" -ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string"$hashed_password" --target_file="$config" -ynh_replace_string --match_string="__SECRET__" --replace_string"$secret" --target_file="$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" +ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string="$theme" --target_file="$config" +ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string="$hashed_password" --target_file="$config" +ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" if [ $is_public -eq 0 ]; then - ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string"" --target_file="$config" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else - ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string"#" --target_file="$config" + ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi ynh_store_file_checksum --file="$config" From e395c420f9227592118c3644f7a9f247b6558982 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 01:30:26 +0200 Subject: [PATCH 05/30] example_ynh to continue --- README.md | 5 +++-- conf/nginx.conf | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c5485ae..b5872c8 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,9 @@ Can the app be used by multiple users? **Yes** #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lstu%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lstu/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lstu%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lstu/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lstu%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lstu/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lstu%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lstu/) + **More information on the documentation page:** diff --git a/conf/nginx.conf b/conf/nginx.conf index 028fa01..a72f47f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,6 @@ -location __PATH__ { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } From 125f9790bff90cc812cb8e8d8081fc757dec2688 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 03:49:14 +0200 Subject: [PATCH 06/30] typo --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index f54a92b..cf6325f 100644 --- a/scripts/install +++ b/scripts/install @@ -208,7 +208,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= ynh_print_info --message="Configuring SSOwat..." -ynh_app_setting_set --app=$app --key=unprotected_uris--value= "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] then # If the app is private, only the shortened URLs are publics. From cc3d0587dbd7e3dae3ac13371e235925d1fa4d85 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 14:03:49 +0200 Subject: [PATCH 07/30] typo --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2d389b6..48e0aa7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -159,7 +159,7 @@ config="${final_path}/lstu.conf" ynh_backup_if_checksum_is_different --file="$config" cp ../conf/lstu.conf.template "$config" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" -ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$configf" +ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config" ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" From b8a312bd49bae197aa9264a1ff89db15b0210602 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 May 2020 11:05:42 +0200 Subject: [PATCH 08/30] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 02a052a..222076f 100644 --- a/check_process +++ b/check_process @@ -14,7 +14,7 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=7410eb674fc4670fcc0398e8e1d086e2560c7f28 + upgrade=1 from_commit=2d33783907d6de4486ac9e954ebc4b4028e11de8 backup_restore=1 multi_instance=1 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. From 09b8ac53554a0f449de0dabdb57217f5203ac826 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 May 2020 11:10:32 +0200 Subject: [PATCH 09/30] Fix change_url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 0949d17..8b90e29 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -148,7 +148,7 @@ ynh_store_file_checksum --file="$config" #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Starting hot deployment for Hypnotoad server" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" #================================================= # UPDATE SSOWAT From eeac5c6c1f9f313a80f573b46c540eed8eb068e7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 May 2020 01:49:48 +0200 Subject: [PATCH 10/30] Adding templates --- issue_template.md | 46 ++++++++++++++++++++++++++++++++++++++++ pull_request_template.md | 18 ++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 issue_template.md create mode 100644 pull_request_template.md diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..d20c2d8 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,46 @@ +--- +name: Bug report +about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* + - *Otherwise, the issue may be due to lstu itself. Refer to its documentation or repository for help.* + - *If you have a doubt, post here, we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +**Describe the bug** +*A clear and concise description of what the bug is.* + +**Versions** +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +**To Reproduce** +*Steps to reproduce the behavior.* +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install lstu + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '....'* + 3. *Scroll down to '....'* + 4. *See error* + +**Expected behavior** +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +**Logs** +*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..95a0350 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Package_check results +--- +*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* + +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/lstu_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/lstu_ynh%20PR-NUM-%20(USERNAME)/) From 1e416359f0852d0a13083897e508466ea01afb36 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 May 2020 21:36:47 +0200 Subject: [PATCH 11/30] Apply last example_ynh --- scripts/backup | 41 +++++++++++++++-------------------- scripts/change_url | 19 ++++++++--------- scripts/install | 53 +++++++++++++++++++++++----------------------- scripts/remove | 27 ++++++++++++----------- scripts/restore | 33 +++++++++++++++-------------- scripts/upgrade | 36 +++++++++++++++---------------- 6 files changed, 100 insertions(+), 109 deletions(-) diff --git a/scripts/backup b/scripts/backup index 23329cc..63ca8f7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,13 +6,13 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { true @@ -32,28 +32,37 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_print_info --message="Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app.service" + #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= @@ -61,22 +70,6 @@ ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= -ynh_print_info --message="Backing up logrotate configuration..." - -ynh_backup --src_path="/etc/logrotate.d/$app" - -#================================================= -# BACKUP SYSTEMD -#================================================= -ynh_print_info --message="Backing up systemd configuration..." - -ynh_backup --src_path="/etc/systemd/system/$app.service" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 0dfd5f0..ac3a73c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= -ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -25,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -43,7 +42,7 @@ hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=1 # Backup the current version of the app ynh_backup_before_upgrade @@ -78,14 +77,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -116,7 +115,7 @@ fi #================================================= # SETUP LSTU #================================================= -ynh_script_progression --message="Updating lstu configuration..." +ynh_script_progression --message="Updating lstu configuration..." --weight=1 domain="$new_domain" path_url="$new_path" @@ -146,14 +145,14 @@ ynh_store_file_checksum --file="$config" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" #================================================= # UPDATE SSOWAT #================================================= -ynh_script_progression --message="Reconfigure SSOwat" +ynh_script_progression --message="Reconfigure SSOwat" --weight=1 if [ $is_public -eq 0 ] then @@ -170,7 +169,7 @@ fi #================================================= # 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 @@ -178,4 +177,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index 5fd1153..e6693d4 100644 --- a/scripts/install +++ b/scripts/install @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." +ynh_script_progression --message="Managing script failure..." --weight=1 ynh_clean_setup () { ynh_clean_check_starting @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_print_info --message="Retrieving arguments from the manifest..." +ynh_script_progression --message="Retrieving arguments from the manifest..." --weight=1 domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -38,23 +38,18 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # 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 test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path --path_url=$path_url) - -# Check web path availability -ynh_webpath_available --domain=$domain --path_url=$path_url # Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Configuring firewall..." +ynh_script_progression --message="Configuring firewall..." --weight=1 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -68,7 +63,7 @@ ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=1 # Find an available port port=$(ynh_find_port --port=8095) @@ -84,7 +79,9 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." --weight=1 + +ynh_install_app_dependencies $pkg_dependencies # Install Carton echo yes | cpanm Carton @@ -92,7 +89,7 @@ echo yes | cpanm Carton #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 # Create postgresql database ynh_psql_test_if_first_run @@ -105,7 +102,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh #================================================= # 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 # Download, check integrity, uncompress and patch the source from app.src @@ -114,7 +111,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # 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 ynh_add_nginx_config @@ -122,15 +119,15 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user ynh_system_user_create --username=$app #================================================= -# Copy and fix variable into lstu config +# CONFIGURE LSTU #================================================= -ynh_script_progression --message="Configuring lstu..." +ynh_script_progression --message="Configuring lstu..." --weight=1 config="${final_path}/lstu.conf" cp ../conf/lstu.conf.template "$config" @@ -143,26 +140,28 @@ ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --targ ynh_replace_string --match_string="__SELECTED_THEME__" --replace_string="$theme" --target_file="$config" ynh_replace_string --match_string="__PASSWORD_HASHED__" --replace_string="$hashed_password" --target_file="$config" ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config" + if [ $is_public -eq 0 ]; then ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="" --target_file="$config" else ynh_replace_string --match_string="__IS_PUBLIC__" --replace_string="#" --target_file="$config" fi + ynh_store_file_checksum --file="$config" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config #================================================= -# BUILD LSTU +# INSTALL LSTU #================================================= -ynh_script_progression --message="Installing lstu..." +ynh_script_progression --message="Installing lstu..." --weight=1 pushd $final_path carton install --deployment --without=sqlite --without=mysql @@ -173,7 +172,7 @@ popd #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files chown -R www-data $final_path @@ -181,7 +180,7 @@ chown -R www-data $final_path #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -189,14 +188,14 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" @@ -204,7 +203,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." --weight=1 ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] @@ -222,7 +221,7 @@ fi #================================================= # 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 @@ -230,4 +229,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 63cf3ff..7c6918d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -27,19 +27,18 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_print_info --message="Removing service integration in YunoHost..." # 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 >/dev/null then - ynh_print_info --message="Removing $app service..." + ynh_script_progression --message="Removing $app service..." --weight=1 yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service" +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -47,7 +46,7 @@ ynh_remove_systemd_config #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_print_info --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 ynh_psql_remove_db --db_user=$db_user --db_name=$db_name @@ -55,7 +54,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -63,7 +62,7 @@ ynh_remove_app_dependencies #================================================= # 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 ynh_secure_remove --file="$final_path" @@ -71,7 +70,7 @@ ynh_secure_remove --file="$final_path" #================================================= # 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 ynh_remove_nginx_config @@ -79,7 +78,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration" +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate @@ -87,11 +86,10 @@ ynh_remove_logrotate #================================================= # CLOSE A PORT #================================================= -ynh_print_info --message="Closing a port..." if yunohost firewall list | grep -q "\- $port$" then - ynh_print_info --message="Closing port $port..." + ynh_script_progression --message="Closing port $port..." --weight=1 ynh_exec_warn_less yunohost firewall disallow TCP $port fi @@ -100,8 +98,9 @@ fi #================================================= # REMOVE LOG FILES #================================================= -ynh_script_progression --message="Removing log files..." +ynh_script_progression --message="Removing log files..." --weight=1 +# Remove the log files ynh_secure_remove --file="/var/log/$app.log" #================================================= @@ -109,7 +108,7 @@ ynh_secure_remove --file="/var/log/$app.log" #================================================= # 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 ynh_system_user_delete --username=$app @@ -118,4 +117,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 6a71188..5b844f1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,13 +6,13 @@ # IMPORT GENERIC HELPERS #================================================= +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -36,7 +36,7 @@ db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --weight=1 ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -48,21 +48,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Restoring the nginx configuration..." +ynh_print_info --message="Restoring the nginx configuration..." --weight=1 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..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$final_path" #================================================= # 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) ynh_system_user_create --username=$app @@ -70,7 +70,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= -ynh_print_info --message="Restoring user rights..." +ynh_print_info --message="Restoring user rights..." --weight=1 # Restore permissions on app files chown -R www-data $final_path @@ -80,7 +80,7 @@ chown -R www-data $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Reinstalling dependencies..." +ynh_print_info --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -91,17 +91,18 @@ echo yes | cpanm Carton #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Restoring the PostregSQL database..." +ynh_print_info --message="Restoring the PostregSQL database..." --weight=1 + -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_test_if_first_run +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service @@ -109,21 +110,21 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_print_info --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_print_info --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_print_info --message="Restoring the logrotate configuration..." +ynh_print_info --message="Restoring the logrotate configuration..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" @@ -132,7 +133,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # 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 @@ -140,4 +141,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 2c82a36..1bbc208 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME @@ -31,14 +31,14 @@ hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info --message="Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -92,7 +92,7 @@ fi #================================================= # 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 ynh_backup_before_upgrade @@ -109,7 +109,7 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" @@ -119,7 +119,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_print_info --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -128,7 +128,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -136,14 +136,14 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies #================================================= # 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) ynh_system_user_create --username=$app @@ -153,7 +153,7 @@ ynh_system_user_create --username=$app #================================================= # UPGRADE LSTU CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading lstu configuration..." +ynh_script_progression --message="Upgrading lstu configuration..." --weight=1 config="${final_path}/lstu.conf" ynh_backup_if_checksum_is_different --file="$config" @@ -180,7 +180,7 @@ ynh_store_file_checksum --file="$config" #================================================= # BUILD LSU #================================================= -ynh_print_info --message="Building lstu..." +ynh_script_progression --message="Building lstu..." --weight=1 pushd $final_path carton install --deployment --without=sqlite --without=mysql @@ -189,7 +189,7 @@ popd #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -197,7 +197,7 @@ ynh_use_logrotate --non-append #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." +ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -207,7 +207,7 @@ ynh_add_systemd_config #================================================= # SECURING FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions on app files chown -R www-data $final_path @@ -215,7 +215,7 @@ chown -R www-data $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] @@ -233,14 +233,14 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd" #================================================= # 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 @@ -248,4 +248,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" --last From 3bf4fd5830458457cace73de91c0de54c2909990 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 29 May 2020 12:37:16 +0200 Subject: [PATCH 12/30] Fix restore --- scripts/restore | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/restore b/scripts/restore index 5b844f1..8e7bca4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -48,7 +48,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Restoring the nginx configuration..." --weight=1 +ynh_script_progression --message="Restoring the nginx configuration..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -70,7 +70,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= -ynh_print_info --message="Restoring user rights..." --weight=1 +ynh_script_progression --message="Restoring user rights..." --weight=1 # Restore permissions on app files chown -R www-data $final_path @@ -80,7 +80,7 @@ chown -R www-data $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Reinstalling dependencies..." --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -91,7 +91,7 @@ echo yes | cpanm Carton #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_print_info --message="Restoring the PostregSQL database..." --weight=1 +ynh_script_progression --message="Restoring the PostregSQL database..." --weight=1 ynh_psql_test_if_first_run @@ -110,21 +110,21 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_print_info --message="Restoring the logrotate configuration..." --weight=1 +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" From d16fe4b48f1da05486150079c3de682a40daac67 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:18:46 +0200 Subject: [PATCH 13/30] apply last example_ynh --- scripts/change_url | 2 +- scripts/install | 6 ++---- scripts/remove | 2 +- scripts/upgrade | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index ac3a73c..50a1c52 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,7 +29,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Needed for lstu conf +# Add settings here as needed by your application port=$(ynh_app_setting_get --app=$app --key=port) is_public=$(ynh_app_setting_get --app=$app --key=is_public) db_name=$(ynh_app_setting_get --app=$app --key=db_name) diff --git a/scripts/install b/scripts/install index e6693d4..abd0168 100644 --- a/scripts/install +++ b/scripts/install @@ -12,7 +12,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 @@ -23,7 +22,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=$YNH_APP_ARG_PATH @@ -49,7 +47,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=1 +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=path --value=$path_url @@ -63,7 +61,7 @@ ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression --message="Configuring firewall..." --weight=1 # Find an available port port=$(ynh_find_port --port=8095) diff --git a/scripts/remove b/scripts/remove index 7c6918d..4ff690b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -70,7 +70,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration" --weight=1 +ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config diff --git a/scripts/upgrade b/scripts/upgrade index 1bbc208..9a055bd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,7 +31,7 @@ hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) From 311c2997a9690214bcb28f0f1ea11bcfaf5bdb22 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:23:07 +0200 Subject: [PATCH 14/30] Update check_process --- check_process | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/check_process b/check_process index 222076f..0221d93 100644 --- a/check_process +++ b/check_process @@ -14,6 +14,7 @@ setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=7410eb674fc4670fcc0398e8e1d086e2560c7f28 upgrade=1 from_commit=2d33783907d6de4486ac9e954ebc4b4028e11de8 backup_restore=1 multi_instance=1 @@ -24,3 +25,8 @@ ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto +;;; Upgrade options + ; commit=7410eb674fc4670fcc0398e8e1d086e2560c7f28 + name=0.21-4~ynh2 + ; commit=2d33783907d6de4486ac9e954ebc4b4028e11de8 + name=0.21-4~ynh4 From 3821e62c8c73663d4cfb3ca0d25dba2f18aaaabc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:28:10 +0200 Subject: [PATCH 15/30] Changing version number --- README.md | 2 +- manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5872c8..cfc0dc3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to Lstu means Let's Shorten That Url. -**Shipped version:** 0.21-4 +**Shipped version:** 0.22-0 ## Screenshots diff --git a/manifest.json b/manifest.json index 53988ea..2bf0e04 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "URL Shortener", "fr": "Raccoursisseur d'URL" }, - "version": "0.21-4~ynh4", + "version": "0.22-0~ynh1", "url": "https://lstu.fr", "license": "WTFPL", "maintainer": { From c4484e237e3ea4451500489177c5bc1c30783794 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:28:48 +0200 Subject: [PATCH 16/30] removing --weight=1 --- scripts/change_url | 16 ++++++++-------- scripts/install | 34 +++++++++++++++++----------------- scripts/remove | 22 +++++++++++----------- scripts/restore | 26 +++++++++++++------------- scripts/upgrade | 34 +++++++++++++++++----------------- 5 files changed, 66 insertions(+), 66 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 50a1c52..1c73162 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -42,7 +42,7 @@ hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=1 +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -77,14 +77,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --weight=1 +ynh_script_progression --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -115,7 +115,7 @@ fi #================================================= # SETUP LSTU #================================================= -ynh_script_progression --message="Updating lstu configuration..." --weight=1 +ynh_script_progression --message="Updating lstu configuration..." domain="$new_domain" path_url="$new_path" @@ -145,14 +145,14 @@ ynh_store_file_checksum --file="$config" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" #================================================= # UPDATE SSOWAT #================================================= -ynh_script_progression --message="Reconfigure SSOwat" --weight=1 +ynh_script_progression --message="Reconfigure SSOwat" if [ $is_public -eq 0 ] then @@ -169,7 +169,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index abd0168..292ae96 100644 --- a/scripts/install +++ b/scripts/install @@ -36,7 +36,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +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" @@ -47,7 +47,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +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 @@ -61,7 +61,7 @@ ynh_app_setting_set --app=$app --key=hashed_password --value=$hashed_password #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=1 +ynh_script_progression --message="Configuring firewall..." # Find an available port port=$(ynh_find_port --port=8095) @@ -77,7 +77,7 @@ ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies @@ -87,7 +87,7 @@ echo yes | cpanm Carton #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 +ynh_script_progression --message="Creating a PostgreSQL database..." # Create postgresql database ynh_psql_test_if_first_run @@ -100,7 +100,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # Password created in ynh #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +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 @@ -109,7 +109,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=1 +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -117,7 +117,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app @@ -125,7 +125,7 @@ ynh_system_user_create --username=$app #================================================= # CONFIGURE LSTU #================================================= -ynh_script_progression --message="Configuring lstu..." --weight=1 +ynh_script_progression --message="Configuring lstu..." config="${final_path}/lstu.conf" cp ../conf/lstu.conf.template "$config" @@ -151,7 +151,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -159,7 +159,7 @@ ynh_add_systemd_config #================================================= # INSTALL LSTU #================================================= -ynh_script_progression --message="Installing lstu..." --weight=1 +ynh_script_progression --message="Installing lstu..." pushd $final_path carton install --deployment --without=sqlite --without=mysql @@ -170,7 +170,7 @@ popd #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 +ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R www-data $final_path @@ -178,7 +178,7 @@ chown -R www-data $final_path #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -186,14 +186,14 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" @@ -201,7 +201,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring SSOwat..." ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] @@ -219,7 +219,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 4ff690b..c5812fb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -31,14 +31,14 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # 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 >/dev/null then - ynh_script_progression --message="Removing $app service..." --weight=1 + ynh_script_progression --message="Removing $app service..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -46,7 +46,7 @@ ynh_remove_systemd_config #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 +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 @@ -54,7 +54,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -62,7 +62,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -70,7 +70,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --weight=1 +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -78,7 +78,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -89,7 +89,7 @@ ynh_remove_logrotate if yunohost firewall list | grep -q "\- $port$" then - ynh_script_progression --message="Closing port $port..." --weight=1 + ynh_script_progression --message="Closing port $port..." ynh_exec_warn_less yunohost firewall disallow TCP $port fi @@ -98,7 +98,7 @@ fi #================================================= # REMOVE LOG FILES #================================================= -ynh_script_progression --message="Removing log files..." --weight=1 +ynh_script_progression --message="Removing log files..." # Remove the log files ynh_secure_remove --file="/var/log/$app.log" @@ -108,7 +108,7 @@ ynh_secure_remove --file="/var/log/$app.log" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app diff --git a/scripts/restore b/scripts/restore index 8e7bca4..bf6f70f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=1 +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -36,7 +36,7 @@ db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +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}" @@ -48,21 +48,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the 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=1 +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=1 +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app @@ -70,7 +70,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= -ynh_script_progression --message="Restoring user rights..." --weight=1 +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R www-data $final_path @@ -80,7 +80,7 @@ chown -R www-data $final_path #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -91,7 +91,7 @@ echo yes | cpanm Carton #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostregSQL database..." --weight=1 +ynh_script_progression --message="Restoring the PostregSQL database..." ynh_psql_test_if_first_run @@ -102,7 +102,7 @@ ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./d #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service @@ -110,21 +110,21 @@ systemctl enable $app.service #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/production.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 +ynh_script_progression --message="Restoring the logrotate configuration..." ynh_restore_file --origin_path="/etc/logrotate.d/$app" @@ -133,7 +133,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 9a055bd..cbf7a4a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -31,14 +31,14 @@ hashed_password=$(ynh_app_setting_get --app=$app --key=hashed_password) #================================================= # 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..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -92,7 +92,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +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 @@ -109,7 +109,7 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" @@ -119,7 +119,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" @@ -128,7 +128,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -136,14 +136,14 @@ ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app @@ -153,7 +153,7 @@ ynh_system_user_create --username=$app #================================================= # UPGRADE LSTU CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading lstu configuration..." --weight=1 +ynh_script_progression --message="Upgrading lstu configuration..." config="${final_path}/lstu.conf" ynh_backup_if_checksum_is_different --file="$config" @@ -180,7 +180,7 @@ ynh_store_file_checksum --file="$config" #================================================= # BUILD LSU #================================================= -ynh_script_progression --message="Building lstu..." --weight=1 +ynh_script_progression --message="Building lstu..." pushd $final_path carton install --deployment --without=sqlite --without=mysql @@ -189,7 +189,7 @@ popd #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append @@ -197,7 +197,7 @@ ynh_use_logrotate --non-append #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config @@ -207,7 +207,7 @@ ynh_add_systemd_config #================================================= # SECURING FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=1 +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R www-data $final_path @@ -215,7 +215,7 @@ chown -R www-data $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 +ynh_script_progression --message="Upgrading SSOwat configuration..." ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" if [ $is_public -eq 0 ] @@ -233,14 +233,14 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action=reload --line_match="Reloaded Shortened URLs service." --log_path="systemd" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=1 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload From 440c6c344f95f3de01dcf81a031d9d668348618f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:30:23 +0200 Subject: [PATCH 17/30] removing --last --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1c73162..4972e18 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -177,4 +177,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 292ae96..4b42ba2 100644 --- a/scripts/install +++ b/scripts/install @@ -227,4 +227,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 c5812fb..46b0333 100644 --- a/scripts/remove +++ b/scripts/remove @@ -117,4 +117,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 bf6f70f..f1db839 100644 --- a/scripts/restore +++ b/scripts/restore @@ -141,4 +141,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 cbf7a4a..52c9add 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -248,4 +248,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" From 35bc6521143ab9c36e47210cef5ec6bb1df911e2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:33:41 +0200 Subject: [PATCH 18/30] missing --length= --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 4b42ba2..a34f0e7 100644 --- a/scripts/install +++ b/scripts/install @@ -28,7 +28,7 @@ path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC theme=$YNH_APP_ARG_THEME password=$YNH_APP_ARG_PASSWORD -secret=$(ynh_string_random 24) +secret=$(ynh_string_random --length=24) hashed_password=$(echo -n $password | sha256sum | cut -d' ' -f1) app=$YNH_APP_INSTANCE_NAME From d9da710ff758314914bd21d31dc61fb89b0a80b6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:37:11 +0200 Subject: [PATCH 19/30] Adding badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cfc0dc3..f6c49e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Lstu app for YunoHost -[![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) +[![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) [![Install lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lstu) > *This package allow you to install lstu quickly and simply on a YunoHost server. From d10fe1a04e3f3234567aea60bf66c201a1fb23f1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:45:34 +0200 Subject: [PATCH 20/30] Apply example_ynh on README --- README.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f6c49e2..a07ee34 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,10 @@ [![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) [![Install lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lstu) -> *This package allow you to install lstu quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install lstu quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview - Lstu means Let's Shorten That Url. **Shipped version:** 0.22-0 @@ -22,7 +21,7 @@ Lstu means Let's Shorten That Url. ## Configuration -How to configure this app: a plain file with SSH. +How to configure this app: a plain file at `/var/www/lstu/lstu.conf` with SSH. ## Documentation @@ -30,34 +29,32 @@ How to configure this app: a plain file with SSH. ## YunoHost specific features -#### Multi-users support +#### Multi-user support Are LDAP and HTTP auth supported? **Yes** Can the app be used by multiple users? **Yes** #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lstu%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lstu/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lstu%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lstu/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lstu%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lstu/) - -**More information on the documentation page:** +**More info on the documentation page:** https://yunohost.org/packaging_apps ## Links * Report a bug: https://github.com/YunoHost-Apps/lstu_ynh/issues - * App website: https://framagit.org/fiat-tux/hat-softwares/lstu + * Upstream app repository: Link to the official repository of the upstream app. * YunoHost website: https://yunohost.org/ --- -Developers info +Developer info ---------------- -**Only if you want to use a testing branch for coding, instead of merging directly into master.** -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/lstu_ynh/tree/testing). To try the testing branch, please proceed like that. ``` @@ -65,6 +62,7 @@ sudo yunohost app install https://github.com/YunoHost-Apps/lstu_ynh/tree/testing or sudo yunohost app upgrade lstu -u https://github.com/YunoHost-Apps/lstu_ynh/tree/testing --debug ``` + ## Todo - [ ] Allow to choose the database (sqlite or PostgreSQL) From 4d5944ad62e0642496688f283b656e97d9e62e12 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:50:56 +0200 Subject: [PATCH 21/30] spacing --- scripts/restore | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index f1db839..478bacd 100644 --- a/scripts/restore +++ b/scripts/restore @@ -93,7 +93,6 @@ echo yes | cpanm Carton #================================================= ynh_script_progression --message="Restoring the PostregSQL database..." - ynh_psql_test_if_first_run db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd From 934affc3ae0fefa58d27e568585a20ee6870b4ed Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:52:59 +0200 Subject: [PATCH 22/30] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a07ee34..2c92472 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Lstu app for YunoHost [![Integration level](https://dash.yunohost.org/integration/lstu.svg)](https://dash.yunohost.org/appci/app/lstu) ![](https://ci-apps.yunohost.org/ci/badges/lstu.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/lstu.maintain.svg) -[![Install lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lstu) +[![Install Lstu with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=lstu) -> *This package allows you to install lstu quickly and simply on a YunoHost server. +> *This package allows you to install Lstu quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview From 6377755b7ca876f01315de6701792070e8732f49 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 15:55:33 +0200 Subject: [PATCH 23/30] Missing ynh_psql_test_if_first_run during upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 52c9add..f73a794 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,6 +58,7 @@ fi if [ -z "$db_pwd" ]; then db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) # Fix old db_pwd if [ -z "$db_pwd" ]; then + ynh_psql_test_if_first_run db_name=$(ynh_sanitize_dbid --db_name="$app") db_user=$db_name # Initialize database and store postgres password for upgrade From 7dc14e6523783f6c459da91da1e38ed7eaea255e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 16:42:42 +0200 Subject: [PATCH 24/30] few modifications --- README.md | 1 - scripts/change_url | 22 +++++++++++----------- scripts/install | 18 ++++++++++-------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 2c92472..c1cc953 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Can the app be used by multiple users? **Yes** * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/lstu%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lstu/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/lstu%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lstu/) - **More info on the documentation page:** https://yunohost.org/packaging_apps diff --git a/scripts/change_url b/scripts/change_url index 4972e18..d81e2c0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -113,9 +113,9 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# SETUP LSTU +# CONFIGURE LSTU #================================================= -ynh_script_progression --message="Updating lstu configuration..." +ynh_script_progression --message="Configuring lstu..." domain="$new_domain" path_url="$new_path" @@ -140,15 +140,6 @@ else fi ynh_store_file_checksum --file="$config" -#================================================= -# GENERIC FINALISATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" - #================================================= # UPDATE SSOWAT #================================================= @@ -166,6 +157,15 @@ then ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" fi +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Server available at" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index a34f0e7..6f4bd70 100644 --- a/scripts/install +++ b/scripts/install @@ -122,6 +122,8 @@ ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app +#================================================= +# SPECIFIC SETUP #================================================= # CONFIGURE LSTU #================================================= @@ -148,14 +150,6 @@ fi ynh_store_file_checksum --file="$config" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # INSTALL LSTU #================================================= @@ -165,6 +159,14 @@ pushd $final_path carton install --deployment --without=sqlite --without=mysql popd +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= From 99430585d62e7a838f04959d162468339f33d30b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Jun 2020 22:58:18 +0200 Subject: [PATCH 25/30] remove upgrade from 0.21-4~ynh2 because install on buster fail --- check_process | 3 --- 1 file changed, 3 deletions(-) diff --git a/check_process b/check_process index 0221d93..21f1451 100644 --- a/check_process +++ b/check_process @@ -14,7 +14,6 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=7410eb674fc4670fcc0398e8e1d086e2560c7f28 upgrade=1 from_commit=2d33783907d6de4486ac9e954ebc4b4028e11de8 backup_restore=1 multi_instance=1 @@ -26,7 +25,5 @@ # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto ;;; Upgrade options - ; commit=7410eb674fc4670fcc0398e8e1d086e2560c7f28 - name=0.21-4~ynh2 ; commit=2d33783907d6de4486ac9e954ebc4b4028e11de8 name=0.21-4~ynh4 From d47a640f476f5bff191bee89b3a7ca36eb63a49d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 3 Jun 2020 21:11:45 +0200 Subject: [PATCH 26/30] Update remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 46b0333..f66f57f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -49,7 +49,7 @@ ynh_remove_systemd_config 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 +ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" #================================================= # REMOVE DEPENDENCIES From 06ae7b06a596ad12f5c1d96299cef80cd33871b2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 3 Jun 2020 21:11:50 +0200 Subject: [PATCH 27/30] Update restore --- scripts/restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restore b/scripts/restore index 478bacd..98e822c 100644 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -94,9 +95,8 @@ echo yes | cpanm Carton ynh_script_progression --message="Restoring the PostregSQL database..." ynh_psql_test_if_first_run -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE SYSTEMD From 5bbc46991a893ed1305b7295f2ff9ed550426191 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Jun 2020 02:20:06 +0200 Subject: [PATCH 28/30] Update scripts/actions/change_theme Co-authored-by: Kayou --- scripts/actions/change_theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/change_theme b/scripts/actions/change_theme index 979b6ec..b806867 100755 --- a/scripts/actions/change_theme +++ b/scripts/actions/change_theme @@ -28,7 +28,7 @@ theme_old=$(ynh_app_setting_get $app theme) if [ "$theme" == "$theme_old" ] then - ynh_die --message="Same theme." 0 + ynh_die --message="Same theme." --ret_code=0 fi #================================================= From 23130ec33d653b47deddaab87cf41835fef7e885 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Jun 2020 02:20:13 +0200 Subject: [PATCH 29/30] Update scripts/actions/change_password Co-authored-by: Kayou --- scripts/actions/change_password | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/change_password b/scripts/actions/change_password index 212c0d0..7c00784 100755 --- a/scripts/actions/change_password +++ b/scripts/actions/change_password @@ -29,7 +29,7 @@ hashed_password_old=$(ynh_app_setting_get $app hashed_password) if [ "$hashed_password" == "$hashed_password_old" ] then - ynh_die --message="Same password." 0 + ynh_die --message="Same password." --ret_code=0 fi #================================================= From e318727e47d89f9bdc25f51fc7d2cb777aa7bcca Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Jun 2020 02:20:22 +0200 Subject: [PATCH 30/30] Update scripts/actions/public_private Co-authored-by: Kayou --- scripts/actions/public_private | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 3a8a6a1..72f7555 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -41,7 +41,7 @@ is_public_old=$(ynh_app_setting_get $app is_public) if [ $is_public -eq $is_public_old ] then - ynh_die --message="is_public is already set as $is_public." 0 + ynh_die --message="is_public is already set as $is_public." --ret_code=0 fi #=================================================