1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/rocketchat_ynh.git synced 2024-09-03 20:16:25 +02:00
This commit is contained in:
ericgaspar 2021-06-30 16:22:50 +02:00
parent 10d81eea02
commit 8211530660
No known key found for this signature in database
GPG key ID: 574F281483054D44
3 changed files with 55 additions and 68 deletions

View file

@ -1,11 +1,24 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
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
ynh_abort_if_errors
#=================================================
@ -23,17 +36,23 @@ domain=$(ynh_app_setting_get $app domain)
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "$final_path"
ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE CONFIGURATION
#=================================================
ynh_backup "/etc/systemd/system/$app.service" "conf/service"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx"
ynh_backup --src_path="/etc/systemd/system/$app.service" "conf/service"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx"
#=================================================
# BACKUP THE MONGODB DATABASE
#=================================================
mongodump -o "./dump"
ynh_mongo_dump_db
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -116,18 +116,13 @@ ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#==============================================
# INSTALL HEDGEDOC
# INSTALL ROCKETCHAT
#==============================================
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=240
ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20
pushd $final_path/programs/server
ynh_use_nodejs
#npm install -g inherits n
ynh_exec_as $app env $ynh_node_load_PATH npm install
#export MONGO_URL='mongodb://$db_user:$db_pwdd@host:27017/$db_name'
#export ROOT_URL='http://$domain'
#export MAIL_URL='smtp://localhost:25'
popd
#=================================================
@ -159,7 +154,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd #--line_match="HTTP Server listening"
ynh_systemd_action --service_name=mongod --action=restart --log_path=systemd
#=================================================

View file

@ -84,6 +84,14 @@ ynh_script_progression --message="Stopping a systemd service..." --time --weight
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@ -96,87 +104,51 @@ then
ynh_setup_source --dest_dir="$final_path"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:$app "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#==============================================
# 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
popd
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --time --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
# ...
#=================================================
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# MODIFY A CONFIG FILE
#=================================================
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE"
ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/CONFIG_FILE"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions on app files
chown -R root: $final_path
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
@ -185,6 +157,8 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
ynh_systemd_action --service_name=mongod --action=restart --log_path=systemd
#=================================================
# UPGRADE FAIL2BAN
#=================================================