From 5be4ba01d776e50f2479b0fb2027aec383bc4020 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 15 Aug 2021 23:50:41 +0200 Subject: [PATCH] Fix --- check_process | 13 ++++--------- conf/nginx.conf | 1 + manifest.json | 18 +++--------------- scripts/_common.sh | 12 ------------ scripts/install | 33 ++++++++++++++++----------------- scripts/upgrade | 9 --------- 6 files changed, 24 insertions(+), 62 deletions(-) diff --git a/check_process b/check_process index 089936a..737ee07 100644 --- a/check_process +++ b/check_process @@ -1,14 +1,9 @@ -# See here for more informations -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/" (PATH) - is_public=1 (PUBLIC|public=1|private=0) - port="9980" (PORT) + domain="domain.tld" + path="/" + is_public=1 + port="9980" ; Checks pkg_linter=1 setup_sub_dir=0 diff --git a/conf/nginx.conf b/conf/nginx.conf index ff90445..819befc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,3 +1,4 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { # Path to source diff --git a/manifest.json b/manifest.json index 351cf70..016cced 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "redmine", "packaging_format": 1, "description": { - "en": "Flexible project management web application.", - "fr": "Gestionnaire de projet flexible sous forme d'application web." + "en": "Flexible project management web application", + "fr": "Gestionnaire de projet flexible sous forme d'application web" }, "version": "4.1.1", "url": "https://www.redmine.org/", @@ -14,7 +14,7 @@ "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.2.4" }, "multi_instance": false, "services": [ @@ -24,29 +24,17 @@ "install": [{ "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Redmine", - "fr": "Choisissez un nom de domaine pour Redmine" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Redmine /red is accepted", - "fr": "Choisissez un chemin pour Redmine /red est accepté" - }, "example": "/red", "default": "/red" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public site?", - "fr": "Est-ce un site public ?" - }, "default": true } ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 45b85de..dfbdabc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -19,18 +19,6 @@ BUNDLER_VERSION="2.2.3" # EXPERIMENTAL HELPERS #================================================= -# Execute a command as another user -# usage: ynh_exec_as USER COMMAND [ARG ...] -ynh_exec_as() { - local USER=$1 - shift 1 - - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} #================================================= # FUTURE OFFICIAL HELPERS diff --git a/scripts/install b/scripts/install index abd313a..5195cfb 100644 --- a/scripts/install +++ b/scripts/install @@ -36,9 +36,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --time --weight=1 -### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app" -final_path=/opt/$app +final_path=/opt/yunohost/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -65,14 +63,14 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --time --weight=1 +ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_install_app_dependencies $pkg_dependencies #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing Rails & Bunlder..." --time --weight=1 +ynh_script_progression --message="Installing Rails & Bunlder..." --weight=1 ynh_install_ruby --ruby_version=$RUBY_VERSION @@ -91,32 +89,33 @@ ynh_psql_create_db $db_name $db_name $db_pwd #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Create dedicated user..." +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Installing Redmine..." +ynh_script_progression --message="Setting up source files..." --weight=1 -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" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info "Install Redmine Conffiguration..." +ynh_script_progression --message="Adding a configuration file..." --weight=1 -cp -a ../conf/database.example.yml $final_path/config/database.yml - -#ynh_replace_string "2.5.3" "2.3.3" "/opt/redmine/Gemfile" -ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/config/database.yml" -ynh_replace_string "__DB_PASSWORD__" "$db_pwd" "$final_path/config/database.yml" -ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/config/database.yml" +ynh_add_config --template="../conf/database.example.yml" --destination="$final_path/config/database.yml" +chmod 400 "$final_path/config/database.yml" +chown $app:$app "$final_path/config/database.yml" #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/upgrade b/scripts/upgrade index ea2b02d..b494500 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,15 +26,6 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= ynh_print_info "Ensuring downward compatibility..." -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 - is_public=0 -fi - # If final_path doesn't exist, create it if [ -z $final_path ]; then final_path=/opt/$app