1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dont-code_ynh.git synced 2024-09-03 18:26:34 +02:00
dont-code_ynh/scripts/restore

102 lines
3.7 KiB
Text
Raw Normal View History

2022-12-27 17:59:56 +01:00
#!/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
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1
2024-01-03 23:19:38 +01:00
ynh_restore_file --origin_path="$install_dir"
2022-12-27 17:59:56 +01:00
2024-01-03 23:19:38 +01:00
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
2022-12-30 10:21:10 +01:00
2022-12-27 17:59:56 +01:00
#=================================================
2022-12-30 10:21:10 +01:00
# RESTORE THE DOCUMENTS DIRECTORY
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
ynh_script_progression --message="Restoring the document storage..." --weight=1
2022-12-27 17:59:56 +01:00
2024-01-04 16:57:56 +01:00
ynh_restore_file --origin_path="$data_dir" --not_mandatory
2022-12-27 17:59:56 +01:00
mkdir -p $document_dir
2022-12-27 17:59:56 +01:00
2024-01-05 15:06:01 +01:00
chmod -R o-rwx "$data_dir"
chown -R $app:www-data "$data_dir"
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
# ADD SSH ACCESS
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
# Make sure the .ssh and files have the correct access rights
if [ -n "$public_key" ]; then
ynh_script_progression --message="Restoring ssh access for dev..." --weight=1
2022-12-30 10:21:10 +01:00
2024-01-04 16:57:56 +01:00
chown -R "$app:$app" "$install_dir/.ssh"
chmod 700 "$install_dir/.ssh"
chmod 600 "$install_dir/.ssh/authorized_keys"
2022-12-27 17:59:56 +01:00
2024-01-05 16:27:40 +01:00
_install_restart_script_and_sudoers
2024-01-04 16:57:56 +01:00
fi
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
# INSTALL MONGO
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
ynh_script_progression --message="Reinstalling MongoDB..." --weight=1
2022-12-27 17:59:56 +01:00
2024-01-04 16:57:56 +01:00
# Install the required version of Mongo
ynh_install_mongo --mongo_version=$mongo_version
2022-12-27 17:59:56 +01:00
#=================================================
2022-12-30 10:21:10 +01:00
# RESTORE THE MONGO DATABASES
2022-12-27 17:59:56 +01:00
#=================================================
2023-01-03 14:51:52 +01:00
ynh_script_progression --message="Restoring the Mongo databases..." --weight=1
2022-12-27 17:59:56 +01:00
2024-01-04 16:57:56 +01:00
for db_name in "${MONGO_DB_LIST[@]}"; do
ynh_mongo_setup_db --db_user="$db_user" --db_pwd="$db_pwd" --db_name="dontCode$tenant${db_name}"
2024-04-04 11:26:21 +02:00
ynh_mongo_restore_db --database="dontCode$tenant$db_name" < "./dump-dontCode${tenant}${db_name}.bson"
2022-12-30 10:21:10 +01:00
done
2024-01-05 16:27:40 +01:00
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
# RESTORE SYSTEM CONFIGURATIONS
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
2022-12-27 17:59:56 +01:00
2024-01-04 16:57:56 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2022-12-27 17:59:56 +01:00
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2024-07-21 10:55:27 +02:00
mkdir --parents /var/log/$app
2022-12-27 17:59:56 +01:00
2024-01-04 16:57:56 +01:00
for service_name in "${SERVICES_LIST[@]}"; do
ynh_restore_file --origin_path="/etc/systemd/system/${app}-${service_name}.service"
systemctl enable "${app}-${service_name}.service" --quiet
yunohost service add "${app}-${service_name}" --description="Dont-code platform ${service_name} service" --log="/var/log/${app}/${service_name}-${app}.log"
2022-12-30 10:21:10 +01:00
done
2022-12-27 17:59:56 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
2024-01-04 16:57:56 +01:00
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
2022-12-27 17:59:56 +01:00
#=================================================
2024-01-04 16:57:56 +01:00
ynh_script_progression --message="Reloading NGINX web server and $app's services..." --weight=1
for service_name in "${SERVICES_LIST[@]}"; do
ynh_systemd_action --service_name="${app}-${service_name}" --action="start" --log_path="/var/log/$app/$app.log"
done
2022-12-27 17:59:56 +01:00
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last