2016-05-04 14:17:07 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
2019-03-04 16:23:36 +01:00
|
|
|
# IMPORT GENERIC HELPERS
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
|
2021-02-13 19:19:24 +01:00
|
|
|
source ../settings/scripts/_common.sh
|
2019-03-04 16:23:36 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
2016-05-04 14:17:07 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
2019-03-04 16:23:36 +01:00
|
|
|
# MANAGE SCRIPT FAILURE
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
|
2019-03-04 16:23:36 +01:00
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
2017-04-20 19:34:26 +02:00
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Loading settings..."
|
2017-08-28 16:34:15 +02:00
|
|
|
|
2017-04-20 19:34:26 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2016-05-07 02:00:48 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Validating restoration parameters..."
|
2017-08-28 16:34:15 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
|
|
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD RESTORATION STEPS
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INSTALL SHELLINABOX
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Installing shellinabox..." --weight=7
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
ynh_package_update
|
2021-02-13 19:19:24 +01:00
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
2017-08-28 16:34:15 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RESTORE THE APP MAIN DIR
|
|
|
|
#=================================================
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Restoring the app main directory..." --weight=3
|
2017-08-28 16:34:15 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_restore_file --origin_path="/etc/shellinabox"
|
|
|
|
ynh_restore_file --origin_path="/etc/default/shellinabox"
|
2018-03-08 00:25:33 +01:00
|
|
|
|
|
|
|
# Allow the service to log in syslog
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_replace_string --match_string=" -- -q --background" --replace_string=" -- --background" --target_file="/etc/init.d/shellinabox"
|
|
|
|
|
2018-03-08 00:51:15 +01:00
|
|
|
systemctl daemon-reload
|
2018-03-08 00:25:33 +01:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_systemd_action --service_name=shellinabox --action=restart
|
2017-08-28 16:34:15 +02:00
|
|
|
|
2017-12-04 22:02:18 +01:00
|
|
|
#=================================================
|
|
|
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
yunohost service add $app
|
|
|
|
|
2017-08-28 16:34:15 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2021-02-13 19:34:25 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
2017-08-28 16:34:15 +02:00
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-03-04 16:24:27 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2019-05-20 17:03:46 +02:00
|
|
|
ynh_script_progression --message="Restoration completed for $app" --last
|