1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/sogo_ynh.git synced 2024-09-03 20:26:07 +02:00
This commit is contained in:
ericgaspar 2022-01-15 10:05:56 +01:00
parent 60e8005d64
commit 2d1e0d1c13
4 changed files with 97 additions and 37 deletions

View file

@ -42,6 +42,12 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SOGo CONFIGURATION
#=================================================

View file

@ -92,8 +92,14 @@ ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
# To fix the issue https://sogo.nu/bugs/view.php?id=31 we need stunnel to be able to connect correctly to the smtp server
config_stunnel
# Install crontab
config_cron
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setuping a cron..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# NGINX CONFIGURATION
@ -137,7 +143,7 @@ ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_hea
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log"
yunohost service add $app --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE

View file

@ -3,68 +3,109 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# Stop script if errors
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
#### Remove this function if there's nothing to clean before calling the remove script.
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
ynh_script_progression --message="Loading settings..."
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_app_setting_get --app $app --key path)
final_path=$(ynh_app_setting_get --app $app --key final_path)
db_name=$(ynh_app_setting_get --app $app --key db_name)
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#=================================================
# CHECK IF THE APP CAN BE RESTORED
ynh_webpath_available --domain $domain --path_url $path_url \
|| ynh_die --message "Path not available: ${domain}${path_url}"
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
install_dependance
ynh_install_app_dependencies $pkg_dependencies
# Restore all config and data
ynh_script_progression --message="Restoring files..." --weight=10
ynh_restore
#=================================================
# RESTORE THE MYSQL DATABASE
ynh_script_progression --message="Restoring database..." --weight=3
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
ynh_mysql_setup_db --db_name $db_name --db_user $db_user --db_pwd $db_pwd
ynh_mysql_connect_as --user $db_user --password $db_pwd --database $db_name < ./db.sql
#=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
# Enable stunnel at startup
ynh_replace_string --match_string "ENABLED=0" --replace_string "ENABLED=1" --target_file /etc/default/stunnel4
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Protecting directory..."
set_permission
# SETUP LOGROTATE
ynh_use_logrotate --logfile /var/log/$app/sogo.log --nonappend
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
# Register service
yunohost service add $app --log "/var/log/$app/sogo.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" --nonappend
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd"
ynh_systemd_action --service_name=stunnel4 --action="restart" --log_path="systemd"
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
# Restart services
ynh_script_progression --message="Starting SOGo services..." --weight=3
systemctl restart sogo
systemctl restart stunnel4
systemctl reload nginx
systemctl restart cron
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -111,8 +111,15 @@ ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
# Configure stunnel
config_stunnel
# Install crontab
config_cron
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setuping a cron..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#Configure Nginx
config_nginx