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

Add message and use getops for helper's args

This commit is contained in:
Josué Tille 2019-06-07 23:09:30 +02:00
parent 33ff5e69b8
commit 6127c7635b
No known key found for this signature in database
GPG key ID: 716A6C99B04194EF
10 changed files with 157 additions and 106 deletions

View file

@ -62,9 +62,8 @@ LDAP and HTTP auth are supported.
### Supported architectures ### Supported architectures
* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/sogo%20(Community).svg)](https://ci-apps.yunohost.org/ci/apps/sogo/) * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/sog%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/sogo/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/sogo%20(Community).svg)](https://ci-apps-arm.yunohost.org/ci/apps/sogo/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/sogo%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/sogo/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/jenkins/job/sogo%20(Community).svg)](https://ci-stretch.nohost.me/jenkins/job/sogo/)
<!--Limitations <!--Limitations
------------ ------------

View file

@ -24,7 +24,7 @@
"mysql" "mysql"
], ],
"requirements": { "requirements": {
"yunohost": ">= 2.7.14" "yunohost": ">= 3.5.2.2"
}, },
"arguments": { "arguments": {
"install" : [ "install" : [
@ -53,6 +53,10 @@
"en": "Is it a public site ? To be able to use caldav and cardav you need to set as public.", "en": "Is it a public site ? To be able to use caldav and cardav you need to set as public.",
"fr": "Est-ce un site public ? Pour pouvoir utiliser caldav et cardav vous devz mettre en public." "fr": "Est-ce un site public ? Pour pouvoir utiliser caldav et cardav vous devz mettre en public."
}, },
"help": {
"en": "If it's not public, everybody which want to access to any page of SOGo need to be authenticated on the SSO. On the public mode anybody can access to the authentication page. The shared calendar will be also accessible by anybody who has this link",
"fr": "Si n'est pas publique, n'importe qui veux accéder à n'importe quelle page de SOGo doit être authentifié dans le SSO. Dans le mode publique n'importe qui peut accéder à la page d'authentification de SOGo. Les agenda partagé seront aussi accessible par n'import qui qui à ce liens."
},
"default": true "default": true
} }
] ]

View file

