1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/radicale_ynh.git synced 2024-09-03 20:16:14 +02:00

Merge pull request #29 from YunoHost-Apps/example

apply last example_ynh
This commit is contained in:
yalh76 2022-03-22 00:16:42 +01:00 committed by GitHub
commit 8fd34e47db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 662 additions and 646 deletions

55
.github/ISSUE_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,55 @@
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
---
**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
- *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
---
### Describe the bug
*A clear and concise description of what the bug is.*
### Context
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
- If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
### Steps to reproduce
- *If you performed a command from the CLI, the command itself is enough. For example:*
```sh
sudo yunohost app install the_app
```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
1. *Go to '...'*
2. *Click on '...'*
3. *Scroll down to '...'*
4. *See error*
### Expected behavior
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
### Logs
*When an operation fails, YunoHost provides a simple way to share the logs.*
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
*If applicable and useful, add screenshots to help explain your problem.*

16
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Problem
- *Description of why you made this PR*
## Solution
- *And how do you fix that problem*
## PR Status
- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)
## Automatic tests
Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)

View file

@ -1,3 +1,8 @@
<!--
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.
-->
# Radicale for YunoHost
[![Integration level](https://dash.yunohost.org/integration/radicale.svg)](https://dash.yunohost.org/appci/app/radicale) ![](https://ci-apps.yunohost.org/ci/badges/radicale.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/radicale.maintain.svg)
@ -5,21 +10,19 @@
*[Lire ce readme en français.](./README_fr.md)*
> *This package allow you to install Radicale 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.*
> *This package allows you to install Radicale 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
Radicale is a small but powerful CalDAV (calendars, todo-lists) and CardDAV (contacts) server.
**Shipped version:** 1.1.6
**Shipped version of InfCloud:** 0.13.1
## Screenshots
**Shipped version:** 1.1.6~ynh6
## Demo
No demo available.
## Disclaimers / important information
## Configuration
@ -29,11 +32,6 @@ And the file `/etc/radicale/rights` to edit the way the calendars will be sharin
InfCloud has its own config file, at /var/www/radicale/infcloud/config.js
## Documentation
* Official documentation: https://github.com/Kozea/Radicale/blob/website/pages/user_documentation.rst
* YunoHost documentation: https://yunohost.org/#/app_radicale
## YunoHost specific features
* This package bring a web interface for Radicale named InfCloud.
@ -42,29 +40,21 @@ InfCloud has its own config file, at /var/www/radicale/infcloud/config.js
Supported, with LDAP and SSO only with radicale, not for InfCloud.
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/radicale%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/radicale/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/radicale%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/radicale/)
## Limitations
* The version 1.1.6 is relatively old. There's a version 2 of radicale, but this new version dos not support LDAP yet.
## Additionnal informations
## Documentation and resources
## Links
* Official app website: http://radicale.org
* Official admin documentation: https://github.com/Kozea/Radicale/blob/website/pages/user_documentation.rst
* Upstream app code repository: https://github.com/Kozea/Radicale
* YunoHost documentation for this app: https://yunohost.org/app_radicale
* Report a bug: https://github.com/YunoHost-Apps/radicale_ynh/issues
* Report a bug: https://github.com/YunoHost-Apps/radicale_ynh/issues
* Radicale website: http://radicale.org/
* InfCloud website: https://www.inf-it.com/open-source/clients/infcloud/
* YunoHost website: https://yunohost.org/
## Developer info
---
## Developers infos
Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/radicale_ynh/tree/testing).
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/radicale_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
@ -72,3 +62,5 @@ sudo yunohost app install https://github.com/YunoHost-Apps/radicale_ynh/tree/tes
or
sudo yunohost app upgrade radicale -u https://github.com/YunoHost-Apps/radicale_ynh/tree/testing --debug
```
**More info regarding app packaging:** https://yunohost.org/packaging_apps

View file

@ -4,22 +4,21 @@
[![Installer Radicale avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=radicale)
*[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Radicale rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/install_fr) pour savoir comment l'installer et en profiter.*
> *Ce package vous permet d'installer Radicale 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.*
## Résumé
## Vue d'ensemble
Radicale est un petit mais puissant serveur CalDAV (calendriers, listes de tâches) et CardDAV (contacts).
**Version embarquée :** 1.1.6
**Version embarquée de InfCloud :** 0.13.1
## Captures d'écran
**Version incluse :** 1.1.6~ynh6
## Démo
Aucune démo pour cette application.
## Avertissements / informations importantes
## Configuration
@ -29,11 +28,6 @@ Et le fichier `/etc/radicale/rights` pour éditer la façon dont les calendriers
InfCloud a son propre fichier de config, à /var/www/radicale/infcloud/config.js
## Documentation
* Official documentation : https://github.com/Kozea/Radicale/blob/website/pages/user_documentation.rst
* Documentation YunoHost : https://yunohost.org/#/app_radicale_fr
## Fonctionnalités spécifiques à YunoHost
* Ce package propose une interface web pour radicale nommée InfCloud.
@ -42,33 +36,27 @@ InfCloud a son propre fichier de config, à /var/www/radicale/infcloud/config.js
Supportée, avec LDAP et SSO seulement avec radicale, pas pour InfCloud.
#### Architectures supportées.
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/radicale%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/radicale/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/radicale%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/radicale/)
## Limitations
* La version 1.1.6 est relativement ancienne. Il existe une version 2 de radicale, mais cette nouvelle version ne supporte pas encore ldap.
## Informations additionnelles
## Documentations et ressources
## Liens
* Site officiel de l'app : http://radicale.org
* Documentation officielle de l'admin : https://github.com/Kozea/Radicale/blob/website/pages/user_documentation.rst
* Dépôt de code officiel de l'app : https://github.com/Kozea/Radicale
* Documentation YunoHost pour cette app : https://yunohost.org/app_radicale
* Signaler un bug : https://github.com/YunoHost-Apps/radicale_ynh/issues
* Reporter un bug : https://github.com/YunoHost-Apps/radicale_ynh/issues
* Site de Radicale : http://radicale.org/
* Site de InfCloud : https://www.inf-it.com/open-source/clients/infcloud/
* Site de YunoHost : https://yunohost.org/
---
## Informations à l'intention des développeurs
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/radicale_ynh/tree/testing).
Pour tester la branche testing, merci de procéder ainsi.
Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/radicale_ynh/tree/testing --debug
ou
sudo yunohost app upgrade radicale -u https://github.com/YunoHost-Apps/radicale_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps

View file

@ -2,9 +2,9 @@
; Manifest
domain="domain.tld"
path="/path"
language="French"
admin="john"
infcloud=1
language="French"
; Checks
pkg_linter=1
setup_sub_dir=1
@ -23,9 +23,9 @@
; Manifest
domain="domain.tld"
path="/path"
language="French"
admin="john"
infcloud=0
language="French"
; Checks
setup_sub_dir=1
setup_root=1
@ -33,7 +33,10 @@
setup_private=0
setup_public=0
upgrade=1
upgrade=1 from_commit=3be74eb1ebd9da9b13f9080fd7aa0e535ab09192
# 1.1.1
#upgrade=1 from_commit=3be74eb1ebd9da9b13f9080fd7aa0e535ab09192
# 1.1.6~ynh5
upgrade=1 from_commit=21b5079179979dbe53e2c916df175f19f24c74ab
backup_restore=1
multi_instance=0
port_already_use=0

View file

@ -43,7 +43,7 @@
dns_lookup = True
# Root URL of Radicale (starting and ending with a slash)
base_prefix = __PATH__/
base_prefix = __PATH__
# Possibility to allow URLs cleaned by a HTTP server, without the base_prefix
#can_skip_base_prefix = False

View file

@ -332,7 +332,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// port, ... (client installed into Davical "htdocs" subdirectory;
// works "out of the box", no additional setup required):
var globalNetworkCheckSettings={
href: 'https://__DOMAIN____PATH__/',
href: 'https://__DOMAIN____PATH__',
hrefLabel: null,
crossDomain: null,
additionalResources: [],
@ -474,7 +474,7 @@ var globalEnableKbNavigation=true;
// uk_UA (Українська [Ukrainian]; thanks Serge Yakimchuck)
// zh_CN (中国 [Chinese]; thanks Fandy)
// Example:
var globalInterfaceLanguage='__LANG__';
var globalInterfaceLanguage='__LANGUAGE__';
// globalInterfaceCustomLanguages

View file

@ -1,4 +1,5 @@
location __PATH__ {
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
try_files $uri @radicale;
}

View file

@ -27,8 +27,6 @@ group = __USER__
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
@ -48,8 +46,7 @@ group = __USER__
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
;listen.mode = 0660
; When POSIX Access Control Lists are supported you can set them using
; these options, value is a comma separated list of user/group names.
; When set, listen.owner and listen.group are ignored
@ -420,3 +417,14 @@ chdir = __FINALPATH__
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
; Common values to change to increase file upload limit
; php_admin_value[upload_max_filesize] = 50M
; php_admin_value[post_max_size] = 50M
; php_admin_flag[mail.add_x_header] = Off
; Other common parameters
; php_admin_value[max_execution_time] = 600
; php_admin_value[max_input_time] = 300
; php_admin_value[memory_limit] = 256M
; php_admin_flag[short_open_tag] = On

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Radicale is a small but powerful CalDAV (calendars, todo-lists) and CardDAV (contacts) server.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Radicale est un petit mais puissant serveur CalDAV (calendriers, listes de tâches) et CardDAV (contacts).

19
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,19 @@
## Configuration
Use the file `/etc/radicale/config` to change the main configuration of radicale.
The file `/etc/radicale/logging` to change the level of logging.
And the file `/etc/radicale/rights` to edit the way the calendars will be sharing.
InfCloud has its own config file, at /var/www/radicale/infcloud/config.js
## YunoHost specific features
* This package bring a web interface for Radicale named InfCloud.
#### Multi-users support
Supported, with LDAP and SSO only with radicale, not for InfCloud.
## Limitations
* The version 1.1.6 is relatively old. There's a version 2 of radicale, but this new version dos not support LDAP yet.

19
doc/DISCLAIMER_fr.md Normal file
View file

@ -0,0 +1,19 @@
## Configuration
Utilisez le fichier `/etc/radicale/config` pour modifier la configuration principale de radicale.
Le fichier `/etc/radicale/logging` pour changer le niveau de journalisation.
Et le fichier `/etc/radicale/rights` pour éditer la façon dont les calendriers seront partagés.
InfCloud a son propre fichier de config, à /var/www/radicale/infcloud/config.js
## Fonctionnalités spécifiques à YunoHost
* Ce package propose une interface web pour radicale nommée InfCloud.
#### Support multi-utilisateurs
Supportée, avec LDAP et SSO seulement avec radicale, pas pour InfCloud.
## Limitations
* La version 1.1.6 est relativement ancienne. Il existe une version 2 de radicale, mais cette nouvelle version ne supporte pas encore ldap.

0
doc/screenshots/.gitkeep Normal file
View file

View file

@ -6,8 +6,14 @@
"en": "CalDAV (calendar) and CardDAV (contact) synchronization server",
"fr": "Serveur de synchronisation CalDAV et CardDAV"
},
"version": "1.1.6~ynh5",
"version": "1.1.6~ynh6",
"url": "http://radicale.org",
"upstream": {
"license": "GPL-3.0,AGPL-3.0",
"website": "http://radicale.org",
"admindoc": "https://github.com/Kozea/Radicale/blob/website/pages/user_documentation.rst",
"code": "https://github.com/Kozea/Radicale"
},
"license": "GPL-3.0,AGPL-3.0",
"maintainer": {
"name": "",
@ -37,6 +43,16 @@
"example": "/radicale",
"default": "/radicale"
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose your interface language",
"fr": "Choisissez la langue de l'interface"
},
"choices" : ["Czech", "Danish", "German", "English/US", "Spanish", "French", "Italian", "Japan", "Hungarian", "Dutch", "Slovak", "Turkish", "Russian", "Ukrainian", "Chinese"],
"default" : "English/US"
},
{
"name": "admin",
"type": "user"
@ -49,16 +65,6 @@
"fr": "Installer l'interface web InfCloud?"
},
"default": true
},
{
"name": "language",
"type": "string",
"ask": {
"en": "Choose your interface language",
"fr": "Choisissez la langue de l'interface"
},
"choices" : ["Czech", "Danish", "German", "English/US", "Spanish", "French", "Italian", "Japan", "Hungarian", "Dutch", "Slovak", "Turkish", "Russian", "Ukrainian", "Chinese"],
"default" : "English/US"
}
]
}

View file

@ -8,14 +8,6 @@ YNH_PHP_VERSION="7.3"
pkg_dependencies="python-pip python-virtualenv virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python"
#=================================================
# PACKAGE CHECK BYPASSING...
#=================================================
IS_PACKAGE_CHECK () {
return $(env | grep -c container=lxc)
}
#=================================================
# BOOLEAN CONVERTER
#=================================================
@ -263,72 +255,6 @@ ynh_maintenance_mode_OFF () {
#=================================================
# Download and check integrity of a file from app.src_file
#
# The file conf/app.src_file need to contains:
#
# FILE_URL=Address to download the file
# FILE_SUM=Control sum
# # (Optional) Program to check the integrity (sha256sum, md5sum...)
# # default: sha256
# FILE_SUM_PRG=sha256
# # (Optionnal) Name of the local archive (offline setup support)
# # default: Name of the downloaded file.
# FILENAME=example.deb
#
# usage: ynh_download_file --dest_dir="/destination/directory" [--source_id=myfile]
# | arg: -d, --dest_dir= - Directory where to download the file
# | arg: -s, --source_id= - Name of the source file 'app.src_file' if it isn't '$app'
ynh_download_file () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [d]=dest_dir= [s]=source_id= )
local dest_dir
local source_id
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
source_id=${source_id:-app} # If the argument is not given, source_id equals "$app"
# Load value from configuration file (see above for a small doc about this file
# format)
local src_file="$YNH_CWD/../conf/${source_id}.src_file"
# If the src_file doesn't exist, use the backup path instead, with a "settings" directory
if [ ! -e "$src_file" ]
then
src_file="$YNH_CWD/../settings/conf/${source_id}.src_file"
fi
local file_url=$(grep 'FILE_URL=' "$src_file" | cut -d= -f2-)
local file_sum=$(grep 'FILE_SUM=' "$src_file" | cut -d= -f2-)
local file_sumprg=$(grep 'FILE_SUM_PRG=' "$src_file" | cut -d= -f2-)
local filename=$(grep 'FILENAME=' "$src_file" | cut -d= -f2-)
# Default value
file_sumprg=${file_sumprg:-sha256sum}
if [ "$filename" = "" ] ; then
filename="$(basename "$file_url")"
fi
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${filename}"
if test -e "$local_src"
then # Use the local source file if it is present
cp $local_src $filename
else # If not, download the source
local out=`wget -nv -O $filename $file_url 2>&1` || ynh_print_err $out
fi
# Check the control sum
echo "${file_sum} ${filename}" | ${file_sumprg} -c --status \
|| ynh_die "Corrupt file"
# Create the destination directory, if it's not already.
mkdir -p "$dest_dir"
# Move the file to its destination
mv $filename $dest_dir
}
#=================================================
# Create a changelog for an app after an upgrade.
#
# The changelog is printed into the file ./changelog for the time of the upgrade.

View file

@ -36,7 +36,7 @@ fi
#=================================================
# INSTALL OR REMOVE INFCLOUD
#=================================================
ynh_script_progression --message="$action_print InfCloud." --weight=9
ynh_script_progression --message="$action_print InfCloud."
if [ $infcloud -eq 1 ]
then
@ -177,4 +177,4 @@ ynh_app_setting_set $app infcloud $infcloud
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Execution completed" --last
ynh_script_progression --message="Execution completed"

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
ynh_script_progression --message="Retrieve arguments from the manifest" --weight=3
ynh_script_progression --message="Retrieve arguments from the manifest"
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path)
@ -50,7 +50,7 @@ fi
#=================================================
# RESET THE CONFIG FILE
#=================================================
ynh_script_progression --message="Reset the config file $config_file" --weight=9
ynh_script_progression --message="Reset the config file $config_file"
# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$config_file"
@ -146,7 +146,7 @@ fi
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config_file"
ynh_script_progression --message="Restart Radicale" --weight=2
ynh_script_progression --message="Restart Radicale"
# Restart uwsgi to restart radicale
ynh_systemd_action --action=restart --service_name=uwsgi
@ -155,4 +155,4 @@ ynh_systemd_action --action=restart --service_name=uwsgi
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Execution completed" --last
ynh_script_progression --message="Execution completed"

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,6 +14,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -23,10 +27,10 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
infcloud=$(ynh_app_setting_get $app infcloud)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
infcloud=$(ynh_app_setting_get --app=$app --key=infcloud)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -37,47 +41,46 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "$final_path"
ynh_backup "/opt/yunohost/$app"
ynh_backup --src_path="$final_path"
ynh_backup --src_path="/opt/yunohost/$app"
#=================================================
# BACKUP 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 PHP-FPM CONFIGURATION
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
if [ $infcloud -eq 1 ]
then
ynh_backup "/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
fi
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP UWSGI CONFIG
# BACKUP LOGROTATE
#=================================================
ynh_backup "/etc/uwsgi/apps-available/radicale.ini"
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP RADICALE CONFIGURATION
# BACKUP SYSTEMD
#=================================================
ynh_backup "/etc/$app"
ynh_backup --src_path="/etc/uwsgi/apps-available/radicale.ini"
#=================================================
# BACKUP LOGROTATE CONFIGURATION
# BACKUP VARIOUS FILES
#=================================================
ynh_backup "/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/$app/"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed. Please wait for YunoHost to create the backup."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
@ -25,26 +24,12 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings" --weight=2
ynh_script_progression --message="Loading installation settings..."
infcloud=$(ynh_app_setting_get $app infcloud)
final_path=$(ynh_app_setting_get $app final_path)
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# CHECK THE SYNTAX OF THE PATHS
#=================================================
ynh_script_progression --message="Check the syntax of the paths"
# Remove /infcloud in $old_path
if [ $infcloud -eq 1 ]
then
old_path="${old_path%/infcloud}"
fi
test -n "$old_path" || old_path="/"
test -n "$new_path" || new_path="/"
new_path=$(ynh_normalize_url_path $new_path)
old_path=$(ynh_normalize_url_path $old_path)
infcloud=$(ynh_app_setting_get --app=$app --key=infcloud)
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -55,6 +40,24 @@ path_url=$old_path
domain=$old_domain
ynh_maintenance_mode_ON
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
@ -71,48 +74,35 @@ then
change_path=1
fi
#=================================================
# MANAGE FAILURE OF THE SCRIPT
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Modify url in nginx configuration" --weight=2
ynh_script_progression --message="Updating NGINX web server configuration..."
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the nginx config file
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original nginx config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
# Set global variables for nginx helper
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Store path_url setting
ynh_app_setting_set $app path_url "$path_url"
# Create a dedicated nginx config
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for nginx
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# 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/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
@ -120,11 +110,10 @@ fi
#=================================================
# MODIFY CONFIG FILES
#=================================================
ynh_replace_string "^base_prefix = $old_path.*" "base_prefix = ${new_path%/}/" /etc/$app/config
ynh_replace_string --match_string="^base_prefix = $old_path.*" --replace_string="base_prefix = ${new_path%/}/" --target_file="/etc/$app/config"
if [ $infcloud -eq 1 ]; then
ynh_replace_string "href: 'https://$old_domain$old_path'," "href: 'https://$new_domain${new_path%/}/'," "$final_path/infcloud/config.js"
ynh_replace_string --match_string="href: 'https://$old_domain$old_path'," --replace_string="href: 'https://$new_domain${new_path%/}/'," --target_file="$final_path/infcloud/config.js"
fi
#=================================================
@ -138,29 +127,30 @@ then
echo "sudo yunohost --verbose app setting $app path -v \"${new_path%/}/infcloud\"; sudo yunohost app ssowatconf" | at now + 1 min >&2
domain_regex=$(echo "$new_domain" | sed 's@-@.@g')
# Radicale is always accessible (For access to ressources)
ynh_app_setting_set $app skipped_regex "$domain_regex$new_path"
ynh_app_setting_set --app=$app --key=skipped_regex --value="$domain_regex$new_path"
fi
#=================================================
# RESTART UWSGI
#=================================================
ynh_script_progression --message="Restart Radicale" --weight=2
ynh_systemd_action --action=restart --service_name=uwsgi
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=uwsgi --action="restart"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reload nginx"
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Disable maintenance mode" --weight=4
ynh_script_progression --message="Disable maintenance mode"
path_url=$old_path
domain=$old_domain
@ -170,4 +160,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed" --last
ynh_script_progression --message="Change of URL completed for $app"

View file

@ -1,7 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -10,22 +10,24 @@ source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE FAILURE OF THE SCRIPT
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
language=$YNH_APP_ARG_LANGUAGE
admin=$YNH_APP_ARG_ADMIN
infcloud=$YNH_APP_ARG_INFCLOUD
language=$YNH_APP_ARG_LANGUAGE
app=$YNH_APP_INSTANCE_NAME
@ -33,120 +35,145 @@ app=$YNH_APP_INSTANCE_NAME
version=$(ynh_app_upstream_version)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Check if the app can be installed"
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register $app $domain $path_url
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Store settings from manifest" --weight=4
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app infcloud $infcloud
ynh_app_setting_set $app version $version
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
ynh_app_setting_set --app=$app --key=infcloud --value=$infcloud
ynh_app_setting_set --app=$app --key=version --value=$version
ynh_app_setting_set $app overwrite_logging "1"
ynh_app_setting_set $app overwrite_config "1"
ynh_app_setting_set $app overwrite_infcloud "1"
ynh_app_setting_set $app overwrite_nginx "1"
ynh_app_setting_set $app overwrite_phpfpm "1"
ynh_app_setting_set $app admin_mail_html "1"
ynh_app_setting_set --app=$app --key=overwrite_logging --value="1"
ynh_app_setting_set --app=$app --key=overwrite_config --value="1"
ynh_app_setting_set --app=$app --key=overwrite_infcloud --value="1"
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="1"
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="1"
ynh_app_setting_set --app=$app --key=admin_mail_html --value="1"
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Install dependencies" --weight=25
ynh_script_progression --message="Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Create the directory and set the path in the config
mkdir -p "$final_path/collections"
# Copy files to the right place
cp ../conf/radicale.wsgi $final_path
# Copy extra files
cp -a ../sources/extra_files_radicale/. "$final_path"
if [ $infcloud -eq 1 ]
then
# Download and uncompress the source into final_path
ynh_setup_source --dest_dir="$final_path/infcloud"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
# Set default permissions as radicale do.
chmod 666 -R $final_path/default_collections
chmod 777 $final_path/default_collections $final_path/default_collections/USER
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configure NGINX" --weight=2
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
ynh_add_nginx_config
if [ $infcloud -eq 1 ]
then
# Add InfCloud in NGINX config
ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf
ynh_replace_string --match_string="#INFCLOUD#" --replace_string="" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
fi
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"
#=================================================
# CREATE DEDICATED USER
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Create a dedicated user" --weight=2
# Create a dedicated system user
ynh_system_user_create $app
if [ $infcloud -eq 1 ]
then
ynh_script_progression --message="Configuring PHP-FPM..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
fi
#=================================================
# SPECIFIC SETUP
#=================================================
# INSTALL RADICALE IN A VIRTUALENV
#=================================================
ynh_script_progression --message="Install Radicale in a virtualenv" --weight=15
ynh_script_progression --message="Install Radicale in a virtualenv"
# Init virtualenv
virtualenv /opt/yunohost/$app
version=$(ynh_app_setting_get $app version $version)
version=$(ynh_app_setting_get --app=$app --key=version)
/opt/yunohost/$app/bin/pip install radicale==$version python-ldap
#=================================================
# COPY FILES INTO $FINAL_PATH
#=================================================
ynh_script_progression --message="Download, check and unpack source" --weight=2
# Create the directory and set the path in the config
mkdir "$final_path"
ynh_app_setting_set $app final_path $final_path
# Copy files to the right place
mkdir -p $final_path/collections
cp ../conf/radicale.wsgi $final_path
# Copy extra files
cp -a ../sources/extra_files_radicale/. "$final_path"
# regex.py file is patched to fix the awful commit e807c3d35bea9cfcfcacac83b1b17d748ea15a39 that stop the reading of "rights" file after the first match.
mv "$final_path/regex.py" /opt/yunohost/$app/lib/python*/site-packages/radicale/rights/regex.py
if [ $infcloud -eq 1 ]
then
#Instal InfCloud
# Backup the content of $final_path
final_path_backup=$final_path
# Modify final_path for InfCloud installation
final_path=$final_path/infcloud
# Download and uncompress the source into final_path
ynh_setup_source "$final_path"
# Restore the content of $final_path
final_path=$final_path_backup
fi
# useradd radicale -d /opt/yunohost/$app
chown radicale: -R /opt/yunohost/$app
find /opt/yunohost/$app/ -type d -exec chmod 2755 {} \;
find /opt/yunohost/$app/ -type f -exec chmod g+r,o+r {} \;
#=================================================
# CONFIGURE RADICALE
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configure Radicale" --weight=5
ynh_script_progression --message="Adding a configuration file..."
mkdir -p /etc/$app
cp ../conf/config /etc/$app/
cp ../conf/logging /etc/$app/
cp ../conf/rights /etc/$app/
ynh_replace_string "__PATH__" "${path_url%/}" /etc/$app/config
ynh_replace_string "__FINALPATH__" "$final_path" /etc/$app/config
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/$app/config"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "/etc/$app/logging"
ynh_add_config --template="../conf/config" --destination="/etc/$app/config"
ynh_add_config --template="../conf/logging" --destination="/etc/$app/logging"
ynh_add_config --template="../conf/rights" --destination="/etc/$app/rights"
chmod 755 /etc/$app/
chmod 644 /etc/$app/*
if [ $infcloud -eq 1 ]
then
# InfCloud configuration
@ -183,49 +210,18 @@ then
"Chinese") language="zh_CN"
;;
esac
ynh_app_setting_set $app language $language
cp ../conf/config.js "$final_path/infcloud/"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/infcloud/config.js"
ynh_replace_string "__PATH__" "${path_url%/}" "$final_path/infcloud/config.js"
ynh_replace_string "__LANG__" "$language" "$final_path/infcloud/config.js"
ynh_replace_string "__ADMIN__" "$admin" "$final_path/infcloud/config.js"
ynh_replace_string "__TIMEZONE__" "$(cat /etc/timezone)" "$final_path/infcloud/config.js"
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/infcloud/config.js"
ynh_app_setting_set --app=$app --key=language --value=$language
timezone=$(cat /etc/timezone)
ynh_add_config --template="../conf/config.js" --destination="$final_path/infcloud/config.js"
chmod 440 "$final_path/infcloud/config.js"
chown $app:www-data "$final_path/infcloud/config.js"
fi
#=================================================
# SET PERMISSIONS ON RADICALE'S DIRECTORIES
#=================================================
# useradd radicale -d /opt/yunohost/$app
chown radicale: -R /opt/yunohost/$app
chown -R radicale: $final_path
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown radicale -R /var/log/$app
# Set default permissions as radicale do.
chmod 666 -R $final_path/default_collections
chmod 777 $final_path/default_collections $final_path/default_collections/USER
# Set permissions
chmod 755 /etc/$app/
find /opt/yunohost/$app/ -type d -exec chmod 2755 {} \;
find /opt/yunohost/$app/ -type f -exec chmod g+r,o+r {} \;
chmod 644 /etc/$app/*
#=================================================
# CONFIGURE UWSGI FOR RADICALE
#=================================================
cp ../conf/radicale.ini /etc/uwsgi/apps-available/
ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
#=================================================
# GENERATE CALENDARS AND ADDRESS BOOKS FOR ALL USERS
#=================================================
ynh_script_progression --message="Generate calendars and address books for all users" --weight=3
ynh_script_progression --message="Generate calendars and address books for all users"
# Create default calendars and address books for each users
while read user
@ -235,71 +231,78 @@ do
# List all users and remove the space after username
done <<< "$(yunohost user list | grep username | cut -d ":" -f 2 | cut -c 2-)"
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
ynh_script_progression --message="Restart Radicale" --weight=2
ynh_systemd_action --action=restart --service_name=uwsgi
yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log"
#=================================================
# PREPARE THE HOOKS
#=================================================
# Modify the hooks for create user collections and to remove them.
ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_create
ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_delete
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../hooks/post_user_create"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../hooks/post_user_delete"
#=================================================
# GENERIC FINALISATION
# SETUP SYSTEMD
#=================================================
# SETUP SSOWAT
ynh_script_progression --message="Configuring a systemd service..."
cp ../conf/radicale.ini /etc/uwsgi/apps-available/
ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
#=================================================
ynh_script_progression --message="Setup SSOwat" --weight=3
if [ $infcloud -eq 1 ]
then
# Add /infcloud to the path of radicale to access it from the portal
# Replace radicale by InfCloud into YunoHost portal
ynh_app_setting_set $app path ${path_url%/}/infcloud
# Protect InfCloud access
ynh_app_setting_set $app protected_uris "/"
domain_regex=$(echo "$domain" | sed 's@-@.@g')
# Radicale is always accessible (For access to ressources)
ynh_app_setting_set $app skipped_regex "$domain_regex$path_url"
else
# If only radicale is installed
# Radicale is always accessible (For access to ressources)
ynh_app_setting_set $app unprotected_uris "/"
fi
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configure logrotate" --weight=2
ynh_script_progression --message="Configuring log rotation..."
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown radicale -R /var/log/$app
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# PHP-FPM CONFIGURATION
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --log="/var/log/uwsgi/app/radicale.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
# Start a systemd service
ynh_systemd_action --service_name=uwsgi --action="restart"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
if [ $infcloud -eq 1 ]
then
ynh_script_progression --message="Configure PHP-FPM" --weight=4
# Create a dedicated php-fpm config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
# Add /infcloud to the path of radicale to access it from the portal
# Replace radicale by InfCloud into YunoHost portal
ynh_app_setting_set --app=$app --key=path --value="${path_url%/}/infcloud"
# Protect InfCloud access
ynh_app_setting_set --app=$app --key=protected_uris --value="/"
domain_regex=$(echo "$domain" | sed 's@-@.@g')
# Radicale is always accessible (For access to ressources)
ynh_app_setting_set --app=$app --key=skipped_regex --value="$domain_regex$path_url"
else
# If only radicale is installed
# Radicale is always accessible (For access to ressources)
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reload NGINX" --weight=4
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
@ -332,4 +335,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --ty
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation completed" --last
ynh_script_progression --message="Installation of $app completed"

View file

@ -1,7 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -12,47 +12,62 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings"
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# 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..."
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stop and remove the service" --weight=3
ynh_script_progression --message="Stopping and removing the systemd service..."
# Delete uwsgi configuration
ynh_systemd_action --action=stop --service_name=uwsgi
if [ -h "/etc/uwsgi/apps-enabled/radicale.ini" ]; then
echo "Delete uwsgi config"
ynh_secure_remove "/etc/uwsgi/apps-enabled/radicale.ini"
ynh_secure_remove --file="/etc/uwsgi/apps-enabled/radicale.ini"
fi
ynh_secure_remove "/etc/uwsgi/apps-available/radicale.ini"
ynh_secure_remove --file="/etc/uwsgi/apps-available/radicale.ini"
ynh_systemd_action --action="restart" --service_name=uwsgi
#=================================================
# REMOVE DEPENDENCIES
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Remove dependencies" --weight=10
ynh_script_progression --message="Removing logrotate configuration..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Remove app main directory"
ynh_script_progression --message="Removing app main directory..."
ynh_secure_remove "/var/www/$app"
ynh_secure_remove "/opt/yunohost/$app"
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
ynh_secure_remove --file="/opt/yunohost/$app"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Remove NGINX configuration"
ynh_script_progression --message="Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
@ -60,55 +75,41 @@ ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Remove PHP-FPM configuration" --weight=3
ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated php-fpm config
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIG
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Remove logrotate configuration" --weight=3
ynh_script_progression --message="Removing dependencies..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE RADICALE CONFIG
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..."
ynh_secure_remove "/etc/$app"
# Remove a directory securely
ynh_secure_remove --file="/etc/$app"
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
#=================================================
if [ -e /etc/init.d/uwsgi ]
then
# Restart uwsgi service
ynh_systemd_action --action=start --service_name=uwsgi
else
# Check if the service is declared in YunoHost
if yunohost service status | grep -q uwsgi
then
ynh_print_info "Remove uwsgi service" >&2
yunohost service remove uwsgi
fi
fi
#=================================================
# GENERIC FINALISATION
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Remove the dedicated user"
ynh_script_progression --message="Removing the dedicated system user..."
ynh_system_user_delete $app
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Deletion completed" --last
ynh_script_progression --message="Removal of $app completed"

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,70 +14,76 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings" --weight=2
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
infcloud=$(ynh_app_setting_get $app infcloud)
path_url=$(ynh_app_setting_get $app path)
admin=$(ynh_app_setting_get $app admin)
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)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
admin=$(ynh_app_setting_get --app=$app --key=admin)
infcloud=$(ynh_app_setting_get --app=$app --key=infcloud)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path "
|| ynh_die --message="There is already a directory: $final_path "
test ! -d "/opt/yunohost/$app" \
|| ynh_die "There is already a directory: /opt/yunohost/$app "
|| ynh_die --message="There is already a directory: /opt/yunohost/$app "
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Activate maintenance mode" --weight=2
ynh_script_progression --message="Activate maintenance mode"
ynh_maintenance_mode_ON
#=================================================
# STANDARD RESTORE STEPS
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstall dependencies" --weight=25
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restore the app main directory"
ynh_restore_file "$final_path"
mkdir -p /opt/yunohost
ynh_restore_file "/opt/yunohost/$app"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreate the dedicated user" --weight=3
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create $app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
mkdir -p /opt/yunohost
ynh_restore_file --origin_path="/opt/yunohost/$app"
chown -R radicale: "/opt/yunohost/$app"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
@ -84,60 +91,79 @@ ynh_system_user_create $app
if [ $infcloud -eq 1 ]
then
ynh_script_progression --message="Reload PHP-FPM" --weight=2
ynh_restore_file "/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_systemd_action --action=reload --service_name=php$phpversion-fpm
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
fi
#=================================================
# SPECIFIC RESTORE
# SPECIFIC RESTORATION
#=================================================
# RESTORE USER RIGHTS
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
chown radicale: -R /opt/yunohost/$app
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE VARIOUS FILES
#=================================================
ynh_script_progression --message="Restoring various files..."
ynh_restore_file --origin_path="/etc/$app/"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/uwsgi/apps-available/radicale.ini"
ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
chown -R radicale: $final_path
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown radicale -R /var/log/$app
#=================================================
# RESTORE THE UWSGI CONFIG
#=================================================
ynh_restore_file "/etc/uwsgi/apps-available/radicale.ini"
ln -s /etc/uwsgi/apps-available/radicale.ini /etc/uwsgi/apps-enabled/
# Advertise service in admin panel
yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log"
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# RESTORE THE RADICALE CONFIGURATION
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
ynh_restore_file "/etc/$app"
yunohost service add $app --log="/var/log/uwsgi/app/radicale.log"
#=================================================
# BACKUP OF THE LOGROTATE CONFIGURATION
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_restore_file "/etc/logrotate.d/$app"
ynh_systemd_action --service_name=uwsgi --action=restart
#=================================================
# GENERIC FINALISATION
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND UWSGI
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reload nginx and restart Radicale"
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_systemd_action --action=restart --service_name=uwsgi
ynh_systemd_action --action=reload --service_name=nginx
if [ $infcloud -eq 1 ]
then
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
fi
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Disable maintenance mode" --weight=4
ynh_script_progression --message="Disable maintenance mode"
ynh_maintenance_mode_OFF
@ -172,4 +198,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --ty
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed" --last
ynh_script_progression --message="Restoration completed for $app"

View file

@ -1,7 +1,7 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
@ -12,16 +12,16 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Load settings" --weight=6
ynh_script_progression --message="Loading installation settings..."
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)
infcloud=$(ynh_app_setting_get --app=$app --key=infcloud)
language=$(ynh_app_setting_get --app=$app --key=language)
admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
infcloud=$(ynh_app_setting_get --app=$app --key=infcloud)
version=$(ynh_app_setting_get --app=$app --key=version)
overwrite_logging=$(ynh_app_setting_get --app=$app --key=overwrite_logging)
overwrite_config=$(ynh_app_setting_get --app=$app --key=overwrite_config)
@ -40,29 +40,40 @@ defaulteventduration=$(ynh_app_setting_get --app=$app --key=defaulteventduration
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backup the app before upgrading"
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Activate maintenance mode"
ynh_maintenance_mode_ON
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensure downward compatibility"
ynh_script_progression --message="Ensuring downward compatibility..."
ynh_app_setting_delete $app unprotected_regex
ynh_app_setting_delete --app=$app --key=unprotected_regex
if [ -d /usr/local/radicale ]
then
@ -74,82 +85,93 @@ if [ -z "$version" ]
then
# Retrieve the version number in the manifest file.
version=$(ynh_app_upstream_version)
ynh_app_setting_set $app version "$version"
ynh_app_setting_set --app=$app --key=version --value="$version"
fi
# Fix infcloud as a boolean
if [ "$infcloud" = "Yes" ]; then
ynh_app_setting_set $app infcloud 1
ynh_app_setting_set --app=$app --key=infcloud --value=1
infcloud=1
elif [ "$infcloud" = "No" ]; then
ynh_app_setting_set $app infcloud 0
ynh_app_setting_set --app=$app --key=infcloud --value=0
infcloud=0
fi
# If overwrite_logging doesn't exist, create it
if [ -z "$overwrite_logging" ]; then
overwrite_logging=1
ynh_app_setting_set $app overwrite_logging $overwrite_logging
ynh_app_setting_set --app=$app --key=overwrite_logging --value=$overwrite_logging
fi
# If overwrite_config doesn't exist, create it
if [ -z "$overwrite_config" ]; then
overwrite_config=1
ynh_app_setting_set $app overwrite_config $overwrite_config
ynh_app_setting_set --app=$app --key=overwrite_config --value=$overwrite_config
fi
# If overwrite_infcloud doesn't exist, create it
if [ -z "$overwrite_infcloud" ]; then
overwrite_infcloud=1
ynh_app_setting_set $app overwrite_infcloud $overwrite_infcloud
ynh_app_setting_set --app=$app --key=overwrite_infcloud --value=$overwrite_infcloud
fi
# If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx
ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
fi
# If overwrite_phpfpm doesn't exist, create it
if [ -z "$overwrite_phpfpm" ]; then
overwrite_phpfpm=1
ynh_app_setting_set $app overwrite_phpfpm $overwrite_phpfpm
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm
fi
#=================================================
# Migrate legacy permissions to new system
#=================================================
if ynh_legacy_permissions_exists
then
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# CHECK THE PATH
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ $infcloud -eq 1 ]; then
# Remove /infcloud to deal with the path only.
path_url=$(echo $path_url | sed "s@/infcloud@@")
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..."
# Copy files to the right place
mkdir -p $final_path/collections
# Copy files to the right place
cp ../conf/radicale.wsgi $final_path
# Copy extra files
cp -a ../sources/extra_files_radicale/. "$final_path"
if [ $infcloud -eq 1 ]
then
# Download and uncompress the source into final_path
ynh_setup_source --dest_dir="$final_path/infcloud" --keep="config.js"
fi
fi
#=================================================
# ACTIVATE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Activate maintenance mode" --weight=1
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
ynh_maintenance_mode_ON
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrade dependencies" --weight=5
ynh_install_app_dependencies $pkg_dependencies
chmod 666 -R $final_path/default_collections
chmod 777 $final_path/default_collections $final_path/default_collections/USER
#=================================================
# NGINX CONFIGURATION
@ -158,36 +180,40 @@ ynh_install_app_dependencies $pkg_dependencies
# Overwrite the NGINX configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ]
then
ynh_script_progression --message="Reconfigure nginx" --weight=2
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
if [ $infcloud -eq 1 ]
then
# Add InfCloud in NGINX config
ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf
ynh_replace_string --match_string="#INFCLOUD#" --replace_string="" --target_file="/etc/nginx/conf.d/$domain.d/$app.conf"
fi
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"
fi
#=================================================
# CREATE DEDICATED USER
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Create a dedicated user" --weight=2
ynh_script_progression --message="Upgrading dependencies..."
# Create a dedicated user (if not existing)
ynh_system_user_create $app
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
if [ $infcloud -eq 1 ]
then
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
# Overwrite the php-fpm configuration only if it's allowed
if [ $overwrite_phpfpm -eq 1 ]
then
ynh_script_progression --message="Reconfigure PHP-FPM" --weight=2
# Create a dedicated php-fpm config
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
fi
fi
@ -199,80 +225,45 @@ fi
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrade Radicale in its virtualenv" --weight=6
ynh_script_progression --message="Upgrade Radicale in its virtualenv"
# Upgrade pip packages
ynh_secure_remove /opt/yunohost/$app
ynh_secure_remove --file="/opt/yunohost/$app"
virtualenv /opt/yunohost/$app
version=$(ynh_app_setting_get $app version $version)
bash -c "source /opt/yunohost/radicale/bin/activate && pip install radicale==$version python-ldap"
# regex.py file is patched to fix the awful commit e807c3d35bea9cfcfcacac83b1b17d748ea15a39 that stop the reading of "rights" file after the first match.
mv "$final_path/regex.py" /opt/yunohost/$app/lib/python*/site-packages/radicale/rights/regex.py
fi
#=================================================
# COPY FILES INTO $FINAL_PATH
#=================================================
ynh_script_progression --message="Download, check and unpack source"
# Copy files to the right place
mkdir -p $final_path/collections
cp ../conf/radicale.wsgi $final_path
# Copy extra files
cp -a ../sources/extra_files_radicale/. "$final_path"
# regex.py file is patched to fix the awful commit e807c3d35bea9cfcfcacac83b1b17d748ea15a39 that stop the reading of "rights" file after the first match.
mv "$final_path/regex.py" /opt/yunohost/$app/lib/python*/site-packages/radicale/rights/regex.py
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
if [ "$infcloud" = "1" ]
then
#Instal InfCloud
# Backup the content of $final_path
final_path_backup=$final_path
# Modify final_path for InfCloud installation
final_path=$final_path/infcloud
# If overwrite_infcloud is 0, copy the config file, then restore it.
if [ $overwrite_infcloud -eq 0 ]; then
cp -a $final_path/config.js ./config.js
fi
# Download and uncompress the source into final_path
ynh_setup_source "$final_path"
if [ $overwrite_infcloud -eq 0 ]; then
mv ./config.js $final_path/config.js
fi
# Restore the content of $final_path
final_path=$final_path_backup
fi
fi
chown radicale: -R /opt/yunohost/$app
find /opt/yunohost/$app/ -type d -exec chmod 2755 {} \;
find /opt/yunohost/$app/ -type f -exec chmod g+r,o+r {} \;
#=================================================
# CONFIGURE RADICALE
#=================================================
ynh_script_progression --message="Reconfigure Radicale" --weight=5
ynh_script_progression --message="Reconfigure Radicale"
# Overwrite the logging config file only if it's allowed
if [ $overwrite_logging -eq 1 ]
then
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different "/etc/$app/logging"
cp ../conf/logging /etc/$app/
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "/etc/$app/logging"
ynh_add_config --template="../conf/logging" --destination="/etc/$app/logging"
fi
# Overwrite the config file only if it's allowed
if [ $overwrite_config -eq 1 ]
then
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different "/etc/$app/config"
cp ../conf/config /etc/$app/
ynh_replace_string "__PATH__" "${path_url%/}" /etc/$app/config
ynh_replace_string "__FINALPATH__" "$final_path" /etc/$app/config
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "/etc/$app/config"
ynh_add_config --template="../conf/config" --destination="/etc/$app/config"
fi
chmod 755 /etc/$app/
chmod 644 /etc/$app/*
# Overwrite the InfCloud config file only if it's allowed
if [ $overwrite_infcloud -eq 1 ]
if [ $infcloud -eq 1 ]
then
if [ $infcloud -eq 1 ]
if [ $overwrite_infcloud -eq 1 ]
then
# InfCloud configuration
# Set language
@ -308,122 +299,89 @@ then
"Chinese") language="zh_CN"
;;
esac
ynh_app_setting_set $app language $language
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different "$final_path/infcloud/config.js"
cp ../conf/config.js "$final_path/infcloud/"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/infcloud/config.js"
ynh_replace_string "__PATH__" "${path_url%/}" "$final_path/infcloud/config.js"
ynh_replace_string "__LANG__" "$language" "$final_path/infcloud/config.js"
ynh_replace_string "__ADMIN__" "$admin" "$final_path/infcloud/config.js"
ynh_replace_string "__TIMEZONE__" "$(cat /etc/timezone)" "$final_path/infcloud/config.js"
ynh_app_setting_set --app=$app --key=language --value=$language
timezone=$(cat /etc/timezone)
ynh_add_config --template="../conf/config.js" --destination="$final_path/infcloud/config.js"
# Optional parameters from config-panel feature
if [ -n "$firstdayofweek" ]; then
ynh_replace_string "\(^var globalDatepickerFirstDayOfWeek=\).*" "\1$firstdayofweek;" "$final_path/infcloud/config.js"
ynh_replace_string --match_string="\(^var globalDatepickerFirstDayOfWeek=\).*" --replace_string="\1$firstdayofweek;" --target_file="$final_path/infcloud/config.js"
fi
if [ -n "$activeview" ]; then
ynh_replace_string "\(^var globalActiveView=\).*" "\1\'$activeview\';" "$final_path/infcloud/config.js"
ynh_replace_string --match_string="\(^var globalActiveView=\).*" --replace_string="\1\'$activeview\';" --target_file="$final_path/infcloud/config.js"
fi
if [ -n "$openformmode" ]; then
ynh_replace_string "\(^var globalOpenFormMode=\).*" "\1\'$openformmode\';" "$final_path/infcloud/config.js"
ynh_replace_string --match_string="\(^var globalOpenFormMode=\).*" --replace_string="\1\'$openformmode\';" --target_file="$final_path/infcloud/config.js"
fi
if [ -n "$startofbusiness" ]; then
ynh_replace_string "\(^var globalCalendarStartOfBusiness=\).*" "\1$startofbusiness;" "$final_path/infcloud/config.js"
ynh_replace_string --match_string="\(^var globalCalendarStartOfBusiness=\).*" --replace_string="\1$startofbusiness;" --target_file="$final_path/infcloud/config.js"
fi
if [ -n "$endofbusiness" ]; then
ynh_replace_string "\(^var globalCalendarEndOfBusiness=\).*" "\1$endofbusiness;" "$final_path/infcloud/config.js"
ynh_replace_string --match_string="\(^var globalCalendarEndOfBusiness=\).*" --replace_string="\1$endofbusiness;" --target_file="$final_path/infcloud/config.js"
fi
if [ -n "$defaulteventduration" ]; then
ynh_replace_string "\(^var globalDefaultEventDuration=\).*" "\1$defaulteventduration;" "$final_path/infcloud/config.js"
ynh_replace_string --match_string="\(^var globalDefaultEventDuration=\).*" --replace_string="\1$defaulteventduration;" --target_file="$final_path/infcloud/config.js"
fi
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$final_path/infcloud/config.js"
ynh_store_file_checksum --file="$final_path/infcloud/config.js"
chmod 440 "$final_path/infcloud/config.js"
chown $app:www-data "$final_path/infcloud/config.js"
fi
fi
#=================================================
# SET PERMISSIONS ON RADICALE DIRECTORIES
#=================================================
chown radicale: -R /opt/yunohost/$app
# Fix permission
chmod 755 /etc/$app/
find /opt/yunohost/$app/ -type d -exec chmod 2755 {} \;
find /opt/yunohost/$app/ -type f -exec chmod g+r,o+r {} \;
chmod 644 /etc/$app/*
chown -R radicale: $final_path
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown radicale -R /var/log/$app
# Set default permissions as radicale do.
chmod 666 -R $final_path/default_collections
chmod 777 $final_path/default_collections $final_path/default_collections/USER
#=================================================
# CONFIGURE UWSGI FOR RADICALE
#=================================================
cp ../conf/radicale.ini /etc/uwsgi/apps-available/
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
ynh_script_progression --message="Restart Radicale" --weight=2
ynh_systemd_action --action=restart --service_name=uwsgi
yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log"
#=================================================
# PREPARE THE HOOKS
#=================================================
# Modify the hooks for create user collections and to remove them.
ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_create
ynh_replace_string "__FINALPATH__" "$final_path" ../hooks/post_user_delete
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../hooks/post_user_create"
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../hooks/post_user_delete"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Reconfigure logrotate" --weight=3
ynh_script_progression --message="Upgrading logrotate configuration..."
mkdir -p /var/log/$app
touch /var/log/$app/$app.log
chown radicale -R /var/log/$app
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# GENERIC FINALISATION
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Reconfigure SSOwat" --weight=2
ynh_script_progression --message="Integrating service in YunoHost..."
if [ $infcloud -eq 1 ]
then
# Add /infcloud to the path of radicale to access it from the portal
# Replace radicale by InfCloud into YunoHost portal
ynh_app_setting_set $app path ${path_url%/}/infcloud
# Protect InfCloud access
ynh_app_setting_set $app protected_uris "/"
domain_regex=$(echo "$domain" | sed 's@-@.@g')
# Radicale is always accessible (For access to ressources)
ynh_app_setting_set $app skipped_regex "$domain_regex$path_url"
else
# If only radicale is installed
# Radicale is always accessible (For access to ressources)
ynh_app_setting_set $app unprotected_uris "/"
fi
yunohost service add $app --log="/var/log/uwsgi/app/radicale.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=uwsgi --action="restart"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reload NGINX"
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --action=reload --service_name=nginx
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
ynh_script_progression --message="Disable maintenance mode" --weight=5
ynh_script_progression --message="Disable maintenance mode"
ynh_maintenance_mode_OFF
@ -466,4 +424,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --ty
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade completed" --last
ynh_script_progression --message="Upgrade of $app completed"