1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lutim_ynh.git synced 2024-09-03 19:36:24 +02:00
lutim_ynh/scripts/restore

171 lines
6.1 KiB
Text
Raw Normal View History

2015-11-18 00:28:42 +01:00
#!/bin/bash
2017-03-19 19:16:10 +01:00
#=================================================
2017-09-05 00:25:58 +02:00
# GENERIC START
2017-03-19 19:16:10 +01:00
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
2016-11-08 13:33:28 +01:00
2017-09-05 00:25:58 +02:00
# Load common variables for all scripts.
2020-04-24 20:16:33 +02:00
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
2017-09-05 00:25:58 +02:00
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
2017-12-16 23:22:54 +01:00
ynh_clean_setup () {
2019-01-18 19:56:43 +01:00
# Clean installation remaining that are not handle by the remove script.
2020-04-24 19:59:27 +02:00
ynh_clean_check_starting
2017-12-16 23:22:54 +01:00
}
2017-09-05 00:25:58 +02:00
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
2016-12-14 16:10:00 +01:00
2017-03-19 19:16:10 +01:00
#=================================================
# LOAD SETTINGS
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Loading settings..." --weight=2
2017-03-19 19:16:10 +01:00
app=$YNH_APP_INSTANCE_NAME
2020-01-02 18:40:15 +01:00
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
2015-11-18 00:28:42 +01:00
2017-03-19 19:16:10 +01:00
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Validating restoration parameters..."
2015-11-18 00:28:42 +01:00
2020-01-02 18:40:15 +01:00
ynh_webpath_available --domain=$domain --path_url=$path_url \
2020-04-24 19:59:27 +02:00
|| ynh_die --message="Path not available: ${domain}${path_url}"
2017-03-19 19:16:10 +01:00
test ! -d $final_path \
2020-04-24 19:59:27 +02:00
|| ynh_die --message="There is already a directory: $final_path "
2015-11-18 00:28:42 +01:00
2018-05-20 20:55:15 +02:00
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Activating maintenance mode..." --weight=2
2018-05-20 20:55:15 +02:00
ynh_maintenance_mode_ON
2017-03-19 19:16:10 +01:00
#=================================================
# STANDARD RESTORE STEPS
#=================================================
2019-01-18 19:56:43 +01:00
# RESTORE THE NGINX CONFIGURATION
2017-03-19 19:16:10 +01:00
#=================================================
2015-11-18 00:28:42 +01:00
2020-01-02 18:40:15 +01:00
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
2015-11-18 00:28:42 +01:00
2017-03-19 19:16:10 +01:00
#=================================================
2019-01-18 19:56:43 +01:00
# RESTORE THE APP MAIN DIR
2017-03-19 19:16:10 +01:00
#=================================================
2020-10-05 22:02:46 +02:00
ynh_script_progression --message="Restoring Lutim main directory..."
2016-12-14 16:10:00 +01:00
2020-01-02 18:40:15 +01:00
ynh_restore_file --origin_path="$final_path"
2016-12-14 16:10:00 +01:00
2017-03-19 19:16:10 +01:00
#=================================================
2019-01-18 19:56:43 +01:00
# RECREATE THE DEDICATED USER
2017-03-19 19:16:10 +01:00
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
2017-03-19 19:16:10 +01:00
2019-01-18 19:56:43 +01:00
# Create the dedicated user (if not existing)
2020-01-02 18:40:15 +01:00
ynh_system_user_create --username=$app
2017-03-19 19:16:10 +01:00
#=================================================
# RESTORE USER RIGHTS
#=================================================
2015-11-18 00:28:42 +01:00
2019-01-18 19:56:43 +01:00
# Restore permissions on app files
2017-09-05 00:25:58 +02:00
chown -R $app: $final_path
2016-08-05 16:59:55 +02:00
2017-03-19 19:16:10 +01:00
#=================================================
# SPECIFIC RESTORE
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Reinstalling dependencies..." --weight=60
2017-03-19 19:16:10 +01:00
2020-11-01 14:31:10 +01:00
ynh_install_app_dependencies $pkg_depencencies
2017-03-19 19:16:10 +01:00
#=================================================
2019-01-18 19:56:43 +01:00
# ADVERTISE SERVICE IN ADMIN PANEL
2017-03-19 19:16:10 +01:00
#=================================================
2020-01-02 18:40:15 +01:00
yunohost service add $app --log $final_path/log/production.log
2017-03-19 19:16:10 +01:00
#=================================================
# RESTORE SYSTEMD
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Restoring the systemd configuration..."
2017-03-19 19:16:10 +01:00
2020-01-02 18:40:15 +01:00
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
2017-09-05 00:25:58 +02:00
systemctl enable $app.service
2017-03-19 19:16:10 +01:00
#=================================================
2019-01-18 19:56:43 +01:00
# RESTORE THE CRON FILE
2017-03-19 19:16:10 +01:00
#=================================================
2020-01-02 18:40:15 +01:00
ynh_restore_file --origin_path="/etc/cron.d/$app"
2017-03-19 19:16:10 +01:00
#=================================================
# SETUP LOG FILE
#=================================================
2015-11-18 00:28:42 +01:00
2019-01-18 19:56:43 +01:00
# Making log a symbolic link to /var/log
2017-09-05 00:25:58 +02:00
mkdir -p /var/log/$app/
touch /var/log/$app/production.log
2017-09-08 13:10:22 +02:00
chown $app -R /var/log/$app
2017-03-19 19:16:10 +01:00
#=================================================
2019-01-18 19:56:43 +01:00
# RESTORE LOGROTATE CONFIGURATION
#=================================================
2020-01-02 18:40:15 +01:00
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
2016-05-15 11:36:31 +02:00
2017-03-19 19:16:10 +01:00
#=================================================
# GENERIC FINALISATION
#=================================================
# RELOAD NGINX
#=================================================
2020-10-05 22:02:46 +02:00
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
2016-08-05 16:59:55 +02:00
2020-01-02 18:40:15 +01:00
ynh_systemd_action --service_name=nginx --action=reload
2017-05-24 16:48:26 +02:00
#=================================================
# START AND CHECK LUTIM BOOTING
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Restarting Lutim..." --weight=3
2017-05-24 16:48:26 +02:00
2019-01-18 19:56:43 +01:00
# Wait for lutim to be fully started
2019-01-13 19:10:28 +01:00
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
2017-12-16 23:22:54 +01:00
2018-05-20 20:55:15 +02:00
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
2020-01-02 18:40:15 +01:00
ynh_script_progression --message="Disabling maintenance mode..." --weight=7
2018-05-20 20:55:15 +02:00
ynh_maintenance_mode_OFF
2017-12-16 23:22:54 +01:00
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
2019-01-20 17:44:06 +01:00
# Get main domain and buid the url of the admin panel of the app.
admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
2019-01-30 19:27:17 +01:00
echo "You can find a config file at $final_path/lutim.conf
2017-12-16 23:22:54 +01:00
2019-01-30 19:27:17 +01:00
You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
2019-01-20 17:44:06 +01:00
2019-01-30 19:27:17 +01:00
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__." > mail_to_send
2017-12-16 23:22:54 +01:00
2020-01-02 18:40:15 +01:00
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
2019-01-30 16:19:40 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2020-10-05 22:02:46 +02:00
ynh_script_progression --message="Restoration completed for Lutim" --last