From ed7ac956ff52769f320ed12db044a6445a34553a Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Thu, 3 Oct 2019 14:38:31 +0530 Subject: [PATCH] Fix install upgrade inconsistencies (#39) * [scripts][install] remove duplicate installation script * [scripts][upgrade] make server.js configuration consistent with install * [scripts][upgrade] move cryptpad installation after configuration to maintain consistency with install script * [scripts] use consistent paths for configuration --- scripts/install | 13 +------------ scripts/upgrade | 45 +++++++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/scripts/install b/scripts/install index 0b7a9e5..47ccb7d 100644 --- a/scripts/install +++ b/scripts/install @@ -131,7 +131,7 @@ ynh_replace_string "__PORT__" "$port" "$final_path/config/config.js" ynh_replace_string "__PORTI__" "$porti" "$final_path/config/config.js" # Tune CSP to allow for YunoHost tile -#ynh_replace_string "\"script-src 'self'\"" "\"script-src 'self' 'unsafe-eval'\"" "$final_path/config.js" +#ynh_replace_string "\"script-src 'self'\"" "\"script-src 'self' 'unsafe-eval'\"" "$final_path/config/config.js" # Remove donate button ynh_replace_string "removeDonateButton: false" "removeDonateButton: true" "$final_path/config/config.js" # Disable analytics unsolicited communications @@ -150,17 +150,6 @@ npm install -g bower --allow-root bower install --allow-root popd -#================================================= -# INSTALL CRYPTPAD -#================================================= - -script_dir="$PWD" -pushd "$final_path" -npm install --allow-root -npm install -g bower --allow-root -bower install --allow-root -popd - #================================================= # Set some permissions #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 20a1c90..6165a06 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -91,6 +91,29 @@ ynh_replace_string "__NODEJS__" "$nodejs_version" "../conf/systemd.service" ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" ynh_add_systemd_config +#================================================= +# CONFIGURE SERVER.JS +#================================================= + +# Backup configuration file if changed +ynh_backup_if_checksum_is_different "$final_path/config.js" +ynh_backup_if_checksum_is_different "$final_path/config/config.js" + +# Copy default configuration file +mv "../conf/config.js" "$final_path/config/config.js" + +# Set service port +ynh_replace_string "__PORT__" "$port" "$final_path/config/config.js" +ynh_replace_string "__PORTI__" "$porti" "$final_path/config/config.js" +# Tune CSP to allow for YunoHost tile +ynh_replace_string "\"script-src 'self'\"" "\"script-src 'self' 'unsafe-eval'\"" "$final_path/config/config.js" +# Remove donate button +ynh_replace_string "removeDonateButton: false" "removeDonateButton: true" "$final_path/config/config.js" +# Disable analytics unsolicited communications +ynh_replace_string "__ADMIN_EMAIL_" "$admin_email" "$final_path/config/config.js" + +# Store file checksum to detected user modifications on upgrade +ynh_store_file_checksum "$final_path/config/config.js" #================================================= # INSTALL CRYPTPAD @@ -104,28 +127,6 @@ npm install -g bower exec_login_as $app cd $final_path && env PATH=$PATH bower install popd -#================================================= -# CONFIGURE SERVER.JS -#================================================= - -# Backup configuration file if changed -ynh_backup_if_checksum_is_different "$final_path/config.js" - -# Copy default configuration file -sudo mv "$final_path/config.example.js" "$final_path/config.js" - -# Set service port -ynh_replace_string "httpPort: 3000" "httpPort: $port" "$final_path/config.js" -# Tune CSP to allow for YunoHost tile -ynh_replace_string "\"script-src 'self'\"" "\"script-src 'self' 'unsafe-eval'\"" "$final_path/config.js" -# Remove donate button -ynh_replace_string "removeDonateButton: false" "removeDonateButton: true" "$final_path/config.js" -# Disable analytics unsolicited communications -ynh_replace_string "adminEmail: 'i.did.not.read.my.config@cryptpad.fr'" "adminEmail: false" "$final_path/config.js" - -# Store file checksum to detected user modifications on upgrade -ynh_store_file_checksum "$final_path/config.js" - #================================================= # SET FILES OWNERSHIP #=================================================