mirror of
https://github.com/YunoHost-Apps/rocketchat_ynh.git
synced 2024-09-03 20:16:25 +02:00
88 lines
3.5 KiB
Bash
88 lines
3.5 KiB
Bash
#!/bin/bash
|
|
|
|
# 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
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
ynh_script_progression "Loading installation settings..."
|
|
|
|
db_user=$db_name
|
|
mongo_version=$(ynh_app_setting_get --key=mongo_version)
|
|
|
|
#=================================================
|
|
# RESTORE THE APP MAIN DIR
|
|
#=================================================
|
|
ynh_script_progression "Restoring the app main directory..."
|
|
|
|
ynh_restore "$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 | 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"
|
|
#=================================================
|
|
# SPECIFIC RESTORATION
|
|
#=================================================
|
|
# REINSTALL DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression "Reinstalling dependencies..."
|
|
|
|
# Define and install dependencies
|
|
ynh_nodejs_install
|
|
ynh_hide_warnings ynh_install_mongo
|
|
|
|
#=================================================
|
|
# RESTORE THE MONGODB DATABASE
|
|
#=================================================
|
|
ynh_script_progression "Restoring the MongoDB database..."
|
|
|
|
db_pwd=$(ynh_app_setting_get --key=db_pwd)
|
|
ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
|
ynh_mongo_restore_db < ./dump.bson
|
|
|
|
#=================================================
|
|
# CONFIGURE MONGOD
|
|
#=================================================
|
|
ynh_script_progression "Configuring mongod..."
|
|
|
|
ynh_replace --match="# engine:" --replace=" engine: wiredTiger" --file="/etc/mongod.conf"
|
|
ynh_replace --match="#replication:" --replace="replication:\n replSetName: rs01" --file="/etc/mongod.conf"
|
|
|
|
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"
|
|
|
|
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())"
|
|
fi
|
|
|
|
#=================================================
|
|
# RESTORE SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
# RESTORE THE PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Restoring system configurations related to $app..."
|
|
|
|
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
ynh_restore "/etc/systemd/system/$app.service"
|
|
systemctl enable $app.service --quiet
|
|
|
|
ynh_restore "/etc/logrotate.d/$app"
|
|
|
|
yunohost service add $app --description="Team collaboration communication platform" --log="/var/log/$app/$app.log"
|
|
|
|
#=================================================
|
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
|
#=================================================
|
|
ynh_script_progression "Reloading NGINX web server and $app's service..."
|
|
|
|
ynh_systemctl --service=$app --action="start" --log_path="systemd" --wait_until="SERVER RUNNING"
|
|
|
|
ynh_systemctl --service=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Restoration completed for $app"
|