@ -18,37 +18,37 @@ config_sogo() {
# Avoid if the directory don't exist # Avoid if the directory don't exist
mkdir -p /etc/$app mkdir -p /etc/$app
ynh_backup_if_checksum_is_different /etc/$app/sogo.conf ynh_backup_if_checksum_is_different --file /etc/$app/sogo.conf
cp ../conf/sogo.conf /etc/$app/sogo.conf cp ../conf/sogo.conf /etc/$app/sogo.conf
ynh_replace_string "__APP__" "$app" /etc/$app/sogo.conf ynh_replace_string --match_string __APP__ --replace_string $app --target_file /etc/$app/sogo.conf
ynh_replace_string "__ADMINUSER__" "$admin" /etc/$app/sogo.conf ynh_replace_string --match_string __ADMINUSER__ --replace_string $admin --target_file /etc/$app/sogo.conf
ynh_replace_string "__DBUSER__" "$db_user" /etc/$app/sogo.conf ynh_replace_string --match_string __DBUSER__ --replace_string $db_user --target_file /etc/$app/sogo.conf
ynh_replace_string "__DBPASS__" "$db_pwd" /etc/$app/sogo.conf ynh_replace_string --match_string __DBPASS__ --replace_string $db_pwd --target_file /etc/$app/sogo.conf
ynh_replace_string "__PORT__" "$port" /etc/$app/sogo.conf ynh_replace_string --match_string __PORT__ --replace_string $port --target_file /etc/$app/sogo.conf
ynh_replace_string "__SMTP_PORT__" "$smtp_port" /etc/$app/sogo.conf ynh_replace_string --match_string __SMTP_PORT__ --replace_string $smtp_port --target_file /etc/$app/sogo.conf
ynh_store_file_checksum /etc/$app/sogo.conf ynh_store_file_checksum --file /etc/$app/sogo.conf
} }
config_stunnel() { config_stunnel() {
ynh_backup_if_checksum_is_different /etc/stunnel/$app.conf ynh_backup_if_checksum_is_different --file /etc/stunnel/$app.conf
cp ../conf/stunnel.conf /etc/stunnel/$app.conf cp ../conf/stunnel.conf /etc/stunnel/$app.conf
ynh_replace_string "__SMTP_PORT__" "$smtp_port" /etc/stunnel/$app.conf ynh_replace_string --match_string __SMTP_PORT__ --replace_string $smtp_port --target_file /etc/stunnel/$app.conf
ynh_store_file_checksum /etc/stunnel/$app.conf ynh_store_file_checksum --file /etc/stunnel/$app.conf
# Enable stunnel at startup # Enable stunnel at startup
ynh_replace_string "ENABLED=0" "ENABLED=1" /etc/default/stunnel4 ynh_replace_string --match_string "ENABLED=0" --replace_string "ENABLED=1" --target_file /etc/default/stunnel4
} }
config_cron() { config_cron() {
ynh_backup_if_checksum_is_different /etc/cron.d/$app ynh_backup_if_checksum_is_different --file /etc/cron.d/$app
cp ../conf/cron /etc/cron.d/$app cp ../conf/cron /etc/cron.d/$app
ynh_replace_string "__APP__" "$app" /etc/cron.d/$app ynh_replace_string --match_string __APP__ --replace_string $app --target_file /etc/cron.d/$app
ynh_store_file_checksum /etc/cron.d/$app ynh_store_file_checksum --file /etc/cron.d/$app
systemctl restart cron systemctl restart cron
} }
@ -83,7 +83,7 @@ location /.well-known/carddav {
} }
" >> "$nginx_config_path" " >> "$nginx_config_path"
ynh_store_file_checksum "$nginx_config_path" ynh_store_file_checksum --file "$nginx_config_path"
systemctl reload nginx systemctl reload nginx
} }

View file

@ -14,27 +14,36 @@ ynh_abort_if_errors
source ../settings/scripts/experimental_helper.sh source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
domain=$(ynh_app_setting_get $app domain) ynh_script_progression --message="Loading installation settings..."
db_name=$(ynh_app_setting_get $app db_name)
# retrieve useful param
domain=$(ynh_app_setting_get --app $app --key domain)
db_name=$(ynh_app_setting_get --app $app --key db_name)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
#================================================= #=================================================
ynh_script_progression --message="Backing up configuration..."
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup SOGo config # Backup SOGo config
ynh_backup "/etc/$app" ynh_backup --src_path "/etc/$app"
# Backup stunnel config # Backup stunnel config
ynh_backup "/etc/stunnel/$app.conf" ynh_backup --src_path "/etc/stunnel/$app.conf"
# Backup Logs
ynh_backup "/var/log/$app"
# Backup Cron # Backup Cron
ynh_backup "/etc/cron.d/$app" ynh_backup --src_path "/etc/cron.d/$app"
# Backup Logs
ynh_script_progression --message="Backing up logs"
ynh_backup --src_path "/var/log/$app"
# BACKUP THE MYSQL DATABASE # BACKUP THE MYSQL DATABASE
ynh_script_progression --message="Backing up database"
ynh_mysql_dump_db "$db_name" > db.sql ynh_mysql_dump_db "$db_name" > db.sql
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -14,36 +14,42 @@ ynh_abort_if_errors
source ./experimental_helper.sh source ./experimental_helper.sh
source ./_common.sh source ./_common.sh
ynh_script_progression --message="Loading installation settings..."
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
old_domain=$YNH_APP_OLD_DOMAIN old_domain=$YNH_APP_OLD_DOMAIN
domain=$YNH_APP_NEW_DOMAIN domain=$YNH_APP_NEW_DOMAIN
path_url=$(ynh_normalize_url_path ${YNH_APP_NEW_PATH:-'/'}) path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
port=$(ynh_app_setting_get $app web_port) port=$(ynh_app_setting_get --app $app --key web_port)
admin=$(ynh_app_setting_get $app admin) admin=$(ynh_app_setting_get --app $app --key admin)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app $app --key final_path)
# Check if the new path stay /SOGo if not exit # Check if the new path stay /SOGo if not exit
if [[ $path_url != "/SOGo" ]] if [[ $path_url != "/SOGo" ]]
then then
ynh_die "You can't use an other path than '/SOGo'" ynh_die --message "You can't use an other path than '/SOGo'"
fi fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
ynh_script_progression --message="Updating nginx configuration..."
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the domain for nginx # Change the domain for nginx
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path" ynh_delete_file_checksum --file "$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf mv $nginx_conf_path /etc/nginx/conf.d/$domain.d/$app.conf
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
#Configure Nginx #Configure Nginx
config_nginx config_nginx
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -1,13 +0,0 @@
#!/bin/bash
# ============= FUTURE YUNOHOST HELPER =============
# Delete a file checksum from the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_remove_file_checksum file
# | arg: file - The file for which the checksum will be deleted
ynh_delete_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_delete $app $checksum_setting_name
}

