From 4c6bc2cd5a78ae2ac015da246d6f1d9c9100af2e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 26 Jun 2022 20:30:44 +0200 Subject: [PATCH 01/13] Apply last example_ynh --- check_process | 8 ++----- conf/nginx.conf | 2 +- manifest.json | 24 ++++++++++----------- scripts/backup | 11 ++++++---- scripts/change_url | 3 ++- scripts/install | 51 +++++++++++++++++++-------------------------- scripts/remove | 30 +++++++++++--------------- scripts/restore | 39 +++++++++++++--------------------- scripts/upgrade | 52 +++++++++++++++++++++++++--------------------- 9 files changed, 100 insertions(+), 120 deletions(-) diff --git a/check_process b/check_process index bdf0be3..bfb23ce 100644 --- a/check_process +++ b/check_process @@ -2,8 +2,8 @@ ; Manifest domain="domain.tld" path="/path" - admin="john" is_public=1 + admin="john" password="1Strong-Password" ; Checks pkg_linter=1 @@ -17,12 +17,8 @@ upgrade=1 from_commit=9280c034e8843e7e69622f0daa02ee74c916faa1 backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 ;;; Options Email= Notification=none -;;; Upgrade options - ; commit=9280c034e8843e7e69622f0daa02ee74c916faa1 - name=Testing (#118) - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1&password=pass&port=666& - \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index c187424..8649aa8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -24,4 +24,4 @@ location /.well-known/matrix/ { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; -} \ No newline at end of file +} diff --git a/manifest.json b/manifest.json index a7916c4..2464484 100644 --- a/manifest.json +++ b/manifest.json @@ -21,15 +21,15 @@ "name": "eric_G", "email": "" }, + "requirements": { + "yunohost": ">> 4.3.2" + }, "multi_instance": true, "services": [ "nginx" ], - "requirements": { - "yunohost": ">> 4.3.2" - }, "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" @@ -40,14 +40,6 @@ "example": "/rocketchat", "default": "/rocketchat" }, - { - "name": "admin", - "type": "user" - }, - { - "name": "password", - "type": "password" - }, { "name": "is_public", "type": "boolean", @@ -56,6 +48,14 @@ "fr": "Si cette case est cochée, RocketChat sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." }, "default": true + }, + { + "name": "admin", + "type": "user" + }, + { + "name": "password", + "type": "password" } ] } diff --git a/scripts/backup b/scripts/backup index 6a99a4c..5a3266b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= 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 @@ -24,6 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,7 +32,10 @@ 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 +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= @@ -45,14 +48,14 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# SPECIFIC BACKUP #================================================= # BACKUP LOGROTATE #================================================= ynh_backup --src_path="/etc/logrotate.d/$app" -#================================================= -# SPECIFIC BACKUP #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/change_url b/scripts/change_url index 76b4138..8cb5d0d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -38,6 +38,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # 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" @@ -108,7 +109,7 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="SERVER RUNNING" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index de4b421..18a0b5d 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -26,12 +26,13 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -password=$YNH_APP_ARG_PASSWORD admin=$YNH_APP_ARG_ADMIN -email=$(ynh_user_get_info --username=$admin --key=mail) +password=$YNH_APP_ARG_PASSWORD app=$YNH_APP_INSTANCE_NAME +email=$(ynh_user_get_info --username=$admin --key=mail) + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -70,11 +71,17 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=20 -ynh_install_app_dependencies $pkg_dependencies - -# Install Nodejs +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_install_mongo +ynh_exec_warn_less ynh_install_mongo + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=3 + +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # CREATE A MONGODB DATABASE @@ -86,14 +93,6 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=3 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -101,7 +100,7 @@ ynh_script_progression --message="Setting up source files..." --weight=2 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 --dest_dir=$final_path +ynh_setup_source --dest_dir="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -136,9 +135,9 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 ynh_add_systemd_config #================================================= -# MODIFY A CONFIG FILE +# CONFIGURE MONGOD #================================================= -ynh_script_progression --message="Configuring a mongod..." --weight=1 +ynh_script_progression --message="Configuring mongod..." --weight=1 sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf @@ -167,31 +166,23 @@ ynh_script_progression --message="Integrating service in YunoHost..." 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=2 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" -sleep 60 +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="SERVER RUNNING" #================================================= # SETUP SSOWAT #================================================= ynh_script_progression --message="Configuring permissions..." --weight=1 -# Make app public if necessary or protect it +# Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi diff --git a/scripts/remove b/scripts/remove index 1c9299b..a4e619e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,19 +28,13 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# 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 + nh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi -if ynh_exec_warn_less yunohost service status "$mongodb_servicename" >/dev/null -then - ynh_script_progression --message="Removing $mongodb_servicename service integration..." - yunohost service remove "$mongodb_servicename" -fi - #================================================= # STOP AND REMOVE SERVICE #================================================= @@ -66,16 +60,6 @@ ynh_script_progression --message="Removing the MongoDB database..." # Remove a database if it exists, along with the associated user ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies -ynh_remove_nodejs -ynh_remove_mongo - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -96,6 +80,16 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies +ynh_remove_mongo +ynh_remove_nodejs +ynh_remove_app_dependencies + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 8162414..fd337a4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,5 +1,7 @@ #!/bin/bash +#================================================= +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -13,8 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -41,12 +42,6 @@ test ! -d $final_path || ynh_die --message="There is already a directory: $final #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -74,10 +69,16 @@ chown -R $app:$app "$final_path" ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_install_mongo +ynh_exec_warn_less ynh_install_mongo + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE MONGODB DATABASE @@ -89,9 +90,9 @@ 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 +# CONFIGURE MONGOD #================================================= -ynh_script_progression --message="Configuring a mongod..." --weight=3 +ynh_script_progression --message="Configuring mongod..." --weight=3 sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf @@ -125,22 +126,12 @@ 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=5 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" -sleep 60 +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="SERVER RUNNING" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 5c20a5b..7f22c53 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,7 @@ email=$(ynh_app_setting_get --app=$app --key=email) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -40,12 +41,22 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -64,15 +75,6 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" - #================================================= # CREATE DEDICATED USER #================================================= @@ -98,6 +100,15 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=7 + +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version +ynh_exec_warn_less ynh_install_mongo + #================================================= # NGINX CONFIGURATION #================================================= @@ -107,14 +118,7 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - ynh_add_nginx_config #================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=7 - -ynh_install_app_dependencies $pkg_dependencies -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -ynh_install_mongo - +# SPECIFIC UPGRADE #============================================== # INSTALL ROCKETCHAT #============================================== @@ -134,20 +138,22 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 ynh_add_systemd_config #================================================= -# MODIFY A CONFIG FILE +# CONFIGURE MONGOD #================================================= -ynh_script_progression --message="Configuring a mongod..." --weight=1 +ynh_script_progression --message="Configuring mongod..." --weight=1 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" +ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 -mongo --eval "printjson(rs.initiate())" +ynh_mongo_exec --command="printjson(rs.initiate())" --eval +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= @@ -168,9 +174,7 @@ yunohost service add $app --description="Team collaboration communication platfo #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=10 -ynh_systemd_action --service_name=$mongodb_servicename --action="restart" --log_path="systemd" -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" -sleep 60 +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="SERVER RUNNING" #================================================= # RELOAD NGINX From dfa72bfa00c64c2dd28569a4a3fbb41d8fa294c7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 26 Jun 2022 20:53:36 +0200 Subject: [PATCH 02/13] switching to ynh_mongo_db__2 --- scripts/_common.sh | 42 ++++++++++++------------------------------ scripts/install | 12 ++++++++---- scripts/restore | 6 ++---- scripts/upgrade | 6 ++---- 4 files changed, 24 insertions(+), 42 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 3644475..9e784b7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -17,11 +17,8 @@ pkg_dependencies="apt-transport-https build-essential gzip curl fontconfig graph # EXPERIMENTAL HELPERS #================================================= -MONGO_DEBIAN_SERVICENAME="mongodb" MONGO_CE_SERVICENAME="mongod" -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_DEPENDENCIES="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" MONGO_CE_CONFIG="/etc/mongod.conf" 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" @@ -110,7 +107,7 @@ ynh_mongo_exec() { database="" fi - mongo --quiet $user $password $authenticationdatabase $host $port < Date: Mon, 27 Jun 2022 02:49:41 +0200 Subject: [PATCH 03/13] More fixes --- scripts/_common.sh | 39 ++++++++++++++++++++------------------- scripts/change_url | 2 ++ scripts/install | 36 +++++++++++++++++++----------------- scripts/remove | 16 ++++++++++++---- scripts/restore | 13 ++++++++----- scripts/upgrade | 34 ++++++++++++++++++---------------- 6 files changed, 79 insertions(+), 61 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 9e784b7..6aa07b7 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -29,14 +29,14 @@ MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-5.0.asc" # example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")" # # usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval] -# | arg: -u, --user= - The user name to connect as -# | arg: -p, --password= - The user password -# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to -# | arg: -d, --database= - The database to connect to -# | arg: -h, --host= - The host to connect to -# | arg: -P, --port= - The port to connect to -# | arg: -c, --command= - The command to evaluate -# | arg: -e, --eval - Evaluate instead of execute the command. +# | arg: -u, --user= - The user name to connect as +# | arg: -p, --password= - The user password +# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to +# | arg: -d, --database= - The database to connect to +# | arg: -h, --host= - The host to connect to +# | arg: -P, --port= - The port to connect to +# | arg: -c, --command= - The command to evaluate +# | arg: -e, --eval - Evaluate instead of execute the command. # # ynh_mongo_exec() { @@ -172,9 +172,9 @@ ynh_mongo_dump_db() { # [internal] # # usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name -# | arg: -u, --db_user= - The user name to create -# | arg: -p, --db_pwd= - The password to identify user by -# | arg: -n, --db_name= - Name of the database to grant privilegies +# | arg: -u, --db_user= - The user name to create +# | arg: -p, --db_pwd= - The password to identify user by +# | arg: -n, --db_name= - Name of the database to grant privilegies # # ynh_mongo_create_user() { @@ -241,8 +241,8 @@ ynh_mongo_restore_db() { # [internal] # # usage: ynh_mongo_drop_user --db_user=user --db_name=name -# | arg: -u, --db_user= - The user to drop -# | arg: -n, --db_name= - Name of the database +# | arg: -u, --db_user= - The user to drop +# | arg: -n, --db_name= - Name of the database # # ynh_mongo_drop_user() { @@ -260,9 +260,9 @@ ynh_mongo_drop_user() { # Create a database, an user and its password. Then store the password in the app's config # # usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd] -# | arg: -u, --db_user= - Owner of the database -# | arg: -n, --db_name= - Name of the database -# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated +# | arg: -u, --db_user= - Owner of the database +# | arg: -n, --db_name= - Name of the database +# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated # # After executing this helper, the password of the created database will be available in $db_pwd # It will also be stored as "mongopwd" into the app settings. @@ -292,8 +292,8 @@ ynh_mongo_setup_db() { # Remove a database if it exists, and the associated user # # usage: ynh_mongo_remove_db --db_user=user --db_name=name -# | arg: -u, --db_user= - Owner of the database -# | arg: -n, --db_name= - Name of the database +# | arg: -u, --db_user= - Owner of the database +# | arg: -n, --db_name= - Name of the database # # ynh_mongo_remove_db() { @@ -348,6 +348,7 @@ ynh_remove_mongo() { mongodb_servicename=$MONGO_CE_SERVICENAME # Remove the mongodb service yunohost service remove $mongodb_servicename - # ynh_secure_remove --file=$MONGO_ROOT_PWD_FILE + ynh_secure_remove --file="/var/lib/mongodb" + ynh_secure_remove --file="/var/log/mongodb" fi } diff --git a/scripts/change_url b/scripts/change_url index 8cb5d0d..a068fb0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,8 @@ 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) + +# Add settings here as needed by your application port=$(ynh_app_setting_get --app=$app --key=port) #================================================= diff --git a/scripts/install b/scripts/install index 03b84e0..3af0053 100644 --- a/scripts/install +++ b/scripts/install @@ -87,7 +87,7 @@ ynh_exec_warn_less ynh_install_mongo ynh_script_progression --message="Configuring system user..." --weight=3 # Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MONGODB DATABASE @@ -122,14 +122,29 @@ ynh_add_nginx_config #================================================= # SPECIFIC SETUP +#================================================= +# CONFIGURE MONGOD +#================================================= +ynh_script_progression --message="Configuring mongod..." --weight=1 + +ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG +ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG + +ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet +ynh_systemd_action --service_name=$mongodb_servicename --action=restart + +sleep 10 + +ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval + #============================================== # INSTALL ROCKETCHAT #============================================== ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20 pushd $final_path/programs/server - ynh_use_nodejs - ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --unsafe-perm 2>/dev/null + ynh_use_nodejs + ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --unsafe-perm 2>/dev/null popd #================================================= @@ -140,19 +155,6 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# CONFIGURE MONGOD -#================================================= -ynh_script_progression --message="Configuring mongod..." --weight=1 - -sed -i "s/^# engine:/ engine: wiredTiger/" $MONGO_CE_CONFIG -sed -i "s/^#replication:/replication:\n replSetName: rs01/" $MONGO_CE_CONFIG - -ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet -ynh_systemd_action --service_name=$mongodb_servicename --action=restart - -sleep 10 - #================================================= # GENERIC FINALIZATION #================================================= @@ -168,7 +170,7 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log" +yunohost service add $app --description="Team collaboration communication platform" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index a4e619e..605123b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,7 +31,7 @@ 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 - nh_script_progression --message="Removing $app service integration..." --weight=1 + ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi @@ -42,7 +42,6 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config -ynh_remove_systemd_config --service=$mongodb_servicename #================================================= # REMOVE LOGROTATE CONFIGURATION @@ -57,6 +56,15 @@ ynh_remove_logrotate #================================================= ynh_script_progression --message="Removing the MongoDB database..." +ynh_mongo_exec --command="printjson(rs.remove(localhost))" --eval +ynh_replace_string --match_string="engine: wiredTiger" --replace_string="# engine:" --target_file=$MONGO_CE_CONFIG +ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file=$MONGO_CE_CONFIG +ynh_replace_string --match_string=" replSetName: rs01" --replace_string="" --target_file=$MONGO_CE_CONFIG + +ynh_systemd_action --service_name=$mongodb_servicename --action=restart + +sleep 10 + # Remove a database if it exists, along with the associated user ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name @@ -86,9 +94,9 @@ ynh_remove_nginx_config ynh_script_progression --message="Removing dependencies..." --weight=1 # Remove metapackage and its dependencies -ynh_remove_mongo -ynh_remove_nodejs ynh_remove_app_dependencies +ynh_remove_nodejs +ynh_remove_mongo #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index c2e519e..400c74f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -38,7 +38,8 @@ db_user=$db_name #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -48,7 +49,7 @@ test ! -d $final_path || ynh_die --message="There is already a directory: $final ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE THE APP MAIN DIR @@ -94,14 +95,16 @@ ynh_mongo_restore_db --database="$db_name" < ./dump.bson #================================================= ynh_script_progression --message="Configuring mongod..." --weight=3 -sed -i "s/^# engine:/ engine: wiredTiger/" $MONGO_CE_CONFIG -sed -i "s/^#replication:/replication:\n replSetName: rs01/" $MONGO_CE_CONFIG +ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG +ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 +ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval + #================================================= # RESTORE SYSTEMD #================================================= @@ -122,7 +125,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= 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" +yunohost service add $app --description="Team collaboration communication platform" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 0ff8652..07fdd70 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -119,14 +119,29 @@ ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE +#================================================= +# CONFIGURE MONGOD +#================================================= +ynh_script_progression --message="Configuring mongod..." --weight=1 + +ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG +ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG + +ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet +ynh_systemd_action --service_name=$mongodb_servicename --action=restart + +sleep 10 + +ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval + #============================================== # INSTALL ROCKETCHAT #============================================== ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20 pushd $final_path/programs/server - ynh_use_nodejs - ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm 2>/dev/null + ynh_use_nodejs + ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm 2>/dev/null popd #================================================= @@ -137,19 +152,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# CONFIGURE MONGOD -#================================================= -ynh_script_progression --message="Configuring mongod..." --weight=1 - -sed -i "s/^# engine:/ engine: wiredTiger/" $MONGO_CE_CONFIG -sed -i "s/^#replication:/replication:\n replSetName: rs01/" $MONGO_CE_CONFIG - -ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet -ynh_systemd_action --service_name=$mongodb_servicename --action=restart - -sleep 10 - #================================================= # GENERIC FINALIZATION #================================================= @@ -165,7 +167,7 @@ ynh_use_logrotate --non-append #================================================= 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" +yunohost service add $app --description="Team collaboration communication platform" #================================================= # START SYSTEMD SERVICE From ab01ccd5774be20f74fec9ef76a1f95b77614ae2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 28 Jun 2022 22:52:55 +0200 Subject: [PATCH 04/13] better rs.initiate --- scripts/install | 4 +++- scripts/restore | 4 +++- scripts/upgrade | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 3af0053..9644bd1 100644 --- a/scripts/install +++ b/scripts/install @@ -135,7 +135,9 @@ ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 -ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then + ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +fi #============================================== # INSTALL ROCKETCHAT diff --git a/scripts/restore b/scripts/restore index 400c74f..3a68deb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -103,7 +103,9 @@ ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 -ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then + ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +fi #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 07fdd70..3f5619e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,7 +132,9 @@ ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 -ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then + ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +fi #============================================== # INSTALL ROCKETCHAT From a081a04a145db58d8ce4c9fd3dfafc8c09b2d45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 28 Jun 2022 23:59:08 +0200 Subject: [PATCH 05/13] Update systemd.service --- conf/systemd.service | 2 -- 1 file changed, 2 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 2767e22..dd0805e 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -10,8 +10,6 @@ Environment="NODE_ENV=production" WorkingDirectory=__FINALPATH__/ Environment="__YNH_NODE_LOAD_PATH__" ExecStart=__YNH_NODE__ __FINALPATH__/main.js -StandardOutput=syslog -StandardError=syslog SyslogIdentifier=__APP__ Environment=MONGO_URL=mongodb://localhost:27017/__APP__?replicaSet=rs01 Environment=MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 From 716503541cb0b46ffc129ecdb38094f1b8dea5c4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 29 Jun 2022 20:08:49 +0200 Subject: [PATCH 06/13] Update scripts/install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 9644bd1..e8c5296 100644 --- a/scripts/install +++ b/scripts/install @@ -146,7 +146,7 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd $final_path/programs/server ynh_use_nodejs - ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --unsafe-perm 2>/dev/null + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm install --unsafe-perm popd #================================================= From e6c1be888ed4bbb9c13acce9e60d38672580bc22 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 29 Jun 2022 20:09:00 +0200 Subject: [PATCH 07/13] Update scripts/upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 3f5619e..a637851 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,7 +143,7 @@ ynh_script_progression --message="Building $app... (this will take some time and pushd $final_path/programs/server ynh_use_nodejs - ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm 2>/dev/null + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH npm install --unsafe-perm popd #================================================= From 759948d55961be89e3626140aae6f82f00bc48f6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 30 Jun 2022 19:34:44 +0200 Subject: [PATCH 08/13] fix mongo service --- scripts/install | 4 ++-- scripts/remove | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index e8c5296..67fecea 100644 --- a/scripts/install +++ b/scripts/install @@ -130,8 +130,8 @@ ynh_script_progression --message="Configuring mongod..." --weight=1 ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG -ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet -ynh_systemd_action --service_name=$mongodb_servicename --action=restart +ynh_exec_warn_less systemctl enable $MONGO_CE_SERVICENAME --quiet +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart sleep 10 diff --git a/scripts/remove b/scripts/remove index 605123b..8528898 100644 --- a/scripts/remove +++ b/scripts/remove @@ -56,12 +56,12 @@ ynh_remove_logrotate #================================================= ynh_script_progression --message="Removing the MongoDB database..." -ynh_mongo_exec --command="printjson(rs.remove(localhost))" --eval +ynh_mongo_exec --command="printjson(rs.remove())" --eval ynh_replace_string --match_string="engine: wiredTiger" --replace_string="# engine:" --target_file=$MONGO_CE_CONFIG ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file=$MONGO_CE_CONFIG ynh_replace_string --match_string=" replSetName: rs01" --replace_string="" --target_file=$MONGO_CE_CONFIG -ynh_systemd_action --service_name=$mongodb_servicename --action=restart +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart sleep 10 diff --git a/scripts/restore b/scripts/restore index 3a68deb..514d35e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -98,8 +98,8 @@ ynh_script_progression --message="Configuring mongod..." --weight=3 ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG -ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet -ynh_systemd_action --service_name=$mongodb_servicename --action=restart +ynh_exec_warn_less systemctl enable $MONGO_CE_SERVICENAME --quiet +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart sleep 10 diff --git a/scripts/upgrade b/scripts/upgrade index a637851..744877b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -127,8 +127,8 @@ ynh_script_progression --message="Configuring mongod..." --weight=1 ynh_replace_string --match_string="# engine:" --replace_string=" engine: wiredTiger" --target_file=$MONGO_CE_CONFIG ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG -ynh_exec_warn_less systemctl enable $mongodb_servicename --quiet -ynh_systemd_action --service_name=$mongodb_servicename --action=restart +ynh_exec_warn_less systemctl enable $MONGO_CE_SERVICENAME --quiet +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart sleep 10 From 03c2296a7ad80d1e188c6d5c22198b4e4fb9b31a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Jul 2022 02:44:36 +0200 Subject: [PATCH 09/13] Fix removal --- scripts/remove | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/remove b/scripts/remove index 8528898..1e1c42b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -56,10 +56,9 @@ ynh_remove_logrotate #================================================= ynh_script_progression --message="Removing the MongoDB database..." -ynh_mongo_exec --command="printjson(rs.remove())" --eval ynh_replace_string --match_string="engine: wiredTiger" --replace_string="# engine:" --target_file=$MONGO_CE_CONFIG ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file=$MONGO_CE_CONFIG -ynh_replace_string --match_string=" replSetName: rs01" --replace_string="" --target_file=$MONGO_CE_CONFIG +ynh_replace_string --match_string=" replSetName: rs01" --replace_string="" --target_file=$MONGO_CE_CONFIG ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart From e40c6e0683cc09fd2f7b110e7fbf0587d884e811 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Jul 2022 22:28:16 +0200 Subject: [PATCH 10/13] Fix mongod service --- scripts/install | 4 +--- scripts/remove | 4 +--- scripts/restore | 4 +--- scripts/upgrade | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/install b/scripts/install index 67fecea..1e0f18e 100644 --- a/scripts/install +++ b/scripts/install @@ -131,9 +131,7 @@ ynh_replace_string --match_string="# engine:" --replace_string=" engine: wired ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG ynh_exec_warn_less systemctl enable $MONGO_CE_SERVICENAME --quiet -ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart - -sleep 10 +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart --log_path=/var/log/mongodb/$MONGO_CE_SERVICENAME.log --line_match="Waiting for connections" if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval diff --git a/scripts/remove b/scripts/remove index 1e1c42b..38d4ad6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -60,9 +60,7 @@ ynh_replace_string --match_string="engine: wiredTiger" --replace_string="# engi ynh_replace_string --match_string="replication:" --replace_string="#replication:" --target_file=$MONGO_CE_CONFIG ynh_replace_string --match_string=" replSetName: rs01" --replace_string="" --target_file=$MONGO_CE_CONFIG -ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart - -sleep 10 +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart --log_path=/var/log/mongodb/$MONGO_CE_SERVICENAME.log --line_match="Waiting for connections" # Remove a database if it exists, along with the associated user ynh_mongo_remove_db --db_user=$db_user --db_name=$db_name diff --git a/scripts/restore b/scripts/restore index 514d35e..dceea60 100644 --- a/scripts/restore +++ b/scripts/restore @@ -99,9 +99,7 @@ ynh_replace_string --match_string="# engine:" --replace_string=" engine: wired ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG ynh_exec_warn_less systemctl enable $MONGO_CE_SERVICENAME --quiet -ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart - -sleep 10 +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart --log_path=/var/log/mongodb/$MONGO_CE_SERVICENAME.log --line_match="Waiting for connections" if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval diff --git a/scripts/upgrade b/scripts/upgrade index 744877b..9025833 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -128,9 +128,7 @@ ynh_replace_string --match_string="# engine:" --replace_string=" engine: wired ynh_replace_string --match_string="#replication:" --replace_string="replication:\n replSetName: rs01" --target_file=$MONGO_CE_CONFIG ynh_exec_warn_less systemctl enable $MONGO_CE_SERVICENAME --quiet -ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart - -sleep 10 +ynh_systemd_action --service_name=$MONGO_CE_SERVICENAME --action=restart --log_path=/var/log/mongodb/$MONGO_CE_SERVICENAME.log --line_match="Waiting for connections" if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval From 8228ad3ec09357d7023f8f3405324201b524b9ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 2 Jul 2022 18:54:13 +0200 Subject: [PATCH 11/13] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 31da8e4..3f0bec7 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Team collaboration communication platform", "fr": "Plateforme de communication collaborative en équipe" }, - "version": "4.8.1~ynh2", + "version": "4.8.1~ynh3", "url": "https://rocket.chat", "upstream": { "license": "GPL-3.0", From 155e99d8ab1313cbed7d48ee07d47792ce78af43 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sat, 2 Jul 2022 16:54:20 +0000 Subject: [PATCH 12/13] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e721f3..e446d45 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Rocket.Chat is an open-source fully customizable communications platform develop - Mobile Apps for [iOS](https://apps.apple.com/app/rocket-chat/id1148741252) and [Android](https://play.google.com/store/apps/details?id=chat.rocket.android) - Desktop Apps for [macOS](https://apps.apple.com/br/app/rocket-chat/id1086818840), [Linux](https://snapcraft.io/rocketchat-desktop) and [Windows](https://releases.rocket.chat/desktop/latest/download) -**Shipped version:** 4.8.1~ynh2 +**Shipped version:** 4.8.1~ynh3 **Demo:** https://cloud.rocket.chat/trial diff --git a/README_fr.md b/README_fr.md index 11927fa..57b5c1d 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,7 +26,7 @@ Rocket.Chat est une plate-forme de communication open source entièrement person - Applications mobiles pour [iOS](https://apps.apple.com/app/rocket-chat/id1148741252) et [Android](https://play.google.com/store/apps/details?id=chat.rocket.android) - Applications de bureau pour [macOS](https://apps.apple.com/br/app/rocket-chat/id1086818840), [Linux](https://snapcraft.io/rocketchat-desktop) et [Windows](https://releases.rocket.chat/desktop/latest/download) -**Version incluse :** 4.8.1~ynh2 +**Version incluse :** 4.8.1~ynh3 **Démo :** https://cloud.rocket.chat/trial From bf41d86e25a1e36a94597011e95e8a6353feea57 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 2 Jul 2022 22:18:59 +0200 Subject: [PATCH 13/13] spacing --- scripts/_common.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6aa07b7..ce29ced 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -29,14 +29,14 @@ MONGO_CE_KEY="https://www.mongodb.org/static/pgp/server-5.0.asc" # example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")" # # usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval] -# | arg: -u, --user= - The user name to connect as -# | arg: -p, --password= - The user password -# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to -# | arg: -d, --database= - The database to connect to -# | arg: -h, --host= - The host to connect to -# | arg: -P, --port= - The port to connect to -# | arg: -c, --command= - The command to evaluate -# | arg: -e, --eval - Evaluate instead of execute the command. +# | arg: -u, --user= - The user name to connect as +# | arg: -p, --password= - The user password +# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to +# | arg: -d, --database= - The database to connect to +# | arg: -h, --host= - The host to connect to +# | arg: -P, --port= - The port to connect to +# | arg: -c, --command= - The command to evaluate +# | arg: -e, --eval - Evaluate instead of execute the command. # # ynh_mongo_exec() { @@ -172,9 +172,9 @@ ynh_mongo_dump_db() { # [internal] # # usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name -# | arg: -u, --db_user= - The user name to create -# | arg: -p, --db_pwd= - The password to identify user by -# | arg: -n, --db_name= - Name of the database to grant privilegies +# | arg: -u, --db_user= - The user name to create +# | arg: -p, --db_pwd= - The password to identify user by +# | arg: -n, --db_name= - Name of the database to grant privilegies # # ynh_mongo_create_user() { @@ -197,7 +197,7 @@ ynh_mongo_create_user() { # Check if a mongo database exists # # usage: ynh_mongo_database_exists --database=database -# | arg: -d, --database= - The database for which to check existence +# | arg: -d, --database= - The database for which to check existence # | exit: Return 1 if the database doesn't exist, 0 otherwise # # @@ -241,8 +241,8 @@ ynh_mongo_restore_db() { # [internal] # # usage: ynh_mongo_drop_user --db_user=user --db_name=name -# | arg: -u, --db_user= - The user to drop -# | arg: -n, --db_name= - Name of the database +# | arg: -u, --db_user= - The user to drop +# | arg: -n, --db_name= - Name of the database # # ynh_mongo_drop_user() { @@ -260,9 +260,9 @@ ynh_mongo_drop_user() { # Create a database, an user and its password. Then store the password in the app's config # # usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd] -# | arg: -u, --db_user= - Owner of the database -# | arg: -n, --db_name= - Name of the database -# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated +# | arg: -u, --db_user= - Owner of the database +# | arg: -n, --db_name= - Name of the database +# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated # # After executing this helper, the password of the created database will be available in $db_pwd # It will also be stored as "mongopwd" into the app settings. @@ -292,8 +292,8 @@ ynh_mongo_setup_db() { # Remove a database if it exists, and the associated user # # usage: ynh_mongo_remove_db --db_user=user --db_name=name -# | arg: -u, --db_user= - Owner of the database -# | arg: -n, --db_name= - Name of the database +# | arg: -u, --db_user= - Owner of the database +# | arg: -n, --db_name= - Name of the database # # ynh_mongo_remove_db() {