mirror of
https://github.com/YunoHost-Apps/radicale_ynh.git
synced 2024-09-03 20:16:14 +02:00
158 lines
4.9 KiB
Bash
158 lines
4.9 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source ../settings/scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
# Load common variables for all scripts.
|
|
source ../settings/scripts/_variables
|
|
|
|
#=================================================
|
|
# MANAGE SCRIPT FAILURE
|
|
#=================================================
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
infcloud=$(ynh_app_setting_get $app infcloud)
|
|
path_url=$(ynh_app_setting_get $app path)
|
|
admin=$(ynh_app_setting_get $app admin)
|
|
|
|
#=================================================
|
|
# CHECK IF THE APP CAN BE RESTORED
|
|
#=================================================
|
|
|
|
ynh_webpath_available $domain $path_url \
|
|
|| ynh_die "Path not available: ${domain}${path_url}"
|
|
test ! -d $final_path \
|
|
|| ynh_die "There is already a directory: $final_path "
|
|
test ! -d "/opt/yunohost/$app" \
|
|
|| ynh_die "There is already a directory: /opt/yunohost/$app "
|
|
|
|
#=================================================
|
|
# ACTIVATE MAINTENANCE MODE
|
|
#=================================================
|
|
|
|
ynh_maintenance_mode_ON
|
|
|
|
#=================================================
|
|
# STANDARD RESTORE STEPS
|
|
#=================================================
|
|
# RESTORE OF THE NGINX CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
|
|
#=================================================
|
|
# INSTALL DEPENDENCIES
|
|
#=================================================
|
|
|
|
ynh_install_app_dependencies $app_depencencies
|
|
|
|
#=================================================
|
|
# RESTORE OF THE MAIN DIR OF THE APP
|
|
#=================================================
|
|
|
|
ynh_restore_file "$final_path"
|
|
mkdir -p /opt/yunohost
|
|
ynh_restore_file "/opt/yunohost/$app"
|
|
|
|
#=================================================
|
|
# RECREATE OF THE DEDICATED USER
|
|
#=================================================
|
|
|
|
ynh_system_user_create $app # Recreate the dedicated user, if not exist
|
|
|
|
#=================================================
|
|
# RESTORE OF THE PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
|
|
if [ $infcloud -eq 1 ]
|
|
then
|
|
ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf"
|
|
ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini"
|
|
ynh_system_reload --service_name=php5-fpm
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC RESTORE
|
|
#=================================================
|
|
# RESTORE USER RIGHTS
|
|
#=================================================
|
|
|
|
chown radicale: -R /opt/yunohost/$app
|
|
|
|
chown -R radicale: $final_path
|
|
mkdir -p /var/log/$app
|
|
touch /var/log/$app/$app.log
|
|
chown radicale -R /var/log/$app
|
|
|
|
#=================================================
|
|
# RESTORE THE UWSGI CONFIG
|
|
#=================================================
|
|
|
|
ynh_restore_file "/etc/uwsgi/apps-available/radicale.ini"
|
|
ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
|
|
|
|
# Ajoute le service au monitoring de Yunohost.
|
|
yunohost service add uwsgi --log "/var/log/uwsgi/app/radicale.log"
|
|
|
|
#=================================================
|
|
# RESTORE THE RADICALE CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_restore_file "/etc/$app"
|
|
|
|
#=================================================
|
|
# BACKUP OF THE LOGROTATE CONFIGURATION
|
|
#=================================================
|
|
|
|
ynh_restore_file "/etc/logrotate.d/$app"
|
|
|
|
#=================================================
|
|
# GENERIC FINALISATION
|
|
#=================================================
|
|
# RELOAD NGINX AND UWSGI
|
|
#=================================================
|
|
|
|
ynh_system_reload --service_name=uwsgi --action=restart
|
|
ynh_system_reload --service_name=nginx
|
|
|
|
#=================================================
|
|
# DEACTIVE MAINTENANCE MODE
|
|
#=================================================
|
|
|
|
ynh_maintenance_mode_OFF
|
|
|
|
#=================================================
|
|
# SEND A README FOR THE ADMIN
|
|
#=================================================
|
|
|
|
if [ $infcloud -eq 1 ]
|
|
then
|
|
infcloud_config="
|
|
InfCloud has its own config file, at $final_path/infcloud/config.js
|
|
"
|
|
else
|
|
infcloud_config=""
|
|
fi
|
|
|
|
message="Use the file /etc/radicale/config to change the main configuration of radicale.
|
|
The file /etc/radicale/logging to change the level of logging.
|
|
And the file /etc/radicale/rights to edit the way the calendars will be sharing.
|
|
$infcloud_config
|
|
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/radicale_ynh"
|
|
|
|
ynh_send_readme_to_admin --app_message="$message" --recipients="$admin"
|