View file

@ -14,6 +14,8 @@ ynh_abort_if_errors
source ./experimental_helper.sh source ./experimental_helper.sh
source ./_common.sh source ./_common.sh
ynh_script_progression --message="Validating installation parameters..."
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
@ -23,35 +25,38 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
path_url="/SOGo" path_url="/SOGo"
# final_path="/opt/yunohost/$app" # final_path="/opt/yunohost/$app"
# STORE SETTINGS FROM MANIFEST
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app is_public $is_public
# Check web path availability
ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is not available, please use an other domain or path."
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register --app $app --domain $domain --path_url $path_url
# Find a port for SOGo # Find a port for SOGo
port=$(ynh_find_port 20000) ynh_script_progression --message="Finding available ports..."
ynh_app_setting_set $app web_port $port port=$(ynh_find_port --port 20000)
smtp_port=$(ynh_find_port $((port+1))) smtp_port=$(ynh_find_port --port $((port+1)))
ynh_app_setting_set $app smtp_port $smtp_port
# STORE SETTINGS FROM MANIFEST
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app $app --key admin --value $admin
ynh_app_setting_set --app $app --key is_public --value $is_public
ynh_app_setting_set --app $app --key smtp_port --value $smtp_port
ynh_app_setting_set --app $app --key web_port --value $port
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
ynh_script_progression --message="Installing dependencies..." --weight=7
install_dependance install_dependance
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
ynh_script_progression --message="Configuring MySQL database..."
db_name=$(ynh_sanitize_dbid $app) db_name=$(ynh_sanitize_dbid $app)
db_user=$db_name db_user=$db_name
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set --app $app --key db_name --value $db_name
ynh_app_setting_set $app db_user $db_user ynh_app_setting_set --app $app --key db_user --value $db_user
db_pwd=$(ynh_string_random 15) ynh_mysql_setup_db --db_name $db_name --db_user $db_user
ynh_mysql_setup_db $db_name $db_user $db_pwd
ynh_script_progression --message="Configuring application..." --weight=3
# Configure SOGO # Configure SOGO
config_sogo config_sogo
@ -64,6 +69,7 @@ config_stunnel
config_cron config_cron
#Configure Nginx #Configure Nginx
ynh_script_progression --message="Configuring nginx..." --weight=1
config_nginx config_nginx
#================================================= #=================================================
@ -71,20 +77,26 @@ config_nginx
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
ynh_script_progression --message="Protecting directory..."
set_permission set_permission
# configure the sso # configure the sso
ynh_script_progression --message="Configuring permissions..."
if [ "$is_public" = "0" ]; if [ "$is_public" = "0" ];
then # Retire l'accès public then # Retire l'accès public
ynh_app_setting_delete $app skipped_uris ynh_app_setting_delete --app $app --key skipped_uris
else else
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set --app $app --key unprotected_uris --value "/"
fi fi
python3 add_sso_conf.py python3 add_sso_conf.py
# SETUP LOGROTATE # SETUP LOGROTATE
ynh_use_logrotate /var/log/$app/sogo.log --non-append ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/$app/sogo.log --non-append
# Restart services # Restart services
ynh_script_progression --message="Starting sogo services..." --weight=3
systemctl restart sogo systemctl restart sogo
systemctl restart stunnel4 systemctl restart stunnel4
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -7,40 +7,51 @@
# Source YunoHost helpers # Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Stop script if errors
set -u
# Import common cmd # Import common cmd
source ./experimental_helper.sh source ./experimental_helper.sh
source ./_common.sh source ./_common.sh
ynh_script_progression --message="Loading installation settings..."
# Retrieve app settings # Retrieve app settings
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app $app --key domain)
domain=$(ynh_app_setting_get $app domain) port=$(ynh_app_setting_get --app $app --key port)
port=$(ynh_app_setting_get $app port) db_name=$(ynh_app_setting_get --app $app --key db_name)
db_name=$(ynh_app_setting_get $app db_name) db_user=$(ynh_app_setting_get --app $app --key db_user)
db_user=$(ynh_app_setting_get $app db_user) final_path=$(ynh_app_setting_get --app $app --key final_path)
final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_script_progression --message="Removing dependencies" --weight=10
ynh_remove_app_dependencies ynh_remove_app_dependencies
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_user $db_name ynh_script_progression --message="Removing databases..."
ynh_mysql_remove_db --db_user $db_user --db_name $db_name
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_script_progression --message="Removing user data..."
ynh_secure_remove --file="$final_path"
ynh_script_progression --message="Removing configuration..."
# Remove sogo config # Remove sogo config
ynh_secure_remove "/etc/$app" ynh_secure_remove --file="/etc/$app"
# Remove stunnel config # Remove stunnel config
ynh_secure_remove "/etc/stunnel/$app.conf" ynh_secure_remove --file="/etc/stunnel/$app.conf"
# Remove custom SSO config # Remove custom SSO config
python3 remove_sso_conf.py python3 remove_sso_conf.py
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -14,47 +14,57 @@ ynh_abort_if_errors
source ../settings/scripts/experimental_helper.sh source ../settings/scripts/experimental_helper.sh
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
domain=$(ynh_app_setting_get $app domain) ynh_script_progression --message="Loading settings..."
path_url=$(ynh_app_setting_get $app path)
final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get --app $app --key domain)
db_name=$(ynh_app_setting_get $app db_name) 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)
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
ynh_webpath_available $domain $path_url \ ynh_webpath_available --domain $domain --path_url $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die --message "Path not available: ${domain}${path_url}"
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# Define and install dependencies # Define and install dependencies
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
install_dependance install_dependance
# Restore all config and data # Restore all config and data
ynh_script_progression --message="Restoring files..." --weight=10
ynh_restore ynh_restore
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_script_progression --message="Restoring database..." --weight=3
ynh_mysql_setup_db $db_name $db_name $db_pwd db_user=$db_name
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql 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
# Enable stunnel at startup # Enable stunnel at startup
ynh_replace_string "ENABLED=0" "ENABLED=1" /etc/default/stunnel4 ynh_replace_string --match_string "ENABLED=0" --replace_string "ENABLED=1" --target_file /etc/default/stunnel4
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
ynh_script_progression --message="Protecting directory..."
set_permission set_permission
python3 ../settings/scripts/add_sso_conf.py python3 ../settings/scripts/add_sso_conf.py
# SETUP LOGROTATE # SETUP LOGROTATE
ynh_use_logrotate /var/log/$app/sogo.log --non-append ynh_use_logrotate --logfile /var/log/$app/sogo.log --non-append
# Restart services # Restart services
ynh_script_progression --message="Starting SOGo services..." --weight=3
systemctl restart sogo systemctl restart sogo
systemctl restart stunnel4 systemctl restart stunnel4
systemctl reload nginx systemctl reload nginx
systemctl restart cron systemctl restart cron
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -14,16 +14,18 @@ ynh_abort_if_errors
source ./experimental_helper.sh source ./experimental_helper.sh
source ./_common.sh source ./_common.sh
ynh_script_progression --message="Loading installation settings..."
# LOAD SETTINGS # LOAD SETTINGS
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path $(ynh_app_setting_get $app path)) path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
admin=$(ynh_app_setting_get $app admin) admin=$(ynh_app_setting_get --app $app --key admin)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get --app $app --key is_public)
port=$(ynh_app_setting_get $app web_port) port=$(ynh_app_setting_get --app $app --key web_port)
smtp_port=$(ynh_app_setting_get $app smtp_port) smtp_port=$(ynh_app_setting_get --app $app --key smtp_port)
db_name=$(ynh_app_setting_get $app db_name) db_name=$(ynh_app_setting_get --app $app --key db_name)
db_user=$(ynh_app_setting_get $app db_user) db_user=$(ynh_app_setting_get --app $app --key db_user)
db_pwd=$(ynh_app_setting_get $app mysqlpwd) db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -39,35 +41,37 @@ ynh_abort_if_errors
# UPGRADE SETTINGS FROM OLD INSTALL # UPGRADE SETTINGS FROM OLD INSTALL
#================================================= #=================================================
ynh_script_progression --message="Fixing old settings..." --weight=1
if [[ ${is_public,,*} = "yes" ]] if [[ ${is_public,,*} = "yes" ]]
then then
is_public=1 is_public=1
ynh_app_setting_set $app is_public 1 ynh_app_setting_set --app $app --key is_public --value 1
fi fi
if [[ ${is_public,,*} = "no" ]] if [[ ${is_public,,*} = "no" ]]
then then
is_public=0 is_public=0
ynh_app_setting_set $app is_public 0 ynh_app_setting_set --app $app --key is_public --value 0
fi fi
if [[ -z $port ]] if [[ -z $port ]]
then then
# Find a port for SOGo # Find a port for SOGo
port=$(ynh_find_port 20000) port=$(ynh_find_port --port 20000)
ynh_app_setting_set $app web_port $port ynh_app_setting_set --app $app --key web_port --value $port
fi fi
if [[ -z $db_name ]] if [[ -z $db_name ]]
then then
db_name=$app db_name=$app
ynh_app_setting_set $app db_name $db_name ynh_app_setting_set --app $app --key db_name --value $db_name
fi fi
if [[ -z $db_user ]] if [[ -z $db_user ]]
then then
db_user=$app db_user=$app
ynh_app_setting_set $app db_user $db_user ynh_app_setting_set --app $app --key db_user --value $db_user
fi fi
#================================================= #=================================================
@ -75,8 +79,11 @@ fi
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
ynh_script_progression --message="Upgrading dependencies..."
install_dependance install_dependance
ynh_script_progression --message="Configuring application..."
# Configure SOGO # Configure SOGO
config_sogo config_sogo
@ -94,20 +101,26 @@ config_nginx
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
ynh_script_progression --message="Protecting directory..."
set_permission set_permission
# configure the sso # configure the sso
ynh_script_progression --message="Configuring permissions..."
if [ "$is_public" = "0" ]; if [ "$is_public" = "0" ];
then # Retire l'accès public then # Retire l'accès public
ynh_app_setting_delete $app skipped_uris ynh_app_setting_delete --app $app --key skipped_uris
else else
ynh_app_setting_set $app unprotected_uris "/" ynh_app_setting_set --app $app --key unprotected_uris --value "/"
fi fi
python3 add_sso_conf.py python3 add_sso_conf.py
# SETUP LOGROTATE # SETUP LOGROTATE
ynh_use_logrotate /var/log/$app/sogo.log --non-append ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/$app/sogo.log --non-append
# Restart services # Restart services
ynh_script_progression --message="Starting SOGo services..." --weight=3
systemctl restart sogo systemctl restart sogo
systemctl restart stunnel4 systemctl restart stunnel4
ynh_script_progression --message="Upgrade of $app completed" --last