1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/rocketchat_ynh.git synced 2024-09-03 20:16:25 +02:00
rocketchat_ynh/scripts/restore

89 lines
3.5 KiB
Text
Raw Normal View History

2017-07-18 13:38:42 +02:00
#!/bin/bash
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
2021-06-30 19:06:52 +02:00
source ../settings/scripts/_common.sh
2021-06-30 18:34:32 +02:00
source /usr/share/yunohost/helpers
2017-07-21 12:11:26 +02:00
2017-07-18 13:38:42 +02:00
#=================================================
# LOAD SETTINGS
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Loading installation settings..."
2017-07-18 13:38:42 +02:00
2023-02-16 10:07:14 +01:00
db_user=$db_name
2024-08-29 15:01:46 +02:00
mongo_version=$(ynh_app_setting_get --key=mongo_version)
#=================================================
2021-07-01 07:59:58 +02:00
# RESTORE THE APP MAIN DIR
2017-07-18 13:38:42 +02:00
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Restoring the app main directory..."
2017-09-04 22:24:56 +02:00
2024-08-29 15:01:46 +02:00
ynh_restore "$install_dir"
2017-09-04 22:24:56 +02:00
2024-08-29 15:01:46 +02:00
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:$app "$install_dir"
2017-07-18 13:38:42 +02:00
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Reinstalling dependencies..."
# Define and install dependencies
2024-08-29 15:01:46 +02:00
ynh_nodejs_install
ynh_hide_warnings ynh_install_mongo
2022-06-26 20:30:44 +02:00
#=================================================
2021-07-01 07:59:58 +02:00
# RESTORE THE MONGODB DATABASE
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Restoring the MongoDB database..."
2024-08-29 15:01:46 +02:00
db_pwd=$(ynh_app_setting_get --key=db_pwd)
2021-07-01 07:59:58 +02:00
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
2024-08-29 15:01:46 +02:00
ynh_mongo_restore_db < ./dump.bson
2021-11-17 23:37:02 +01:00
#=================================================
2022-06-26 20:30:44 +02:00
# CONFIGURE MONGOD
2021-11-17 23:37:02 +01:00
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Configuring mongod..."
2021-11-17 23:37:02 +01:00
2024-08-29 15:01:46 +02:00
ynh_replace --match="# engine:" --replace=" engine: wiredTiger" --file="/etc/mongod.conf"
ynh_replace --match="#replication:" --replace="replication:\n replSetName: rs01" --file="/etc/mongod.conf"
2021-11-17 23:37:02 +01:00
2024-08-29 15:01:46 +02:00
ynh_hide_warnings systemctl enable mongod --quiet
ynh_systemctl --service=mongod --action=restart --log_path=/var/log/mongodb/mongod.log --wait_until="Waiting for connections"
2021-11-17 23:37:02 +01:00
2024-08-29 15:01:46 +02:00
if ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then
ynh_hide_warnings ynh_mongo_exec --command="printjson(rs.initiate())"
2022-06-28 22:52:55 +02:00
fi
2022-06-27 02:49:41 +02:00
#=================================================
2023-08-27 07:48:19 +02:00
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
2023-08-27 07:48:19 +02:00
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Restoring system configurations related to $app..."
2024-08-29 15:01:46 +02:00
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
2023-03-30 16:05:39 +02:00
2024-08-29 15:01:46 +02:00
ynh_restore "/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
2024-08-29 15:01:46 +02:00
ynh_restore "/etc/logrotate.d/$app"
2021-11-13 23:17:56 +01:00
2023-08-27 07:48:19 +02:00
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
2023-08-27 07:48:19 +02:00
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
2021-11-18 10:55:35 +01:00
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Reloading NGINX web server and $app's service..."
2021-11-18 10:55:35 +01:00
2024-08-29 15:01:46 +02:00
ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="SERVER RUNNING"
2024-08-29 15:01:46 +02:00
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
2024-08-29 15:01:46 +02:00
ynh_script_progression "Restoration completed for $app"