mirror of
https://github.com/YunoHost-Apps/radicale_ynh.git
synced 2024-09-03 20:16:14 +02:00
commit
a8e59b5a73
16 changed files with 77 additions and 475 deletions
|
@ -1,7 +1,7 @@
|
|||
# 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)
|
||||
[![Install Radicale with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=radicale)
|
||||
[![Install Radicale with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=radicale)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
|
@ -32,7 +32,7 @@ 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: [app_radicale.md](./app_radicale.md)
|
||||
* YunoHost documentation: https://yunohost.org/#/app_radicale
|
||||
|
||||
## YunoHost specific features
|
||||
|
||||
|
|
10
README_fr.md
10
README_fr.md
|
@ -1,6 +1,6 @@
|
|||
# Radicale pour YunoHost
|
||||
|
||||
[![Niveau d'intégration](https://dash.yunohost.org/integration/radicale.svg)](https://dash.yunohost.org/appci/app/radicale)
|
||||
[![Niveau d'intégration](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)
|
||||
[![Installer Radicale avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=radicale)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
|
@ -32,7 +32,7 @@ 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: [app_radicale_fr.md](./app_radicale_fr.md)
|
||||
* Documentation YunoHost : https://yunohost.org/#/app_radicale_fr
|
||||
|
||||
## Fonctionnalités spécifiques à YunoHost
|
||||
|
||||
|
@ -44,9 +44,8 @@ Supportée, avec LDAP et SSO seulement avec radicale, pas pour InfCloud.
|
|||
|
||||
#### Architectures supportées.
|
||||
|
||||
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/radicale%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/radicale/)
|
||||
* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/radicale%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/radicale/)
|
||||
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/radicale%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/radicale/)
|
||||
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/radicale%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/radicale/)
|
||||
|
||||
## Limitations
|
||||
|
||||
|
@ -63,8 +62,7 @@ Supportée, avec LDAP et SSO seulement avec radicale, pas pour InfCloud.
|
|||
|
||||
---
|
||||
|
||||
Informations à l'intention des développeurs
|
||||
----------------
|
||||
## Informations à l'intention des développeurs
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/radicale_ynh/tree/testing).
|
||||
|
||||
|
|
|
@ -36,21 +36,8 @@
|
|||
upgrade=1 from_commit=3be74eb1ebd9da9b13f9080fd7aa0e535ab09192
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
incorrect_path=0
|
||||
port_already_use=0
|
||||
change_url=1
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
# Level 4: https://github.com/YunoHost-Apps/radicale_ynh/issues/2
|
||||
Level 4=0
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=down
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
SOURCE_URL=https://www.inf-it.com/InfCloud_0.13.1.zip
|
||||
SOURCE_SUM=6ffb1b3b9b7f54137723c6c13e9c5635
|
||||
SOURCE_SUM_PRG=md5sum
|
||||
SOURCE_SUM=9fa95edd2dcc2b864a10b503ab9220895ea28d4c5541ab02117de1511d5464d4
|
||||
SOURCE_SUM_PRG=sha256sum
|
||||
SOURCE_FORMAT=zip
|
||||
SOURCE_IN_SUBDIR=true
|
||||
SOURCE_FILENAME=
|
||||
|
|
|
@ -34,7 +34,7 @@ location @radicale {
|
|||
#INFCLOUD# try_files $uri $uri/ index.php;
|
||||
#INFCLOUD# location ~ [^/]\.php(/|$) {
|
||||
#INFCLOUD# fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
#INFCLOUD# fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
|
||||
#INFCLOUD# fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
#INFCLOUD# fastcgi_index index.php;
|
||||
#INFCLOUD# include fastcgi_params;
|
||||
#INFCLOUD# fastcgi_param REMOTE_USER $remote_user;
|
||||
|
|
|
@ -35,7 +35,7 @@ group = __USER__
|
|||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock
|
||||
listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"email": "maniackc_dev@crudelis.fr"
|
||||
}],
|
||||
"requirements": {
|
||||
"yunohost": ">= 3.4"
|
||||
"yunohost": ">= 3.8.1"
|
||||
},
|
||||
"multi_instance": false,
|
||||
"services": [
|
||||
|
@ -66,6 +66,7 @@
|
|||
},
|
||||
{
|
||||
"name": "language",
|
||||
"type": "string",
|
||||
"ask": {
|
||||
"en": "Choose your interface language",
|
||||
"fr": "Choisissez la langue de l'interface"
|
||||
|
|
|
@ -1,26 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# BACKUP
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
|
||||
human=$(numfmt --to=iec --from-unit=1K $1)
|
||||
echo $human
|
||||
}
|
||||
YNH_PHP_VERSION="7.3"
|
||||
|
||||
CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
||||
file_to_analyse=$1
|
||||
backup_size=$(du --summarize "$file_to_analyse" | cut -f1)
|
||||
free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d)
|
||||
|
||||
if [ $free_space -le $backup_size ]
|
||||
then
|
||||
ynh_print_err "Espace insuffisant pour sauvegarder $file_to_analyse."
|
||||
ynh_print_err "Espace disponible: $(HUMAN_SIZE $free_space)"
|
||||
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
|
||||
fi
|
||||
}
|
||||
pkg_dependencies="python-pip python-virtualenv virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python"
|
||||
|
||||
#=================================================
|
||||
# PACKAGE CHECK BYPASSING...
|
||||
|
@ -60,7 +46,7 @@ ynh_multimedia_build_main_dir () {
|
|||
local checksum="806a827ba1902d6911095602a9221181"
|
||||
|
||||
# Download yunohost.multimedia scripts
|
||||
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz
|
||||
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1
|
||||
|
||||
# Check the control sum
|
||||
echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
|
||||
|
@ -129,358 +115,6 @@ ynh_multimedia_addaccess () {
|
|||
usermod -a -G multimedia $user_name
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# Create a dedicated fail2ban config (jail and filter conf files)
|
||||
#
|
||||
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
|
||||
# | arg: -l, --logpath= - Log file to be checked by fail2ban
|
||||
# | arg: -r, --failregex= - Failregex to be looked for by fail2ban
|
||||
# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3
|
||||
# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https
|
||||
ynh_add_fail2ban_config () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= )
|
||||
local logpath
|
||||
local failregex
|
||||
local max_retry
|
||||
local ports
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
max_retry=${max_retry:-3}
|
||||
ports=${ports:-http,https}
|
||||
|
||||
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
|
||||
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
|
||||
|
||||
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
|
||||
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
|
||||
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
||||
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
||||
|
||||
tee $finalfail2banjailconf <<EOF
|
||||
[$app]
|
||||
enabled = true
|
||||
port = $ports
|
||||
filter = $app
|
||||
logpath = $logpath
|
||||
maxretry = $max_retry
|
||||
EOF
|
||||
|
||||
tee $finalfail2banfilterconf <<EOF
|
||||
[INCLUDES]
|
||||
before = common.conf
|
||||
[Definition]
|
||||
failregex = $failregex
|
||||
ignoreregex =
|
||||
EOF
|
||||
|
||||
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||
|
||||
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||
systemctl reload fail2ban
|
||||
else
|
||||
systemctl restart fail2ban
|
||||
fi
|
||||
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||
if [ -n "$fail2ban_error" ]
|
||||
then
|
||||
echo "[ERR] Fail2ban failed to load the jail for $app" >&2
|
||||
echo "WARNING${fail2ban_error#*WARNING}" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Remove the dedicated fail2ban config (jail and filter conf files)
|
||||
#
|
||||
# usage: ynh_remove_fail2ban_config
|
||||
ynh_remove_fail2ban_config () {
|
||||
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
||||
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||
systemctl reload fail2ban
|
||||
else
|
||||
systemctl restart fail2ban
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# Read the value of a key in a ynh manifest file
|
||||
#
|
||||
# usage: ynh_read_manifest manifest key
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
# | arg: -k, --key= - Name of the key to find
|
||||
ynh_read_manifest () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
|
||||
local manifest
|
||||
local manifest_key
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])"
|
||||
}
|
||||
|
||||
# Read the upstream version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number before ~ynh
|
||||
# In the last example it return 4.3-2
|
||||
#
|
||||
# usage: ynh_app_upstream_version [-m manifest]
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
ynh_app_upstream_version () {
|
||||
declare -Ar args_array=( [m]=manifest= )
|
||||
local manifest
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
manifest="${manifest:-../manifest.json}"
|
||||
if [ ! -e "$manifest" ]; then
|
||||
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||
echo "${version_key/~ynh*/}"
|
||||
}
|
||||
|
||||
# Read package version from the manifest
|
||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||
# For example : 4.3-2~ynh3
|
||||
# This include the number after ~ynh
|
||||
# In the last example it return 3
|
||||
#
|
||||
# usage: ynh_app_package_version [-m manifest]
|
||||
# | arg: -m, --manifest= - Path of the manifest to read
|
||||
ynh_app_package_version () {
|
||||
declare -Ar args_array=( [m]=manifest= )
|
||||
local manifest
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
manifest="${manifest:-../manifest.json}"
|
||||
if [ ! -e "$manifest" ]; then
|
||||
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||
fi
|
||||
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||
echo "${version_key/*~ynh/}"
|
||||
}
|
||||
|
||||
# Checks the app version to upgrade with the existing app version and returns:
|
||||
# - UPGRADE_APP if the upstream app version has changed
|
||||
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||
#
|
||||
## It stops the current script without error if the package is up-to-date
|
||||
#
|
||||
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||
# of it, when it's not needed
|
||||
#
|
||||
# To force an upgrade, even if the package is up to date,
|
||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||
#
|
||||
# usage: ynh_check_app_version_changed
|
||||
ynh_check_app_version_changed () {
|
||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||
|
||||
# By default, upstream app version has changed
|
||||
local return_value="UPGRADE_APP"
|
||||
|
||||
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0)
|
||||
local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")"
|
||||
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0)
|
||||
local update_upstream_version="$(ynh_app_upstream_version)"
|
||||
|
||||
if [ "$current_version" == "$update_version" ] ; then
|
||||
# Complete versions are the same
|
||||
if [ "$force_upgrade" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||
unset YNH_FORCE_UPGRADE
|
||||
elif [ "$package_check" != "0" ]
|
||||
then
|
||||
echo "Upgrade forced for package check." >&2
|
||||
else
|
||||
ynh_die "Up-to-date, nothing to do" 0
|
||||
fi
|
||||
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||
# Upstream versions are the same, only YunoHost package versions differ
|
||||
return_value="UPGRADE_PACKAGE"
|
||||
fi
|
||||
echo $return_value
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||
#
|
||||
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||
# | arg: -n, --service_name= - Name of the service to reload. Default : $app
|
||||
# | arg: -a, --action= - Action to perform with systemctl. Default: start
|
||||
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
|
||||
# If not defined it don't wait until the service is completely started.
|
||||
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
|
||||
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
||||
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||
ynh_systemd_action() {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||
local service_name
|
||||
local action
|
||||
local line_match
|
||||
local length
|
||||
local log_path
|
||||
local timeout
|
||||
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
local service_name="${service_name:-$app}"
|
||||
local action=${action:-start}
|
||||
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||
local length=${length:-20}
|
||||
local timeout=${timeout:-300}
|
||||
|
||||
# Start to read the log
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local templog="$(mktemp)"
|
||||
# Following the starting of the app in its log
|
||||
if [ "$log_path" == "systemd" ] ; then
|
||||
# Read the systemd journal
|
||||
journalctl -u $service_name -f --since=-45 > "$templog" &
|
||||
else
|
||||
# Read the specified log file
|
||||
tail -F -n0 "$log_path" > "$templog" &
|
||||
fi
|
||||
# Get the PID of the tail command
|
||||
local pid_tail=$!
|
||||
fi
|
||||
|
||||
echo "${action^} the service $service_name" >&2
|
||||
systemctl $action $service_name \
|
||||
|| ( journalctl --lines=$length -u $service_name >&2 \
|
||||
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||
; false )
|
||||
|
||||
# Start the timeout and try to find line_match
|
||||
if [[ -n "${line_match:-}" ]]
|
||||
then
|
||||
local i=0
|
||||
for i in $(seq 1 $timeout)
|
||||
do
|
||||
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||
if grep --quiet "$line_match" "$templog"
|
||||
then
|
||||
echo "The service $service_name has correctly started." >&2
|
||||
break
|
||||
fi
|
||||
echo -n "." >&2
|
||||
sleep 1
|
||||
done
|
||||
if [ $i -eq $timeout ]
|
||||
then
|
||||
echo "The service $service_name didn't fully started before the timeout." >&2
|
||||
echo "Please find here an extract of the end of the log of the service $service_name:"
|
||||
journalctl --lines=$length -u $service_name >&2
|
||||
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
ynh_clean_check_starting
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean temporary process and file used by ynh_check_starting
|
||||
# (usually used in ynh_clean_setup scripts)
|
||||
#
|
||||
# usage: ynh_clean_check_starting
|
||||
ynh_clean_check_starting () {
|
||||
# Stop the execution of tail.
|
||||
kill -s 15 $pid_tail 2>&1
|
||||
ynh_secure_remove "$templog" 2>&1
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
||||
# Print a message as INFO and show progression during an app script
|
||||
#
|
||||
# usage: ynh_script_progression --message=message [--weight=weight] [--time]
|
||||
# | arg: -m, --message= - The text to print
|
||||
# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script.
|
||||
# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights.
|
||||
# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar.
|
||||
increment_progression=0
|
||||
previous_weight=0
|
||||
# Define base_time when the file is sourced
|
||||
base_time=$(date +%s)
|
||||
ynh_script_progression () {
|
||||
# Declare an array to define the options of this helper.
|
||||
declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last )
|
||||
local message
|
||||
local weight
|
||||
local time
|
||||
local last
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
weight=${weight:-1}
|
||||
time=${time:-0}
|
||||
last=${last:-0}
|
||||
|
||||
# Get execution time since the last $base_time
|
||||
local exec_time=$(( $(date +%s) - $base_time ))
|
||||
base_time=$(date +%s)
|
||||
|
||||
# Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented.
|
||||
local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)"
|
||||
# Get the number of call with a weight value
|
||||
local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0)
|
||||
|
||||
# Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight
|
||||
local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')"
|
||||
# Get the weight of each occurrences of 'ynh_script_progression' in the script using -w
|
||||
local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')"
|
||||
# Each value will be on a different line.
|
||||
# Remove each 'end of line' and replace it by a '+' to sum the values.
|
||||
local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 ))
|
||||
|
||||
# max_progression is a total number of calls to this helper.
|
||||
# Less the number of calls with a weight value.
|
||||
# Plus the total of weight values
|
||||
local max_progression=$(( $helper_calls - $weight_calls + $weight_values ))
|
||||
|
||||
# Increment each execution of ynh_script_progression in this script by the weight of the previous call.
|
||||
increment_progression=$(( $increment_progression + $previous_weight ))
|
||||
# Store the weight of the current call in $previous_weight for next call
|
||||
previous_weight=$weight
|
||||
|
||||
# Set the scale of the progression bar
|
||||
local scale=20
|
||||
# progress_string(1,2) should have the size of the scale.
|
||||
local progress_string1="####################"
|
||||
local progress_string0="...................."
|
||||
|
||||
# Reduce $increment_progression to the size of the scale
|
||||
if [ $last -eq 0 ]
|
||||
then
|
||||
local effective_progression=$(( $increment_progression * $scale / $max_progression ))
|
||||
# If last is specified, fill immediately the progression_bar
|
||||
else
|
||||
local effective_progression=$scale
|
||||
fi
|
||||
|
||||
# Build $progression_bar from progress_string(1,2) according to $effective_progression
|
||||
local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}"
|
||||
|
||||
local print_exec_time=""
|
||||
if [ $time -eq 1 ]
|
||||
then
|
||||
print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]"
|
||||
fi
|
||||
|
||||
ynh_print_info "[$progression_bar] > ${message}${print_exec_time}"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Dependencies
|
||||
app_depencencies="python-pip python-virtualenv virtualenv python-dev libldap2-dev libsasl2-dev libssl-dev uwsgi uwsgi-plugin-python"
|
|
@ -19,41 +19,41 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Load settings" --weight=2
|
||||
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)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backup the app main dir" --weight=2
|
||||
|
||||
CHECK_SIZE "$final_path"
|
||||
ynh_backup "$final_path"
|
||||
CHECK_SIZE "/opt/yunohost/$app"
|
||||
|
||||
ynh_backup "/opt/yunohost/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backup nginx configuration"
|
||||
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backup php-fpm configuration"
|
||||
|
||||
if [ $infcloud -eq 1 ]
|
||||
then
|
||||
ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -61,22 +61,18 @@ fi
|
|||
#=================================================
|
||||
# BACKUP UWSGI CONFIG
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backup uWSGI configuration"
|
||||
|
||||
ynh_backup "/etc/uwsgi/apps-available/radicale.ini"
|
||||
|
||||
#=================================================
|
||||
# BACKUP RADICALE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backup Radicale configuration"
|
||||
|
||||
CHECK_SIZE "/etc/$app"
|
||||
ynh_backup "/etc/$app"
|
||||
|
||||
#=================================================
|
||||
# BACKUP LOGROTATE CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Backup logrotate configuration"
|
||||
|
||||
ynh_backup "/etc/logrotate.d/$app"
|
||||
|
||||
|
@ -84,4 +80,4 @@ ynh_backup "/etc/logrotate.d/$app"
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Backup script completed. Please wait for YunoHost to create the backup." --last
|
||||
ynh_print_info --message="Backup script completed. Please wait for YunoHost to create the backup."
|
||||
|
|
|
@ -170,4 +170,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" --last
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Load common variables for all scripts.
|
||||
source _variables
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Load common variables for all scripts.
|
||||
source _variables
|
||||
|
||||
#=================================================
|
||||
# MANAGE FAILURE OF THE SCRIPT
|
||||
|
@ -42,9 +40,6 @@ ynh_script_progression --message="Check if the app can be installed"
|
|||
final_path=/var/www/$app
|
||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||
|
||||
# Normalize the url path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
# Register (book) web path
|
||||
ynh_webpath_register $app $domain $path_url
|
||||
|
||||
|
@ -73,17 +68,17 @@ ynh_app_setting_set $app admin_mail_html "1"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Install dependencies" --weight=25
|
||||
|
||||
ynh_install_app_dependencies $app_depencencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configure nginx" --weight=2
|
||||
ynh_script_progression --message="Configure NGINX" --weight=2
|
||||
|
||||
ynh_add_nginx_config
|
||||
if [ $infcloud -eq 1 ]
|
||||
then
|
||||
# Add InfCloud in Nginx config
|
||||
# Add InfCloud in NGINX config
|
||||
ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
fi
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
|
@ -101,7 +96,7 @@ ynh_system_user_create $app
|
|||
#=================================================
|
||||
# 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" --weight=15
|
||||
|
||||
# Init virtualenv
|
||||
virtualenv /opt/yunohost/$app
|
||||
|
@ -246,7 +241,7 @@ done <<< "$(yunohost user list | grep username | cut -d ":" -f 2 | cut -c 2-)"
|
|||
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"
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log"
|
||||
|
||||
#=================================================
|
||||
# PREPARE THE HOOKS
|
||||
|
@ -293,15 +288,16 @@ ynh_use_logrotate
|
|||
|
||||
if [ $infcloud -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Configure php-fpm" --weight=4
|
||||
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)
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reload nginx" --weight=4
|
||||
ynh_script_progression --message="Reload NGINX" --weight=4
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ ynh_script_progression --message="Load settings"
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -52,15 +52,15 @@ ynh_secure_remove "/opt/yunohost/$app"
|
|||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove nginx configuration"
|
||||
ynh_script_progression --message="Remove NGINX configuration"
|
||||
|
||||
# Remove the dedicated nginx config
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Remove php-fpm configuration" --weight=3
|
||||
ynh_script_progression --message="Remove PHP-FPM configuration" --weight=3
|
||||
|
||||
# Remove the dedicated php-fpm config
|
||||
ynh_remove_fpm_config
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Load common variables for all scripts.
|
||||
source ../settings/scripts/_variables
|
||||
|
||||
#=================================================
|
||||
# MANAGE SCRIPT FAILURE
|
||||
|
@ -30,6 +28,7 @@ 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)
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -62,7 +61,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Reinstall dependencies" --weight=25
|
||||
|
||||
ynh_install_app_dependencies $app_depencencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
|
@ -87,9 +86,9 @@ ynh_system_user_create $app
|
|||
|
||||
if [ $infcloud -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Reload php-fpm" --weight=2
|
||||
ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf"
|
||||
ynh_systemd_action --action=reload --service_name=php7.0-fpm
|
||||
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
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
@ -113,7 +112,7 @@ 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"
|
||||
yunohost service add uwsgi --log="/var/log/uwsgi/app/radicale.log"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE RADICALE CONFIGURATION
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
# Load common variables for all scripts.
|
||||
source _variables
|
||||
|
||||
#=================================================
|
||||
# LOAD SETTINGS
|
||||
|
@ -18,26 +16,26 @@ ynh_script_progression --message="Load settings" --weight=6
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
admin=$(ynh_app_setting_get $app admin)
|
||||
infcloud=$(ynh_app_setting_get $app infcloud)
|
||||
language=$(ynh_app_setting_get $app language)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
version=$(ynh_app_setting_get $app version)
|
||||
overwrite_logging=$(ynh_app_setting_get $app overwrite_logging)
|
||||
overwrite_config=$(ynh_app_setting_get $app overwrite_config)
|
||||
overwrite_infcloud=$(ynh_app_setting_get $app overwrite_infcloud)
|
||||
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx)
|
||||
overwrite_phpfpm=$(ynh_app_setting_get $app overwrite_phpfpm)
|
||||
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)
|
||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||
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)
|
||||
overwrite_infcloud=$(ynh_app_setting_get --app=$app --key=overwrite_infcloud)
|
||||
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
|
||||
overwrite_phpfpm=$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)
|
||||
|
||||
# Optional parameters from config-panel feature
|
||||
firstdayofweek=$(ynh_app_setting_get $app firstdayofweek)
|
||||
activeview=$(ynh_app_setting_get $app activeview)
|
||||
openformmode=$(ynh_app_setting_get $app openformmode)
|
||||
startofbusiness=$(ynh_app_setting_get $app startofbusiness)
|
||||
endofbusiness=$(ynh_app_setting_get $app endofbusiness)
|
||||
defaulteventduration=$(ynh_app_setting_get $app defaulteventduration)
|
||||
firstdayofweek=$(ynh_app_setting_get --app=$app --key=firstdayofweek)
|
||||
activeview=$(ynh_app_setting_get --app=$app --key=activeview)
|
||||
openformmode=$(ynh_app_setting_get --app=$app --key=openformmode)
|
||||
startofbusiness=$(ynh_app_setting_get --app=$app --key=startofbusiness)
|
||||
endofbusiness=$(ynh_app_setting_get --app=$app --key=endofbusiness)
|
||||
defaulteventduration=$(ynh_app_setting_get --app=$app --key=defaulteventduration)
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
|
@ -126,8 +124,6 @@ if [ $infcloud -eq 1 ]; then
|
|||
# Remove /infcloud to deal with the path only.
|
||||
path_url=$(echo $path_url | sed "s@/infcloud@@")
|
||||
fi
|
||||
# Normalize the URL path syntax
|
||||
path_url=$(ynh_normalize_url_path $path_url)
|
||||
|
||||
#=================================================
|
||||
# ACTIVATE MAINTENANCE MODE
|
||||
|
@ -143,20 +139,20 @@ ynh_maintenance_mode_ON
|
|||
#=================================================
|
||||
ynh_script_progression --message="Upgrade dependencies"
|
||||
|
||||
ynh_install_app_dependencies $app_depencencies
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
# Overwrite the nginx configuration only if it's allowed
|
||||
# Overwrite the NGINX configuration only if it's allowed
|
||||
if [ $overwrite_nginx -eq 1 ]
|
||||
then
|
||||
ynh_script_progression --message="Reconfigure nginx" --weight=2
|
||||
ynh_add_nginx_config
|
||||
if [ $infcloud -eq 1 ]
|
||||
then
|
||||
# Add InfCloud in Nginx config
|
||||
# Add InfCloud in NGINX config
|
||||
ynh_replace_string "#INFCLOUD#" "" /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
fi
|
||||
ynh_store_file_checksum "$finalnginxconf"
|
||||
|
@ -179,7 +175,7 @@ then
|
|||
# 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
|
||||
ynh_script_progression --message="Reconfigure PHP-FPM" --weight=2
|
||||
# Create a dedicated php-fpm config
|
||||
ynh_add_fpm_config
|
||||
fi
|
||||
|
@ -362,11 +358,12 @@ chmod 777 $final_path/default_collections $final_path/default_collections/USER
|
|||
cp ../conf/radicale.ini /etc/uwsgi/apps-available/
|
||||
|
||||
#=================================================
|
||||
# RESTART UWSGI
|
||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restart Radicale" --weight=3
|
||||
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
|
||||
|
@ -409,7 +406,7 @@ fi
|
|||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reload nginx"
|
||||
ynh_script_progression --message="Reload NGINX"
|
||||
|
||||
ynh_systemd_action --action=reload --service_name=nginx
|
||||
|
||||
|
|
Loading…
Reference in a new issue