From b18df666e756ddc57a52780c4cdcba31a3e31118 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 8 Mar 2019 00:46:02 +0100 Subject: [PATCH 1/5] Misc tweaks --- scripts/install | 87 ++++++++++--------------------------------------- scripts/remove | 10 ------ scripts/restore | 2 ++ scripts/upgrade | 20 ++++++------ 4 files changed, 30 insertions(+), 89 deletions(-) diff --git a/scripts/install b/scripts/install index 90daf64..4501493 100755 --- a/scripts/install +++ b/scripts/install @@ -25,22 +25,11 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4, ... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names, ... -app=$YNH_APP_INSTANCE_NAME - #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -54,9 +43,6 @@ ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - # Register (book) web path ynh_webpath_register $app $domain $path_url @@ -68,37 +54,21 @@ ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_print_info "Configuring firewall..." - -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script +ynh_app_setting_set $app final_path $final_path # Find a free port port=$(ynh_find_port 8095) -# Open this port -#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port ynh_app_setting_set $app port $port +# Registering db name +db_name=$(ynh_sanitize_dbid $app) +ynh_app_setting_set $app db_name $db_name + #================================================= # INSTALL DEPENDENCIES #================================================= ynh_print_info "Installing dependencies..." -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - ynh_print_info "Installing nodejs ..." ynh_install_nodejs 8.9.3 @@ -114,37 +84,27 @@ ynh_print_info "Starting mongodb ..." systemctl enable mongodb systemctl restart mongodb -#================================================= -# CREATE A MONGODB DATABASE -#================================================= -ynh_print_info "Creating a MongoDB database..." - -### Use these lines if you need a database for the application. -### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. -### The password will be stored as 'mysqlpwd' into the app settings, -### and will be available as $db_pwd -### If you're not using these lines: -### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script -### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script -### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script - -db_name=$(ynh_sanitize_dbid $app) -ynh_app_setting_set $app db_name $db_name -#ynh_mysql_setup_db $db_name $db_name - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_print_info "Setting up wekan source files..." ### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### downloaded from an upstream source, like a git repository. ### `ynh_setup_source` use the file conf/app.src -ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" +ynh_print_info "Installing wekan npm dependencies ..." + +# Install wekan dependencies +chown -R $app $final_path +pushd $final_path/programs/server + ynh_use_nodejs + npm install +popd + #================================================= # NGINX CONFIGURATION #================================================= @@ -165,18 +125,6 @@ ynh_system_user_create $app "$final_path" #================================================= # SPECIFIC SETUP -#================================================= -# INSTALL WEKAN NPM DEPENDENCIES -#================================================= -ynh_print_info "Installing wekan npm dependencies ..." - -# Install wekan dependencies -chown -R $app $final_path -pushd $final_path/programs/server - ynh_use_nodejs - npm install -popd - #================================================= # SETUP SYSTEMD #================================================= @@ -206,7 +154,7 @@ ynh_add_systemd_config #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_print_info "Fixing permissions ..." +ynh_print_info "Configuring file permissions ..." ### For security reason, any app should set the permissions to root: before anything else. ### Then, if write authorization is needed, any access should be given only to directories @@ -253,6 +201,7 @@ systemctl reload nginx #================================================= # START SERVICE #================================================= +ynh_print_info "Now starting Wekan service..." ynh_systemd_action --action=start --service_name=$app --log_path="systemd" --line_match="Finishing add-custom-html-before-body-end migration" sleep 10 diff --git a/scripts/remove b/scripts/remove index f08fad7..9e7b861 100755 --- a/scripts/remove +++ b/scripts/remove @@ -82,16 +82,6 @@ ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_print_info "Closing port $port" - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 11c87b7..837b197 100644 --- a/scripts/restore +++ b/scripts/restore @@ -106,6 +106,7 @@ mongorestore --db $db_name ./dump/$db_name ynh_print_info "Restoring the systemd configuration..." ynh_restore_file "/etc/systemd/system/$app.service" +systemctl daemon-reload systemctl enable $app.service #================================================= @@ -127,6 +128,7 @@ systemctl reload nginx #================================================= # START SERVICE #================================================= +ynh_print_info "Now starting Wekan service..." ynh_systemd_action --action=start --service_name=$app --log_path="systemd" sleep 10 diff --git a/scripts/upgrade b/scripts/upgrade index 4f48cfa..be075db 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) port=$(ynh_app_setting_get $app port) +# Previous versions of the app did not have the db_name setting if [ -z "$db_name" ] then db_name=$app @@ -69,12 +70,11 @@ fi if ynh_version_gt "0.77-2" "${previous_version}" ; then ynh_install_nodejs 8.9.3 - ynh_use_nodejs # Create a dedicated systemd config - ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" - ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" - ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" - ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" + ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" + ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" + ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" + ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" ynh_add_systemd_config fi @@ -87,13 +87,12 @@ if ynh_version_gt "1.07~ynh2" "${previous_version}" ; then ynh_install_app_dependencies "mongodb mongodb-server" yunohost service remove mongod yunohost service add mongodb --log "/var/log/mongodb/mongodb.log" - ynh_use_nodejs # Gotta regen the systemd config because mongodb service name changed - ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" - ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" - ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" - ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" + ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" + ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" + ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" + ynh_replace_string "__PORT__" "$port" "../conf/systemd.service" ynh_add_systemd_config fi @@ -166,6 +165,7 @@ systemctl reload nginx #================================================= # START SERVICE #================================================= +ynh_print_info "Now restarting Wekan service..." ynh_systemd_action --action=restart --service_name=$app --log_path="systemd" sleep 10 From 0c6b777ca3ea7c554627bc6ce66a8a7640b1f870 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Mar 2019 06:55:55 +0100 Subject: [PATCH 2/5] remove limitations from readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index ff06768..5a4a386 100644 --- a/README.md +++ b/README.md @@ -51,10 +51,6 @@ First registered user will be admin, and next ones normal users. If you want oth * ARMv8-A - Not supported * Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/wekan%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/wekan/) -## Limitations - -* Any known limitations. - ## Links * Report a bug: https://github.com/YunoHost-Apps/wekan_ynh/issues From dd7cb7857d43737d03cdc4b56312cd85e5333cad Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Mar 2019 23:32:18 +0100 Subject: [PATCH 3/5] Update install Remove dependencies installation as they are included in the package --- scripts/install | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/install b/scripts/install index 4501493..68ac907 100755 --- a/scripts/install +++ b/scripts/install @@ -96,15 +96,6 @@ ynh_print_info "Setting up wekan source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" -ynh_print_info "Installing wekan npm dependencies ..." - -# Install wekan dependencies -chown -R $app $final_path -pushd $final_path/programs/server - ynh_use_nodejs - npm install -popd - #================================================= # NGINX CONFIGURATION #================================================= From b432a036515f0b8df0516df8947aedeafcf63873 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 14 Mar 2019 00:57:24 +0100 Subject: [PATCH 4/5] Add needed ynh_use_nodejs to be abble to use $nodejs_path variable --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index be075db..a68fa6d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -71,6 +71,7 @@ fi if ynh_version_gt "0.77-2" "${previous_version}" ; then ynh_install_nodejs 8.9.3 # Create a dedicated systemd config + ynh_use_nodejs ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" @@ -89,6 +90,7 @@ if ynh_version_gt "1.07~ynh2" "${previous_version}" ; then yunohost service add mongodb --log "/var/log/mongodb/mongodb.log" # Gotta regen the systemd config because mongodb service name changed + ynh_use_nodejs ynh_replace_string "__ENV_PATH__" "$nodejs_path" "../conf/systemd.service" ynh_replace_string "__DB_NAME__" "$db_name" "../conf/systemd.service" ynh_replace_string "__DOMAIN_URI__" "$domain$path_url" "../conf/systemd.service" From d466cf7bfd6249ddbb5cd3ebd28ccb6d82ba4e68 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 15 Mar 2019 16:15:57 +0100 Subject: [PATCH 5/5] Typo in helper --- scripts/ynh_package_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ynh_package_version b/scripts/ynh_package_version index 816f97a..d6cdc4d 100644 --- a/scripts/ynh_package_version +++ b/scripts/ynh_package_version @@ -15,7 +15,7 @@ abort_if_up_to_date () { version=$(read_json "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" 'version' 2> /dev/null || echo '20160501-7') last_version=$(read_manifest 'version') if [ "${version}" = "${last_version}" ]; then - info "Up-to-date, nothing to do" + ynh_print_info "Up-to-date, nothing to do" ynh_die "" 0 fi }