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

Merge pull request #15 from YunoHost-Apps/linter

Linter
This commit is contained in:
Josue-T 2022-06-27 13:09:42 +02:00 committed by GitHub
commit 5480f5fbdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 608 additions and 389 deletions

129
README.md
View file

@ -1,121 +1,44 @@
SOGo for Yunohost
=================
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
[![Integration level](https://dash.yunohost.org/integration/sogo.svg)](https://dash.yunohost.org/appci/app/sogo) ![](https://ci-apps.yunohost.org/ci/badges/sogo.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/sogo.maintain.svg)
[![Install sogo with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=sogo)
# SOGo for YunoHost
> *This package allow you to install sogo quickly and simply on a YunoHost server.
If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
[![Integration level](https://dash.yunohost.org/integration/sogo.svg)](https://dash.yunohost.org/appci/app/sogo) ![Working status](https://ci-apps.yunohost.org/ci/badges/sogo.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/sogo.maintain.svg)
[![Install SOGo with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=sogo)
Overview
--------
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install SOGo quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
SOGo is an opensource groupware solution which has Webmail, a global address book and Calender and Contacts which can be synced via caldav or cardav.
**Shipped version:** 4.0.7-1
Screenshots
-----------
**Shipped version:** 5.0.1~ynh1
| Localized |Drag'n'Drop | Reminders | Delegation |
| :------------: | :------------: | :------------: | :------------: |
| ![](https://sogo.nu/img/features/localized.png) | ![](https://sogo.nu/img/features/dnd_01.png) | ![](https://sogo.nu/img/features/reminders.png) | ![](https://sogo.nu/img/features/delegation.png) |
| SOGo is available in over a dozen languages so you'll always feel at home. If your language is missing, you can easily contribute to the project and submit your translation. | Move messages to folders, drag contacts to address books, and modify events time and duration from the tip of your finger. Just like a desktop app. | Set alarms to important events and get alerted directly from your browser. | Set alarms to important events and get alerted directly from your browser. | Delegate access to your mail account or delegate an invitation to another person. |
**Demo:** https://demo.sogo.nu/SOGo/
## Documentation and resources
| Resource Reservation | HTML | Mail Return Receipt | Forward and Auto-Reply |
| :------------: | :------------: | :------------: | :------------: |
| ![](https://sogo.nu/img/features/resource.png) | ![](https://sogo.nu/img/features/html.png) | ![](https://sogo.nu/img/features/return-receipt.png) | ![](https://sogo.nu/img/features/auto-reply.png) |
| Define resources like projectors and conference rooms to automatically accept invitations for them while avoiding double-booking. | Compose HTML mail with the complete inline [rich-text editor](http://www.ckeditor.com). | Request or answer to return requests to confirm the arrival of messages. | Set an auto reply while on vacation or forward all your incoming mail to one ore many alternate email addresses. |
* Official app website: <https://sogo.nu/>
* Official admin documentation: <https://www.sogo.nu/support.html#/documentation>
* Upstream app code repository: <https://github.com/inverse-inc/sogo>
* YunoHost documentation for this app: <https://yunohost.org/app_sogo>
* Report a bug: <https://github.com/YunoHost-Apps/sogo_ynh/issues>
| S/MIME | Mail Filtering | Sharing | Recurring Events |
| :------------: | :------------: | :------------: | :------------: |
| ![](https://sogo.nu/img/features/security.png) | ![](https://sogo.nu/img/features/mail-filters.png) | ![](https://sogo.nu/img/features/sharing.png) | ![](https://sogo.nu/img/features/recurring-events.png) |
| Sign and encrypt messages using your personal secure certificate. Automatically manage public certificates you receive by email. | Define powerful server-side filters to automatically act on new messages. Forward, discard, reject, flag or move incoming mail depending on complex criteria. | Share your mail, calendars and address books with other users. Define specific rights to each person or group of persons. | Define precise recurrence pattern for your repeating events and create exceptions if necessary. |
## Developer info
| Free/Busy Time | Notifications | Categories | Multiple Mail Accounts | Export/Import |
| :------------: | :------------: | :------------: | :------------: | :------------: |
| ![](https://sogo.nu/img/features/freebusy.png) | ![](https://sogo.nu/img/features/notifications.png) | ![](https://sogo.nu/img/features/categories.png) | ![](https://sogo.nu/img/features/imap-accounts.png) | ![](https://sogo.nu/img/features/import.png) |
| Before sending an invitation, see the free/busy periods of attendees, either from the local SOGo server or a remote Microsoft Exchange server. Automatically set off-hours as busy if you like. | Be informed if someone modifies your calendar or automatically inform someone if your calendar changes. | Choose from a predefined set of categories or create your own categories and associate them to your events and contacts. | Configure all your mail accounts (IMAP) from SOGo and forget about login-in to multiple webmail services. | Export calendars or import events from a vCalendar file. Export contacts to LDIF or import cards from a LDIF of vCard file. Export a mailbox to zip archive. |
Demo
----
* [Official demo](https://sogo.nu/)
<!--## Configuration
TODO complete-->
Documentation
-------------
* Official documentation: https://sogo.nu/support.html#/documentation
* YunoHost documentation: There no other documentations, feel free to contribute.
YunoHost specific features
--------------------------
### Multi-users support
LDAP and HTTP auth are supported.
### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/sogo%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%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/sogo/)
<!--Limitations
------------
* Any known limitations.
Additional informations
-----------------------
* Other informations you would add about this application-->
Links
-----
* Report a bug: https://github.com/YunoHost-Apps/sogo_ynh/issues
* App website: https://sogo.nu/
* YunoHost website: https://yunohost.org/
---
Install
-------
From command line:
`sudo yunohost app install -l sogo https://github.com/YunoHost-Apps/sogo_ynh`
Upgrade
-------
From command line:
`sudo yunohost app upgrade sogo -u https://github.com/YunoHost-Apps/sogo_ynh`
Developers infos
----------------
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/sogo_ynh/tree/testing).
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/sogo_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/sogo_ynh/tree/testing --debug
or
sudo yunohost app upgrade sogo -u https://github.com/YunoHost-Apps/sogo_ynh/tree/testing --debug
```
License
-------
Sogo is published under the GPL-v2 and LGPL-v2 liencience : https://github.com/inverse-inc/sogo/blob/master/COPYING.GPL and https://github.com/inverse-inc/sogo/blob/master/COPYING.LGPL
Todo
----
-[ ] More Tests
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

44
README_fr.md Normal file
View file

@ -0,0 +1,44 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# SOGo pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/sogo.svg)](https://dash.yunohost.org/appci/app/sogo) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/sogo.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/sogo.maintain.svg)
[![Installer SOGo avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=sogo)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer SOGo rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
SOGo is an opensource groupware solution which has Webmail, a global address book and Calender and Contacts which can be synced via caldav or cardav.
**Version incluse :** 5.0.1~ynh1
**Démo :** https://demo.sogo.nu/SOGo/
## Documentations et ressources
* Site officiel de l'app : <https://sogo.nu/>
* Documentation officielle de l'admin : <https://www.sogo.nu/support.html#/documentation>
* Dépôt de code officiel de l'app : <https://github.com/inverse-inc/sogo>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_sogo>
* Signaler un bug : <https://github.com/YunoHost-Apps/sogo_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/sogo_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/sogo_ynh/tree/testing --debug
ou
sudo yunohost app upgrade sogo -u https://github.com/YunoHost-Apps/sogo_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -5,12 +5,10 @@
;; Test complet
; Manifest
domain="domain.tld" (DOMAIN)
path="/SOGo" (PATH)
admin="john" (USER)
language="French"
is_public=1 (PUBLIC|public=1|private=0)
port="20000" (PORT)
domain="domain.tld"
path="/SOGo"
admin="john"
is_public=1
; Checks
pkg_linter=1
setup_sub_dir=1
@ -20,11 +18,12 @@
setup_public=1
upgrade=1
upgrade=1 from_commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1
upgrade=1 from_commit=2fc174c57586df38506a07195decb08eed02f55f
backup_restore=1
multi_instance=0
incorrect_path=1
port_already_use=1 (8448)
change_url=0
;;; Upgrade options
; commit=cc07f5da79498ef948c31a99f6ace9ad0a5b9ec1
name=Before group permission support
; commit=2fc174c57586df38506a07195decb08eed02f55f
name=Before refactoring

View file

@ -1,6 +0,0 @@
SOURCE_URL=url of app's source
SOURCE_SUM=sha256 checksum
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -2,17 +2,17 @@
# Vacation messages expiration
# The credentials file should contain the sieve admin credentials (username:passwd)
0 0 * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds
0 0 * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds
# Session cleanup - runs every minute
# - Ajust the nbMinutes parameter to suit your needs
# Example: Sessions without activity since 60 minutes will be dropped:
* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool expire-sessions 60 > /dev/null 2>&1
* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-tool expire-sessions 60 > /dev/null 2>&1
# Email alarms - runs every minutes
# If you need to use SMTP AUTH for outgoing mails, specify credentials to use
# with '-p /path/to/credentialsFile' (same format as the sieve credentials)
* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-ealarms-notify > /dev/null 2>&1
* * * * * __APP__ /opt/yunohost/__APP__/sbin/sogo-ealarms-notify > /dev/null 2>&1
# Daily backups
# - writes to ~sogo/backups/ by default

View file

@ -12,5 +12,35 @@ ExecStart=/opt/yunohost/__APP__/sbin/sogod -WOWorkersCount ${PREFORK} -WOPidFile
PIDFile=/run/__APP__/sogo.pid
User=__APP__
# Sandboxing options to harden security
# Depending on specificities of your service/app, you may need to tweak these
# .. but this should be a good baseline
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed
ProtectSystem=full
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
# Denying access to capabilities that should not be relevant for webapps
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
[Install]
WantedBy=multi-user.target

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
SOGo is an opensource groupware solution which has Webmail, a global address book and Calender and Contacts which can be synced via caldav or cardav.

View file

@ -2,13 +2,20 @@
"name": "SOGo",
"id": "sogo",
"packaging_format": 1,
"license": "LGPL-2.1,GPL-2.0",
"url": "https://sogo.nu/",
"version": "4.0.7-1~ynh2",
"description": {
"en": "An opensource groupware for E-Mail, Contacts and Calender.",
"fr": "Un groupware opensource pour les e-mail, contacts et calendrier"
"en": "Opensource groupware for E-Mail, Contacts and Calender",
"fr": "Groupware opensource pour les e-mail, contacts et calendrier"
},
"version": "5.0.1~ynh1",
"url": "https://sogo.nu/",
"upstream": {
"license": "LGPL-2.1,GPL-2.0",
"website": "https://sogo.nu/",
"demo": "https://demo.sogo.nu/SOGo/",
"admindoc": "https://www.sogo.nu/support.html#/documentation",
"code": "https://github.com/inverse-inc/sogo"
},
"license": "LGPL-2.1,GPL-2.0",
"maintainer": {
"name": "Josué Tille",
"email": "josue@tille.ch"
@ -24,35 +31,21 @@
"mysql"
],
"requirements": {
"yunohost": ">= 4.1"
"yunohost": ">= 4.3.0"
},
"arguments": {
"install" : [
{
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a domain name for SOGo",
"fr": "Choisissez un nom de domaine pour SOGo"
},
"example": "example.com"
"type": "domain"
},
{
"name": "admin",
"type": "user",
"ask": {
"en": "Choose an admin user",
"fr": "Choisissez ladministrateur"
},
"example": "johndoe"
"type": "user"
},
{
"name": "is_public",
"type": "boolean",
"ask": {
"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."
},
"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."

View file

@ -4,16 +4,13 @@
# SET ALL CONSTANTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
# dependencies used by the app
pkg_dependencies="sogo stunnel4 memcached"
#=================================================
# DEFINE ALL COMMON FONCTIONS
#=================================================
install_dependance() {
ynh_install_app_dependencies sogo stunnel4 memcached
}
config_stunnel() {
ynh_add_config --template="stunnel.conf" --destination="/etc/stunnel/$app.conf"
@ -21,11 +18,6 @@ config_stunnel() {
ynh_replace_string --match_string "ENABLED=0" --replace_string "ENABLED=1" --target_file /etc/default/stunnel4
}
config_cron() {
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
systemctl restart cron
}
config_nginx() {
ynh_add_nginx_config

View file

@ -3,47 +3,78 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
# 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
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
# retrieve useful param
domain=$(ynh_app_setting_get --app $app --key domain)
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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
#=================================================
# STANDARD BACKUP STEPS
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info --message="Backing up configuration..."
#=================================================
# BACKUP THE NGINX CONFIGURATION
ynh_backup --src_path "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# Backup SOGo config
ynh_backup --src_path "/etc/$app"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup stunnel config
ynh_backup --src_path "/etc/stunnel/$app.conf"
#=================================================
# BACKUP SOGo CONFIGURATION
#=================================================
# Backup Cron
ynh_backup --src_path "/etc/cron.d/$app"
ynh_backup --src_path="/etc/$app"
# Backup Logs
ynh_print_info --message="Backing up logs"
ynh_backup --src_path "/var/log/$app"
#=================================================
# BACKUP STUNNEL CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/stunnel/$app.conf"
#=================================================
# BACKUP CRON
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP LOGS
#=================================================
ynh_backup --src_path="/var/log/$app"
#=================================================
# BACKUP THE MYSQL DATABASE
ynh_print_info --message="Backing up database"
ynh_mysql_dump_db "$db_name" > db.sql
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,30 +1,34 @@
#!/bin/bash
#=================================================
# GENERIC START
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# IMPORT GENERIC HELPERS
source _common.sh
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
ynh_script_progression --message="Loading installation settings..."
# RETRIEVE ARGUMENTS
old_domain=$YNH_APP_OLD_DOMAIN
domain=$YNH_APP_NEW_DOMAIN
path_url=$(ynh_normalize_url_path --path_url $YNH_APP_NEW_PATH)
path_url=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
port=$(ynh_app_setting_get --app $app --key web_port)
admin=$(ynh_app_setting_get --app $app --key admin)
final_path=$(ynh_app_setting_get --app $app --key final_path)
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
port=$(ynh_app_setting_get --app=$app --key=web_port)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Check if the new path stay /SOGo if not exit
@ -36,8 +40,7 @@ fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
ynh_script_progression --message="Updating nginx configuration..."
ynh_script_progression --message="Updating NGINX configuration..."
# MODIFY URL IN NGINX CONF
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -52,4 +55,8 @@ ynh_store_file_checksum --file "/etc/nginx/conf.d/$domain.d/$app.conf"
#Configure Nginx
config_nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -3,105 +3,172 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
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="Validating installation parameters..."
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
# Set variable
path_url="/SOGo"
# final_path="/opt/yunohost/$app"
# Register (book) web path
ynh_webpath_register --app $app --domain $domain --path_url $path_url
# Find a port for SOGo
ynh_script_progression --message="Finding available ports..."
port=$(ynh_find_port --port 20000)
smtp_port=$(ynh_find_port --port $((port+1)))
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# 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
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
port=$(ynh_find_port --port=20000)
ynh_app_setting_set --app=$app --key=web_port --value=$port
smtp_port=$(ynh_find_port --port=$((port+1)))
ynh_app_setting_set --app=$app --key=smtp_port --value=$smtp_port
#=================================================
# INSTALL DEPENDENCIES
ynh_script_progression --message="Installing dependencies..." --weight=7
install_dependance
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE A MYSQL DATABASE
ynh_script_progression --message="Configuring MySQL database..."
db_name=$(ynh_sanitize_dbid $app)
db_user=$db_name
ynh_app_setting_set --app $app --key db_name --value $db_name
ynh_app_setting_set --app $app --key db_user --value $db_user
ynh_mysql_setup_db --db_name $db_name --db_user $db_user
#=================================================
ynh_script_progression --message="Creating a MySQL database..." --weight=1
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring application..." --weight=3
# Configure SOGO
mkdir -p /etc/$app
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
ynh_add_config --template="../conf/sogo.conf" --destination="/etc/$app/sogo.conf"
# 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
config_stunnel
ynh_add_config --template="../conf/stunnel.conf" --destination="/etc/stunnel/$app.conf"
# Install crontab
config_cron
# 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="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
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
#Configure Nginx
ynh_script_progression --message="Configuring nginx..." --weight=1
config_nginx
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Protecting directory..." --weight=1
chown -R $app:$app /etc/$app
chmod u=rwX,g=rX,o= -R /etc/$app
chown -R $app:$app /var/log/$app
chmod u=rwX,g=rX,o= -R /var/log/$app
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
# SECURE FILES AND DIRECTORIES
ynh_script_progression --message="Protecting directory..."
set_permission
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --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=1
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd"
ynh_systemd_action --service_name=stunnel4 --action="restart" --log_path="systemd"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
if [ $is_public -eq 1 ]
then
ynh_permission_update --permission="main" --add="visitors"
fi
# configure the sso
ynh_script_progression --message="Configuring permissions..."
ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\
--label="Sync client" --protected=true --show_tile=false\
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
if [ "$is_public" == '1' ];
then
ynh_permission_update --permission "main" --add "visitors"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
# SETUP LOGROTATE
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/$app/sogo.log --nonappend
ynh_systemd_action --service_name=nginx --action=reload
# Register service
yunohost service add $app --log "/var/log/$app/sogo.log"
# Restart services
ynh_script_progression --message="Starting sogo services..." --weight=3
systemctl restart sogo
systemctl restart stunnel4
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -3,57 +3,92 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# Source YunoHost helpers
source _common.sh
source /usr/share/yunohost/helpers
ynh_script_progression --message="Loading installation settings..."
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Retrieve app settings
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app $app --key domain)
port=$(ynh_app_setting_get --app $app --key port)
db_name=$(ynh_app_setting_get --app $app --key db_name)
db_user=$(ynh_app_setting_get --app $app --key db_user)
final_path=$(ynh_app_setting_get --app $app --key final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove metapackage and its dependencies
ynh_script_progression --message="Removing dependencies" --weight=10
ynh_remove_app_dependencies
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_script_progression --message="Removing databases..."
ynh_mysql_remove_db --db_user $db_user --db_name $db_name
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
# Remove the app directory securely
ynh_script_progression --message="Removing user data..."
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
ynh_script_progression --message="Removing configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=3
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove sogo config
ynh_secure_remove --file="/etc/$app"
# Remove stunnel config
ynh_secure_remove --file="/etc/stunnel/$app.conf"
# Remove nginx config
ynh_script_progression --message="Removing nginx configuration..."
ynh_remove_nginx_config
# Remove service
yunohost service remove $app
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -3,69 +3,123 @@
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Import common cmd
source ../settings/scripts/experimental_helper.sh
# 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
# 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}"
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#=================================================
# STANDARD RESTORATION STEPS
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# 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
#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
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app"
ynh_restore_file --origin_path="/etc/$app"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Protecting directory..." --weight=1
chown -R $app:$app /etc/$app
chmod u=rwX,g=rX,o= -R /etc/$app
chown -R $app:$app /var/log/$app
chmod u=rwX,g=rX,o= -R /var/log/$app
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --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
#=================================================
# SECURE FILES AND DIRECTORIES
ynh_script_progression --message="Protecting directory..."
set_permission
# SETUP LOGROTATE
ynh_use_logrotate --logfile /var/log/$app/sogo.log --nonappend
# Register service
yunohost service add $app --log "/var/log/$app/sogo.log"
# 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

@ -3,36 +3,44 @@
#=================================================
# GENERIC START
#=================================================
# Import common cmd
source ./experimental_helper.sh
source ./_common.sh
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
ynh_script_progression --message="Loading installation settings..."
#=================================================
# LOAD SETTINGS
domain=$(ynh_app_setting_get --app $app --key domain)
path_url=$(ynh_normalize_url_path --path_url $(ynh_app_setting_get --app $app --key path))
admin=$(ynh_app_setting_get --app $app --key admin)
is_public=$(ynh_app_setting_get --app $app --key is_public)
port=$(ynh_app_setting_get --app $app --key web_port)
smtp_port=$(ynh_app_setting_get --app $app --key smtp_port)
db_name=$(ynh_app_setting_get --app $app --key db_name)
db_user=$(ynh_app_setting_get --app $app --key db_user)
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
port=$(ynh_app_setting_get --app=$app --key=web_port)
smtp_port=$(ynh_app_setting_get --app=$app --key=smtp_port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -40,81 +48,98 @@ ynh_abort_if_errors
#=================================================
# UPGRADE SETTINGS FROM OLD INSTALL
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_script_progression --message="Fixing old settings..." --weight=1
if [[ ${is_public,,*} = "yes" ]]
then
is_public=1
ynh_app_setting_set --app $app --key is_public --value 1
fi
if [[ ${is_public,,*} = "no" ]]
then
is_public=0
ynh_app_setting_set --app $app --key is_public --value 0
fi
if [[ -z $port ]]
then
if [[ -z $port ]]; then
# Find a port for SOGo
port=$(ynh_find_port --port 20000)
ynh_app_setting_set --app $app --key web_port --value $port
port=$(ynh_find_port --port=20000)
ynh_app_setting_set --app=$app --key=web_port --value=$port
fi
if [[ -z $db_name ]]
then
if [[ -z $db_name ]]; then
db_name=$app
ynh_app_setting_set --app $app --key db_name --value $db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
fi
if [[ -z $db_user ]]
then
if [[ -z $db_user ]]; then
db_user=$app
ynh_app_setting_set --app $app --key db_user --value $db_user
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
fi
# Manage migration form SOGo 3.x to SOGo 4.x (Debian stretch -> Buster)
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# Manage migrations
ynh_script_progression --message="Migrating database if needed..."
# FIXME use the new way to manage version when available on the core
app_previous_version="$(jq -r .version /etc/yunohost/apps/$app/manifest.json | cut -d~ -f1)"
if [[ "$app_previous_version" == 3.2.* ]]; then
if ynh_compare_current_package_version --comparison le --version 4.0.0~ynh0; then
ynh_replace_string --match_string __APP__ --replace_string $app --target_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_string --match_string __DBPASS__ --replace_string $db_pwd --target_file migrations/3.2-4.0.sh
bash migrations/3.2-4.0.sh
fi
if ! ynh_permission_exists --permission="sync_client"; then
# Create the required permissions
ynh_permission_create --permission="sync_client" --allowed='visitors' --auth_header=false\
--label="Sync client" --protected=true --show_tile=false\
--additional_urls="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1
# INSTALL DEPENDENCIES
ynh_script_progression --message="Upgrading dependencies..."
install_dependance
ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring application..."
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Configuring application..." --weight=1
# Configure SOGO
ynh_add_config --template="sogo.conf" --destination="/etc/$app/sogo.conf"
ynh_add_config --template="../conf/sogo.conf" --destination="/etc/$app/sogo.conf"
# Configure stunnel
config_stunnel
ynh_add_config --template="../conf/stunnel.conf" --destination="/etc/stunnel/$app.conf"
# Install crontab
config_cron
# 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="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
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
#Configure Nginx
config_nginx
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
ynh_script_progression --message="Protecting directory..."
set_permission
#=================================================
ynh_script_progression --message="Protecting directory..." --weight=1
chown -R $app:$app /etc/$app
chmod u=rwX,g=rX,o= -R /etc/$app
chown -R $app:$app /var/log/$app
chmod u=rwX,g=rX,o= -R /var/log/$app
# configure the sso
ynh_script_progression --message="Configuring permissions..."
@ -127,20 +152,44 @@ if ! ynh_permission_exists --permission sync_client; then
|| ynh_print_warn --message="Your file /etc/ssowat/""conf.json.persistent doesn't respect the json syntax. The config file wasn't cleaned. Please clean it manually."
else
ynh_permission_update --permission="sync_client" --add='visitors' --label="Sync client" --protected=true --show_tile=false
ynh_permission_url --permission "sync_client" --auth_header=false\
ynh_permission_url --permission "sync_client" --auth_header=false\
--add_url="/Microsoft-Server-ActiveSync" "/principals" "/.well-known/caldav" "/.well-known/carddav"
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
ynh_script_progression --message="Configuring log rotation..."
ynh_use_logrotate --logfile /var/log/$app/sogo.log --nonappend
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Register service
yunohost service add $app --log "/var/log/$app/sogo.log"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --logfile="/var/log/$app/sogo.log" --nonappend
# Restart services
ynh_script_progression --message="Starting SOGo services..." --weight=3
systemctl restart sogo
systemctl restart stunnel4
#=================================================
# 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=1
ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd"
ynh_systemd_action --service_name=stunnel4 --action="restart" --log_path="systemd"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last