From 652795607e1ba24dba145cbbe75a7170d9fc91b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 18 Nov 2021 17:26:35 +0100 Subject: [PATCH] Testing (#82) --- .github/ISSUE_TEMPLATE.md | 55 ++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 16 ++++ README.md | 6 +- README_fr.md | 5 +- check_process | 2 +- conf/app.src | 8 +- conf/mongod.conf | 44 ----------- conf/rocketchat_ldap.js | 2 +- conf/systemd.service | 9 ++- doc/DESCRIPTION.md | 1 + doc/DESCRIPTION_fr.md | 1 + doc/DISCLAIMER_fr.md | 0 manifest.json | 10 +-- scripts/_common.sh | 4 +- scripts/backup | 6 ++ scripts/change_url | 124 +++++++++++++++++++++++++++++++ scripts/install | 31 ++++++-- scripts/remove | 8 ++ scripts/restore | 45 +++++++++-- scripts/upgrade | 65 +++++++++------- 20 files changed, 334 insertions(+), 108 deletions(-) create mode 100755 .github/ISSUE_TEMPLATE.md create mode 100755 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 conf/mongod.conf create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/DESCRIPTION_fr.md create mode 100644 doc/DISCLAIMER_fr.md create mode 100644 scripts/change_url diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100755 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**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 the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and 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.* + +### Context + +- 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`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *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 + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100755 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/README.md b/README.md index 408ea0b..07d6655 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,10 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Team collaboration communication platform +Rocket.Chat is an open-source fully customizable communications platform developed in JavaScript for organizations with high standards of data protection. -**Shipped version:** 3.16.2~ynh1 + +**Shipped version:** 4.1.2~ynh1 **Demo:** https://cloud.rocket.chat/trial @@ -28,7 +29,6 @@ Team collaboration communication platform ## Documentation and resources * Official app website: https://rocket.chat/ -* Official user documentation: https://yunohost.org/apps * Official admin documentation: https://docs.rocket.chat/ * Upstream app code repository: https://github.com/RocketChat/Rocket.Chat * YunoHost documentation for this app: https://yunohost.org/app_rocketchat diff --git a/README_fr.md b/README_fr.md index e45f0f3..fc3fba4 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,9 +11,9 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble -Plateforme de communication collaborative en équipe +Rocket.Chat est une plate-forme de communication open source entièrement personnalisable développée en JavaScript pour les organisations avec des normes élevées de protection des données. -**Version incluse :** 3.16.2~ynh1 +**Version incluse :** 4.1.2~ynh1 **Démo :** https://cloud.rocket.chat/trial @@ -24,7 +24,6 @@ Plateforme de communication collaborative en équipe ## Documentations et ressources * Site officiel de l'app : https://rocket.chat/ -* Documentation officielle utilisateur : https://yunohost.org/apps * Documentation officielle de l'admin : https://docs.rocket.chat/ * Dépôt de code officiel de l'app : https://github.com/RocketChat/Rocket.Chat * Documentation YunoHost pour cette app : https://yunohost.org/app_rocketchat diff --git a/check_process b/check_process index 650c839..8b9b820 100644 --- a/check_process +++ b/check_process @@ -13,7 +13,7 @@ upgrade=1 #upgrade=1 from_commit=CommitHash backup_restore=1 - multi_instance=0 + multi_instance=1 change_url=1 ;;; Options Email= diff --git a/conf/app.src b/conf/app.src index 0f346dd..02346cc 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,7 @@ -SOURCE_URL=https://releases.rocket.chat/3.16.2/download -SOURCE_SUM=97c0ddcdb8ceb95bf87282368d4f6193e1fa86e33a8f139593ca93521159c728 +SOURCE_URL=https://releases.rocket.chat/4.1.2/download +SOURCE_SUM=a85954b127ed6ad377a8f178b6762262d9ee6ddb8cdd1905a76929e3621cf85b SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=rocket.chat-3.16.2.tgz -SOURCE_EXTRACT=true \ No newline at end of file +SOURCE_FILENAME=rocket.chat.tgz +SOURCE_EXTRACT=true diff --git a/conf/mongod.conf b/conf/mongod.conf deleted file mode 100644 index 4bedf87..0000000 --- a/conf/mongod.conf +++ /dev/null @@ -1,44 +0,0 @@ -# mongod.conf - -# for documentation of all options, see: -# http://docs.mongodb.org/manual/reference/configuration-options/ - -# Where and how to store data. -storage: - dbPath: /var/lib/mongodb - journal: - enabled: true -engine: wiredTiger -# mmapv1: -# wiredTiger: - -# where to write logging data. -systemLog: - destination: file - logAppend: true - path: /var/log/mongodb/mongod.log - -# network interfaces -net: - port: 27017 - bindIp: 127.0.0.1 - - -# how the process runs -processManagement: - timeZoneInfo: /usr/share/zoneinfo - -#security: - -#operationProfiling: - -replication: - replSetName: "rs01" - -#sharding: - -## Enterprise-Only Options: - -#auditLog: - -#snmp: diff --git a/conf/rocketchat_ldap.js b/conf/rocketchat_ldap.js index 62293ff..23de9a0 100644 --- a/conf/rocketchat_ldap.js +++ b/conf/rocketchat_ldap.js @@ -1,4 +1,4 @@ -use __DB_NAME__ +use rocketchat db.rocketchat_settings.update( diff --git a/conf/systemd.service b/conf/systemd.service index 65b2f60..59299ec 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,19 +1,20 @@ [Unit] Description=The Rocket.Chat server -#Wants=__MONGODB_SERVICENAME__.service +Wants=__MONGODB_SERVICENAME__.service After=network.target remote-fs.target nss-lookup.target nginx.service __MONGODB_SERVICENAME__.service [Service] User=__APP__ +Group=__APP__ WorkingDirectory=__FINALPATH__ Environment="PATH=__ENV_PATH__" Environment="NODE_ENV=production" -ExecStart=__YNH_NODE__ main.js +ExecStart=__YNH_NODE__ __FINALPATH__/main.js StandardOutput=syslog StandardError=syslog SyslogIdentifier=__APP__ -Environment=MONGO_URL=mongodb://127.0.0.1:27017/__APP__?replicaSet=rs01 -Environment=MONGO_OPLOG_URL=mongodb://127.0.0.1:27017/local?replicaSet=rs01 +Environment=MONGO_URL=mongodb://localhost:27017/__APP__?replicaSet=rs01 +Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 Environment=ROOT_URL=https://__DOMAIN____PATH__ Environment=PORT=__PORT__ diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..9fdc029 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +Rocket.Chat is an open-source fully customizable communications platform developed in JavaScript for organizations with high standards of data protection. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md new file mode 100644 index 0000000..d347e88 --- /dev/null +++ b/doc/DESCRIPTION_fr.md @@ -0,0 +1 @@ +Rocket.Chat est une plate-forme de communication open source entièrement personnalisable développée en JavaScript pour les organisations avec des normes élevées de protection des données. \ No newline at end of file diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md new file mode 100644 index 0000000..e69de29 diff --git a/manifest.json b/manifest.json index 15a0448..944f3a9 100644 --- a/manifest.json +++ b/manifest.json @@ -6,14 +6,13 @@ "en": "Team collaboration communication platform", "fr": "Plateforme de communication collaborative en équipe" }, - "version": "3.16.2~ynh1", + "version": "4.1.2~ynh1", "url": "https://rocket.chat", "upstream": { "license": "GPL-3.0", "website": "https://rocket.chat/", "demo": "https://cloud.rocket.chat/trial", "admindoc": "https://docs.rocket.chat/", - "userdoc": "https://yunohost.org/apps", "code": "https://github.com/RocketChat/Rocket.Chat" }, "license": "GPL-3.0", @@ -21,19 +20,18 @@ "name": "", "email": "" }, - "multi_instance": false, + "multi_instance": true, "services": [ "nginx" ], "requirements": { - "yunohost": ">> 4.2.4" + "yunohost": ">> 4.3.2" }, "arguments": { "install" : [ { "name": "domain", - "type": "domain", - "example": "domain.org" + "type": "domain" }, { "name": "path", diff --git a/scripts/_common.sh b/scripts/_common.sh index 87ac1c2..02a93b8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -23,8 +23,8 @@ MONGO_DEBIAN_DEPENDENCIES="mongodb mongodb-server mongo-tools" MONGO_CE_DEPENDENCIES="mongodb-org mongodb-org-server mongodb-org-tools" MONGO_DEBIAN_CONFIG="/etc/mongodb.conf" MONGO_CE_CONFIG="/etc/mongod.conf" -MONGO_CE_REPO="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" -MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-4.4.asc" +MONGO_CE_REPO="deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main" +MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-5.0.asc" # Execute a mongo command # diff --git a/scripts/backup b/scripts/backup index e0b8bd7..6a99a4c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -45,6 +45,12 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # SPECIFIC BACKUP #================================================= diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..538ca2b --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,124 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD 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) +port=$(ynh_app_setting_get --app=$app --key=port) + +#================================================= +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +#================================================= +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 +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 +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the NGINX config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original NGINX config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for NGINX helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated NGINX config + ynh_add_nginx_config +fi + +# Change the domain for NGINX +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + 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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index bad0647..55f6106 100644 --- a/scripts/install +++ b/scripts/install @@ -101,7 +101,7 @@ ynh_setup_source --dest_dir=$final_path chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -139,7 +139,23 @@ ynh_script_progression --message="Configuring a mongod..." --weight=1 sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf -#echo -e "replication:\n replSetName: \"rs01\"" | tee -a /etc/mongod.conf + +ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet +ynh_systemd_action --service_name=$mongodb_servicename --action=restart + +sleep 10 + +ynh_mongo_exec --command="printjson(rs.initiate())" --eval + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." --weight=1 + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST @@ -149,22 +165,21 @@ ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log" #================================================= -# START SYSTEMD SERVICE +# START MONGO SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a MongoDB service..." --weight=2 # Start a mongod service -ynh_exec_warn_less systemctl enable mongod --quiet -ynh_systemd_action --service_name=mongod --action=restart - -#mongo --eval "printjson(rs.initiate())" +ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet +ynh_systemd_action --service_name=$mongodb_servicename --action=restart #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="➔ System ➔ startup" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd +sleep 120 #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index d37f8d1..33b029f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -43,6 +43,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE THE MONGODB DATABASE #================================================= diff --git a/scripts/restore b/scripts/restore index ff9daa6..95372e4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -37,8 +37,6 @@ db_user=$db_name #================================================= 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}" test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " @@ -67,7 +65,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION @@ -78,18 +76,34 @@ ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies + ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_install_mongo #================================================= # RESTORE THE MONGODB DATABASE #================================================= -ynh_script_progression --message="Restoring the MongoDB database..." +ynh_script_progression --message="Restoring the MongoDB database..." --weight=3 db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mongo_restore_db --database="$db_name" < ./dump.bson +#================================================= +# MODIFY A CONFIG FILE +#================================================= +ynh_script_progression --message="Configuring a mongod..." --weight=3 + +sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf +sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf + +ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet +ynh_systemd_action --service_name=$mongodb_servicename --action=restart + +sleep 10 + +ynh_mongo_exec --command="printjson(rs.initiate())" --eval + #================================================= # RESTORE SYSTEMD #================================================= @@ -98,6 +112,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." --weig ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -105,19 +126,29 @@ ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log" +#================================================= +# START MONGO SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a MongoDB service..." --weight=2 + +# Start a mongod service +ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet +ynh_systemd_action --service_name=$mongodb_servicename --action=restart + #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=5 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd +sleep 120 #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index a34008c..92452bc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # CHECK VERSION @@ -28,27 +29,6 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# 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 nobody installed your app before 4.1, -### then you may safely remove these lines - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -63,6 +43,24 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# 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 + +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -95,7 +93,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -139,7 +137,23 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Configuring a mongod..." --weight=1 -echo -e "replication:\n replSetName: \"rs01\"" | tee -a /etc/mongod.conf +sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf +sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf + +ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet +ynh_systemd_action --service_name=$mongodb_servicename --action=restart + +sleep 10 + +mongo --eval "printjson(rs.initiate())" + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append #================================================= # INTEGRATE SERVICE IN YUNOHOST @@ -153,8 +167,9 @@ yunohost service add $app --description="Team collaboration communication platfo #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=10 -ynh_systemd_action --service_name=mongod --action=restart --log_path=systemd -ynh_systemd_action --service_name=$app --action=start --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$mongodb_servicename --action=restart --log_path=systemd +ynh_systemd_action --service_name=$app --action=start --log_path=systemd +sleep 120 #================================================= # RELOAD NGINX