1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/sogo_ynh.git synced 2024-09-03 20:26:07 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 03:02:25 +02:00 committed by Alexandre Aubin
parent e3bb393e5e
commit 3b3a61e442
8 changed files with 61 additions and 114 deletions

View file

@ -21,7 +21,8 @@ cpe = "cpe:2.3:a:alinto:sogo"
fund = "https://www.sogo.nu/partner.html" fund = "https://www.sogo.nu/partner.html"
[integration] [integration]
yunohost = ">= 11.2" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = false multi_instance = false
ldap = true ldap = true

View file

@ -1,11 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
#=================================================
# PERSONAL HELPERS
#================================================= #=================================================
config_nginx() { config_nginx() {
@ -46,7 +42,7 @@ location = /.well-known/carddav {
rewrite ^ https://$server_name/SOGo/dav/; rewrite ^ https://$server_name/SOGo/dav/;
}' }'
ynh_add_nginx_config ynh_config_add_nginx
if ! is_url_handled -d "$domain" -p "/principals"; then if ! is_url_handled -d "$domain" -p "/principals"; then
echo "$principals_block" >> "$nginx_config" echo "$principals_block" >> "$nginx_config"
@ -60,7 +56,7 @@ location = /.well-known/carddav {
if ! is_url_handled -d "$domain" -p "/.wellk-nown/carddav"; then if ! is_url_handled -d "$domain" -p "/.wellk-nown/carddav"; then
echo "$carddav_block" >> "$nginx_config" echo "$carddav_block" >> "$nginx_config"
fi fi
ynh_store_file_checksum --file="$nginx_config" ynh_store_file_checksum "$nginx_config"
systemctl reload nginx.service systemctl reload nginx.service
} }
@ -68,20 +64,16 @@ set_permissions() {
chown -R "$app:$app" "/etc/$app" chown -R "$app:$app" "/etc/$app"
chmod -R u=rwX,g=rX,o= "/etc/$app" chmod -R u=rwX,g=rX,o= "/etc/$app"
chown -R "$app:$app" "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:$app" "/var/log/$app"
chmod -R u=rwX,g=rX,o= "/var/log/$app" #REMOVEME? Assuming ynh_config_add_logrotate is called, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R u=rwX,g=rX,o= "/var/log/$app"
chown root: "/etc/cron.d/$app" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app" #REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 644 "/etc/cron.d/$app"
} }
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
is_url_handled() { is_url_handled() {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=dp #REMOVEME? local legacy_args=dp
declare -Ar args_array=( [d]=domain= [p]=path= ) declare -Ar args_array=( [d]=domain= [p]=path= )
local domain local domain
local path local path
@ -108,7 +100,3 @@ is_url_handled() {
return 1 return 1
fi fi
} }
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,49 +1,40 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# SYSTEM CONFIGURATION # SYSTEM CONFIGURATION
#================================================= #=================================================
# Backup the nginx configuration # Backup the nginx configuration
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
# Backup SOGo configuration # Backup SOGo configuration
ynh_backup --src_path="/etc/$app" ynh_backup "/etc/$app"
# Backup cron # Backup cron
ynh_backup --src_path="/etc/cron.d/$app" ynh_backup "/etc/cron.d/$app"
# Backup logs # Backup logs
ynh_backup --src_path="/var/log/$app" ynh_backup "/var/log/$app"
#================================================= #=================================================
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
#================================================= #=================================================
ynh_print_info --message="Backing up the MySQL database..." ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql ynh_mysql_dump_db > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,29 +1,21 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Check if the new path stay /SOGo if not exit # Check if the new path stay /SOGo if not exit
if [[ $path != "/SOGo" ]]; then if [[ $path != "/SOGo" ]]; then
ynh_die --message "You can't use an other path than '/SOGo'" ynh_die "You can't use an other path than '/SOGo'"
fi fi
#================================================= #=================================================
# STANDARD MODIFICATIONS ynh_script_progression "Updating NGINX configuration..."
#=================================================
ynh_script_progression --message="Updating NGINX configuration..."
ynh_change_url_nginx_config ynh_config_change_url_nginx
config_nginx config_nginx
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression "Change of URL completed for $app"

View file

@ -1,28 +1,22 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
if [[ $path != "/SOGo" ]]; then if [[ $path != "/SOGo" ]]; then
ynh_die --message "You can't install SOGo on other path than '/SOGo'" ynh_die "You can't install SOGo on other path than '/SOGo'"
fi fi
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring application..." --weight=3 ynh_script_progression "Configuring application..."
mkdir -p "/etc/$app" mkdir -p "/etc/$app"
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf" ynh_config_add --template="sogo.conf" --destination="/etc/$app/sogo.conf"
config_nginx config_nginx
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend ynh_config_add_logrotate "/var/log/$app/sogo.log"
yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log" yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
@ -31,12 +25,12 @@ set_permissions
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" ynh_systemctl --service="$app" --action="restart" --log_path="systemd"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -1,44 +1,38 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 ynh_script_progression "Removing system configurations related to $app..."
yunohost service remove "sogo" yunohost service remove "sogo"
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_config_remove_systemd
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_config_remove_logrotate
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_config_remove_nginx
#================================================= #=================================================
# SPECIFIC REMOVE # SPECIFIC REMOVE
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." --weight=1 ynh_script_progression "Removing various files..."
ynh_secure_remove --file="/etc/$app" ynh_safe_rm "/etc/$app"
# Remove stunnel config # Remove stunnel config
ynh_secure_remove --file="/etc/stunnel/$app.conf" ynh_safe_rm "/etc/stunnel/$app.conf"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -13,20 +7,19 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql ynh_mysql_db_shell < ./db.sql
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." --weight=1 ynh_script_progression "Restoring various files..."
ynh_restore ynh_restore_everything
#================================================= #=================================================
# RESTORE SYSTEM CONFIGURATIONS # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_script_progression "Restoring system configurations related to $app..."
yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log" yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
set_permissions set_permissions
@ -34,22 +27,22 @@ set_permissions
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" ynh_systemctl --service="$app" --action="restart" --log_path="systemd"
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_script_progression "Reloading NGINX web server..."
ynh_systemd_action --service_name="nginx" --action=reload ynh_systemctl --service="nginx" --action=reload
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend ynh_config_add_logrotate "/var/log/$app/sogo.log"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -1,60 +1,54 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# UPGRADE SETTINGS FROM OLD INSTALL # UPGRADE SETTINGS FROM OLD INSTALL
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression "Ensuring downward compatibility..."
# Manage migrations # Manage migrations
ynh_script_progression --message="Migrating database if needed..." ynh_script_progression "Migrating database if needed..."
if ynh_compare_current_package_version --comparison le --version 4.0.0~ynh0; then if ynh_app_upgrading_from_version_before_or_equal_to 4.0.0~ynh0; then
ynh_replace_string --match_string __APP__ --replace_string $app --target_file migrations/3.2-4.0.sh ynh_replace --match __APP__ --replace $app --file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file migrations/3.2-4.0.sh ynh_replace --match __DBUSER__ --replace $db_user --file migrations/3.2-4.0.sh
ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file migrations/3.2-4.0.sh ynh_replace --match __DBPASS__ --replace $db_pwd --file migrations/3.2-4.0.sh
bash migrations/3.2-4.0.sh bash migrations/3.2-4.0.sh
fi fi
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Configuring application..." --weight=1 ynh_script_progression "Configuring application..."
# Configure SOGO # Configure SOGO
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf" ynh_config_add --template="sogo.conf" --destination="/etc/$app/sogo.conf"
#================================================= #=================================================
# REAPPLY SYSTEM CONFIGURATIONS # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 ynh_script_progression "Upgrading system configurations related to $app..."
config_nginx config_nginx
yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log" yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend ynh_config_add_logrotate "/var/log/$app/sogo.log"
set_permissions set_permissions
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression "Starting $app's systemd service..."
ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" ynh_systemctl --service="$app" --action="restart" --log_path="systemd"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"