mirror of
https://github.com/YunoHost-Apps/sogo_ynh.git
synced 2024-09-03 20:26:07 +02:00
Simplify and cleanup scripts
This commit is contained in:
parent
b9584056d5
commit
89c99ff2d2
8 changed files with 27 additions and 84 deletions
|
@ -50,8 +50,6 @@ ram.runtime = "200M"
|
|||
[resources]
|
||||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#=================================================
|
||||
|
||||
config_nginx() {
|
||||
nginx_config="$YNH_APP_BASEDIR/conf/nginx.conf"
|
||||
nginx_config="/etc/nginx/conf.d/$domain/$app.conf"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
principals_block='
|
||||
|
@ -37,6 +37,8 @@ location /.well-known/carddav {
|
|||
rewrite ^ https://$server_name/SOGo/dav/;
|
||||
}'
|
||||
|
||||
ynh_add_nginx_config
|
||||
|
||||
if ! is_url_handled -d "$domain" -p "/principals"; then
|
||||
echo "$principals_block" >> "$nginx_config"
|
||||
fi
|
||||
|
@ -49,7 +51,19 @@ location /.well-known/carddav {
|
|||
if ! is_url_handled -d "$domain" -p "/.wellk-nown/carddav"; then
|
||||
echo "$carddav_block" >> "$nginx_config"
|
||||
fi
|
||||
ynh_add_nginx_config
|
||||
ynh_store_file_checksum --file="$nginx_config"
|
||||
systemctl reload nginx.service
|
||||
}
|
||||
|
||||
set_permissions() {
|
||||
chown -R "$app:$app" "/etc/$app"
|
||||
chmod -R u=rwX,g=rX,o= "/etc/$app"
|
||||
|
||||
chown -R "$app:$app" "/var/log/$app"
|
||||
chmod -R u=rwX,g=rX,o= "/var/log/$app"
|
||||
|
||||
chown root: "/etc/cron.d/$app"
|
||||
chmod 644 "/etc/cron.d/$app"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -22,9 +22,6 @@ ynh_print_info --message="Declaring files to be backed up..."
|
|||
# Backup the nginx configuration
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
# Backup the logrotate configuration
|
||||
ynh_backup --src_path="/etc/logrotate.d/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP VARIOUS FILES
|
||||
#=================================================
|
||||
|
@ -32,9 +29,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
|
|||
# Backup SOGo configuration
|
||||
ynh_backup --src_path="/etc/$app"
|
||||
|
||||
# Backup Stunnel configuration
|
||||
ynh_backup --src_path="/etc/stunnel/$app.conf"
|
||||
|
||||
# Backup cron
|
||||
ynh_backup --src_path="/etc/cron.d/$app"
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ fi
|
|||
ynh_script_progression --message="Updating NGINX configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
config_nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
|
|
|
@ -20,37 +20,14 @@ ynh_script_progression --message="Configuring application..." --weight=3
|
|||
|
||||
mkdir -p "/etc/$app"
|
||||
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
|
||||
chown -R "$app:$app" "/etc/$app"
|
||||
chmod -R 750 "/etc/$app"
|
||||
|
||||
# Configure stunnel
|
||||
# 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
|
||||
ynh_add_config --template="stunnel.conf" --destination="/etc/stunnel/$app.conf"
|
||||
|
||||
# Enable stunnel at startup
|
||||
ynh_replace_string --match_string="ENABLED=0" --replace_string="ENABLED=1" --target_file="/etc/default/stunnel4"
|
||||
|
||||
#=================================================
|
||||
# SETUP A CRON
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up a cron..." --weight=1
|
||||
|
||||
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
||||
chown root: "/etc/cron.d/$app"
|
||||
chmod 644 "/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
||||
|
||||
config_nginx
|
||||
|
||||
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
|
||||
|
||||
yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
|
||||
|
||||
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
|
||||
chown -R "$app:$app" "/var/log/$app"
|
||||
chmod -R 750 "/var/log/$app"
|
||||
set_permissions
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
|
|
@ -14,11 +14,7 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
|
||||
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
|
||||
if ynh_exec_warn_less yunohost service status "sogo" >/dev/null; then
|
||||
ynh_script_progression --message="Removing sogo service integration..." --weight=1
|
||||
yunohost service remove "sogo"
|
||||
fi
|
||||
|
||||
# Remove the dedicated systemd config
|
||||
ynh_remove_systemd_config
|
||||
|
|
|
@ -17,37 +17,19 @@ ynh_script_progression --message="Restoring the MySQL database..." --weight=1
|
|||
|
||||
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
|
||||
|
||||
#=================================================
|
||||
# RESTORE VARIOUS FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring various files..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/$app"
|
||||
chown -R "$app:$app" "/etc/$app"
|
||||
chmod -R 750 "/etc/$app"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/stunnel/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/cron.d/$app"
|
||||
|
||||
ynh_restore_file --origin_path="/var/log/$app"
|
||||
chown -R "$app:$app" "/var/log/$app"
|
||||
chmod -R 750 "/var/log/$app"
|
||||
ynh_restore
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
systemctl enable "$app.service" --quiet
|
||||
yunohost service add "sogo" --description="Groupware for E-Mail, Contacts and Calender" --log="/var/log/$app/$app.log"
|
||||
|
||||
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
|
||||
set_permissions
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
|
@ -55,15 +37,17 @@ ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
|
|||
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
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name="nginx" --action=reload
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
|
|
@ -31,27 +31,6 @@ ynh_script_progression --message="Configuring application..." --weight=1
|
|||
|
||||
# Configure SOGO
|
||||
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
|
||||
chown -R "$app:$app" "/etc/$app"
|
||||
chmod -R 750 "/etc/$app"
|
||||
|
||||
# Configure stunnel
|
||||
ynh_add_config --template="stunnel.conf" --destination="/etc/stunnel/$app.conf"
|
||||
|
||||
# Enable stunnel at startup
|
||||
ynh_replace_string --match_string="ENABLED=0" --replace_string="ENABLED=1" --target_file="/etc/default/stunnel4"
|
||||
|
||||
# Protect logs dir
|
||||
chown -R "$app:$app" "/var/log/$app"
|
||||
chmod -R 750 "/var/log/$app"
|
||||
|
||||
#=================================================
|
||||
# SETUP A CRON
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up a cron..." --weight=1
|
||||
|
||||
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
||||
chown root: "/etc/cron.d/$app"
|
||||
chmod 644 "/etc/cron.d/$app"
|
||||
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
|
|
Loading…
Reference in a new issue