From 9d14c5e380cc3715b96ad0d12774607ca2dfb80d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 8 Oct 2017 19:03:08 +0200 Subject: [PATCH 01/53] Global refactoring --- check_process | 19 +- conf/app.src | 6 + conf/nginx.conf | 27 +- conf/php-fpm.conf | 12 +- conf/php-fpm.ini | 3 + manifest.json | 159 +++++----- scripts/.fonctions | 213 ------------- scripts/_common.sh | 2 + scripts/backup | 72 +++-- scripts/install | 284 ++++++++++-------- scripts/remove | 122 ++++---- scripts/restore | 124 +++++--- scripts/upgrade | 212 +++++++------ .../plugins/auto-domain-grab/LICENSE | 0 .../plugins/auto-domain-grab/README | 0 .../plugins/auto-domain-grab/VERSION | 0 .../plugins/auto-domain-grab/index.php | 0 .../plugins/ynh-ldap-suggestions/README | 0 .../plugins/ynh-ldap-suggestions/VERSION | 0 .../YnhLdapSuggestions.php | 0 .../plugins/ynh-ldap-suggestions/index.php | 0 .../plugins/ynh-login-mapping/README | 0 .../plugins/ynh-login-mapping/VERSION | 0 .../plugins/ynh-login-mapping/index.php | 0 sources/rainloop_version | 1 - 25 files changed, 589 insertions(+), 667 deletions(-) create mode 100644 conf/app.src create mode 100644 conf/php-fpm.ini delete mode 100755 scripts/.fonctions create mode 100644 scripts/_common.sh rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/auto-domain-grab/LICENSE (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/auto-domain-grab/README (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/auto-domain-grab/VERSION (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/auto-domain-grab/index.php (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/ynh-ldap-suggestions/README (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/ynh-ldap-suggestions/VERSION (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/ynh-ldap-suggestions/YnhLdapSuggestions.php (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/ynh-ldap-suggestions/index.php (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/ynh-login-mapping/README (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/ynh-login-mapping/VERSION (100%) rename sources/{ => extra_files/app/data/_data_/_default_}/plugins/ynh-login-mapping/index.php (100%) delete mode 100644 sources/rainloop_version diff --git a/check_process b/check_process index 9da1e61..09ecc87 100644 --- a/check_process +++ b/check_process @@ -3,9 +3,9 @@ ; Manifest domain="domain.tld" (DOMAIN) path="/rainloop" (PATH) - is_public="No" (PUBLIC|public=Yes|private=No) - password="password" (PASSWORD) - ldap="Yes" + is_public=1 (PUBLIC|public=1|private=0) + password="password" + ldap=1 lang="English" ; Checks pkg_linter=1 @@ -17,21 +17,22 @@ upgrade=1 backup_restore=1 multi_instance=1 - wrong_user=0 - wrong_path=1 incorrect_path=1 - corrupt_source=0 - fail_download_source=0 port_already_use=0 - final_path_already_use=0 + change_url=0 ;;; Levels Level 1=auto Level 2=auto Level 3=auto +# Level 4: Level 4=1 - Level 5=1 +# Level 5: + Level 5=auto Level 6=auto Level 7=auto Level 8=0 Level 9=0 Level 10=0 +;;; Options +Email= +Notification=none diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..985e078 --- /dev/null +++ b/conf/app.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/RainLoop/rainloop-webmail/releases/download/v1.11.1/rainloop-community-1.11.1.zip +SOURCE_SUM=153150c51fd41403ce089544dad77dfb +SOURCE_SUM_PRG=md5sum +SOURCE_FORMAT=zip +SOURCE_IN_SUBDIR=false +SOURCE_FILENAME= diff --git a/conf/nginx.conf b/conf/nginx.conf index 04c3de4..7f3d212 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,16 +1,16 @@ -location PATHTOCHANGE { - alias ALIASTOCHANGE; +location __PATH__ { + alias __FINALPATH__/; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - location ^~ ROOTTOCHANGE/app/data { - deny all; + location ^~ __PATH__/app/data { + deny all; } - location ^~ ROOTTOCHANGE/pgpback/keys { - deny all; + location ^~ __PATH__/pgpback/keys { + deny all; } client_max_body_size 10G; @@ -18,14 +18,15 @@ location PATHTOCHANGE { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm-NAMETOCHANGE.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; } - include conf.d/yunohost_panel.conf.inc; + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 67f989d..6b5de9c 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,7 +1,7 @@ ; Start a new pool named 'www'. ; the variable $pool can we used in any directive and will be replaced by the ; pool name ('www' here) -[NAMETOCHANGE] +[__NAMETOCHANGE__] ; Per pool prefix ; It only applies on the following directives: @@ -24,7 +24,7 @@ ; specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php5-fpm-NAMETOCHANGE.sock +listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. A value of '-1' means unlimited. ; Default Value: 128 (-1 on FreeBSD and OpenBSD) @@ -50,8 +50,8 @@ listen.mode = 0600 ; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. -user = www-data -group = www-data +user = __USER__ +group = __USER__ ; Choose how the process manager will control the number of child processes. ; Possible Values: @@ -170,7 +170,7 @@ request_slowlog_timeout = 5s ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set -slowlog = /var/log/nginx/NAMETOCHANGE.slow.log +slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log ; Set open file descriptor rlimit. ; Default Value: system defined value @@ -195,7 +195,7 @@ rlimit_core = 0 ; Chdir to this directory at the start. ; Note: relative path can be used. ; Default Value: current directory or / when chroot -chdir = /var/www/NAMETOCHANGE +chdir = __FINALPATH__ ; Redirect worker stdout and stderr into main error log. If not set, stdout and ; stderr will be redirected to /dev/null according to FastCGI specs. diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini new file mode 100644 index 0000000..b4608de --- /dev/null +++ b/conf/php-fpm.ini @@ -0,0 +1,3 @@ +upload_max_filesize = 10G +post_max_size = 10G +mail.add_x_header = Off diff --git a/manifest.json b/manifest.json index 1b3d2ea..0a5abde 100644 --- a/manifest.json +++ b/manifest.json @@ -1,81 +1,82 @@ { - "packaging_format": 1, - "name": "Rainloop", - "id": "rainloop", - "description": { - "en": "Lightweight multi-account webmail", - "fr": "Webmail léger multi-comptes" - }, - "url": "http://rainloop.net/", - "license": "AGPL-3.0", - "maintainer": { - "name": "scith, Djip007, polytan02" - }, - "multi_instance": true, - "services": [ - "nginx", - "php5-fpm", - "mysql" - ], - "requirements": { - "yunohost": ">= 2.4.0" - }, - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain for Rainloop", - "fr": "Choisissez un domaine pour Rainloop" - }, - "example": "domain.org" - }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for Rainloop", - "fr": "Choisissez un chemin pour Rainloop" - }, - "example": "/rainloop", - "default": "/rainloop" - }, - { - "name": "is_public", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une page publique ?" - }, - "choices": ["Yes", "No"], - "default": "No" - }, - { - "name": "password", - "type": "password", - "ask": { - "en": "Choose a strong password for the 'admin' user", - "fr": "Choisissez un mot de passe fort pour l'administrateur 'admin'" - } - }, - { - "name": "ldap", - "ask": { - "en": "Do you want to add YunoHost users to the recipients suggestions?", - "fr": "Souhaitez-vous ajouter les utilisateurs YunoHost dans les suggestions de destinataires ?" - }, - "choices": ["Yes", "No"], - "default": "Yes" - }, - { - "name": "lang", - "ask": { - "en": "Select default language", - "fr": "Definir la langue par defaut" - }, - "choices": ["English", "Francais"], - "default": "English" - } - ] - } + "name": "Rainloop", + "id": "rainloop", + "packaging_format": 1, + "description": { + "en": "Lightweight multi-account webmail", + "fr": "Webmail léger multi-comptes" + }, + "version": "1.11.1", + "url": "https://www.rainloop.net/", + "license": "AGPL-3.0", + "maintainer": { + "name": "scith, Djip007, polytan02" + }, + "requirements": { + "yunohost": ">= 2.7.2" + }, + "multi_instance": true, + "services": [ + "nginx", + "php5-fpm", + "mysql" + ], + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain for Rainloop", + "fr": "Choisissez un domaine pour Rainloop" + }, + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Rainloop", + "fr": "Choisissez un chemin pour Rainloop" + }, + "example": "/rainloop", + "default": "/rainloop" + }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" + }, + "default": false + }, + { + "name": "password", + "type": "password", + "ask": { + "en": "Choose a strong password for the 'admin' user", + "fr": "Choisissez un mot de passe fort pour l'administrateur, 'admin'" + } + }, + { + "name": "ldap", + "type": "boolean", + "ask": { + "en": "Do you want to add YunoHost users to the recipients suggestions?", + "fr": "Souhaitez-vous ajouter les utilisateurs YunoHost dans les suggestions de destinataires ?" + }, + "default": true + }, + { + "name": "lang", + "ask": { + "en": "Select default language", + "fr": "Definir la langue par defaut" + }, + "choices": ["English", "Francais"], + "default": "English" + } + ] + } } diff --git a/scripts/.fonctions b/scripts/.fonctions deleted file mode 100755 index 699ead7..0000000 --- a/scripts/.fonctions +++ /dev/null @@ -1,213 +0,0 @@ -#!/bin/bash - -CHECK_VAR () { # Vérifie que la variable n'est pas vide. -# $1 = Variable à vérifier -# $2 = Texte à afficher en cas d'erreur - test -n "$1" || (echo "$2" >&2 && false) -} - -EXIT_PROPERLY () { # Provoque l'arrêt du script en cas d'erreur. Et nettoye les résidus. - exit_code=$? - if [ "$exit_code" -eq 0 ]; then - exit 0 # Quitte sans erreur si le script se termine correctement. - fi - trap '' EXIT - set +eu - echo -e "\e[91m \e[1m" # Shell in light red bold - echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" >&2 - - if type -t CLEAN_SETUP > /dev/null; then # Vérifie l'existance de la fonction avant de l'exécuter. - CLEAN_SETUP # Appel la fonction de nettoyage spécifique du script install. - fi - - # Compense le bug de ssowat qui ne supprime pas l'entrée de l'app en cas d'erreur d'installation. - sudo sed -i "\@\"$domain$path/\":@d" /etc/ssowat/conf.json - - ynh_die -} - -TRAP_ON () { # Activate signal capture - set -eu # Exit if a command fail, and if a variable is used unset. - trap EXIT_PROPERLY EXIT # Capturing exit signals on shell script -} - -CHECK_USER () { # Vérifie la validité de l'user admin -# $1 = Variable de l'user admin. - ynh_user_exists "$1" || (echo "Wrong admin" >&2 && false) -} - -CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin. - if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un / - path="/$path" # Ajoute un / en début de path - fi - if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then # Si le dernier caractère est un / et que ce n'est pas le seul caractère. - path="${path:0:${#path}-1}" # Supprime le dernier caractère - fi -} - -CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine. - sudo yunohost app checkurl $domain$path -a $app || ynh_die "Path not available: ${domain}${path}" -} - -CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé. - final_path=/var/www/$app - if [ -e "$final_path" ] - then - echo "This path already contains a folder" >&2 - false - fi -} - -GENERATE_DB () { # Créer une base de données et un utilisateur dédié au nom de l'app. -# $1 = Nom de la base de donnée - db_user=$1 - db_user=${db_user//-/_} # mariadb ne supporte pas les - dans les noms de base de données. Ils sont donc remplacé par des _ - # Génère un mot de passe aléatoire. -# db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20) - db_pwd=$(ynh_string_random) - CHECK_VAR "$db_pwd" "db_pwd empty" - # Utilise '$app' comme nom d'utilisateur et de base de donnée - # Initialise la base de donnée et stocke le mot de passe mysql. - ynh_mysql_create_db "$db_user" "$db_user" $db_pwd - ynh_app_setting_set $app mysqlpwd $db_pwd -} - -SETUP_SOURCE () { # Télécharge la source, décompresse et copie dans $final_path -# $1 = Nom de l'archive téléchargée. - wget -nv -i ../sources/source_url -O $1 - # Vérifie la somme de contrôle de la source téléchargée. - md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) - # Décompresse la source - if [ "$(echo ${1##*.})" == "gz" ]; then - tar -x -f $1 - elif [ "$(echo ${1##*.})" == "zip" ]; then - unzip -q $1 - else - false # Format d'archive non pris en charge. - fi - # Copie les fichiers sources - sudo cp -a $(cat ../sources/source_dir)/. "$final_path" - # Copie les fichiers additionnels ou modifiés. - if test -e "../sources/ajouts"; then - sudo cp -a ../sources/ajouts/. "$final_path" - fi -} - -ADD_SYS_USER () { # Créer un utilisateur système dédié à l'app - if ! ynh_system_user_exists "$app" # Test l'existence de l'utilisateur - then - sudo useradd -d /var/www/$app --system --user-group $app --shell /usr/sbin/nologin || (echo "Unable to create $app system account" >&2 && false) - fi -} - -POOL_FPM () { # Créer le fichier de configuration du pool php-fpm et le configure. - sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf - sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf - sed -i "s@__USER__@$app@g" ../conf/php-fpm.conf - finalphpconf=/etc/php5/fpm/pool.d/$app.conf - sudo cp ../conf/php-fpm.conf $finalphpconf - sudo chown root: $finalphpconf - finalphpini=/etc/php5/fpm/conf.d/20-$app.ini - sudo cp ../conf/php-fpm.ini $finalphpini - sudo chown root: $finalphpini - sudo service php5-fpm reload -} - -STORE_MD5_CONFIG () { # Enregistre la somme de contrôle du fichier de config -# $1 = Nom du fichier de conf pour le stockage dans settings.yml -# $2 = Nom complet et chemin du fichier de conf. - ynh_app_setting_set $app $1_file_md5 $(sudo md5sum "$2" | cut -d' ' -f1) -} - -CHECK_MD5_CONFIG () { # Créé un backup du fichier de config si il a été modifié. -# $1 = Nom du fichier de conf pour le stockage dans settings.yml -# $2 = Nom complet et chemin du fichier de conf. - if [ "$(ynh_app_setting_get $app $1_file_md5)" != $(sudo md5sum "$2" | cut -d' ' -f1) ]; then - sudo cp -a "$2" "$2.backup.$(date '+%d.%m.%y_%Hh%M,%Ss')" # Si le fichier de config a été modifié, créer un backup. - fi -} - -FIND_PORT () { # Cherche un port libre. -# $1 = Numéro de port pour débuter la recherche. - port=$1 - while ! sudo yunohost app checkport $port ; do - port=$((port+1)) - done - CHECK_VAR "$port" "port empty" -} - - -### REMOVE SCRIPT - -REMOVE_NGINX_CONF () { # Suppression de la configuration nginx - if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config - echo "Delete nginx config" - sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf" - sudo service nginx reload - fi -} - -REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm - if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config - echo "Delete fpm config" - sudo rm "/etc/php5/fpm/pool.d/$app.conf" - fi - if [ -e "/etc/php5/fpm/conf.d/20-$app.ini" ]; then # Delete php config - echo "Delete php config" - sudo rm "/etc/php5/fpm/conf.d/20-$app.ini" - fi - sudo service php5-fpm reload -} - -REMOVE_LOGROTATE_CONF () { # Suppression de la configuration de logrotate - if [ -e "/etc/logrotate.d/$app" ]; then - echo "Delete logrotate config" - sudo rm "/etc/logrotate.d/$app" - fi -} - -SECURE_REMOVE () { # Suppression de dossier avec vérification des variables - chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables. - no_var=0 - while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine - do - no_var=1 - global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée. - only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse surtout du / et d'un éventuel chemin derrière. - real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable. - if test -z "$real_var" || [ "$real_var" = "/" ]; then - echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2 - return 1 - fi - chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine. - done - if [ "$no_var" -eq 1 ] - then - if [ -e "$chaine" ]; then - echo "Delete directory $chaine" - sudo rm -r "$chaine" - fi - return 0 - else - echo "No detected variable." >&2 - return 1 - fi -} - -REMOVE_BDD () { # Suppression de la base de donnée et de l'utilisateur associé. -# $1 = Nom de la base de donnée - # Utilise '$app' comme nom d'utilisateur et de base de donnée - db_user=$1 - if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then - echo "Delete db" - ynh_mysql_drop_db $db_user - ynh_mysql_drop_user $db_user - fi -} - -REMOVE_SYS_USER () { # Supprime l'utilisateur système dédié à l'app - if ynh_system_user_exists "$app" # Test l'existence de l'utilisateur - then - sudo userdel $app - fi -} diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..05a7907 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,2 @@ +#!/bin/bash + diff --git a/scripts/backup b/scripts/backup index 3c6b807..0a064c2 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,31 +1,59 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error - set -eu - app=$YNH_APP_INSTANCE_NAME +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source app helpers - source /usr/share/yunohost/helpers +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh +fi +source _common.sh +source /usr/share/yunohost/helpers -# Retrieve app settings - domain=$(ynh_app_setting_get "$app" domain) - path=$(ynh_app_setting_get "$app" path) - dbpass=$(ynh_app_setting_get "$app" mysqlpwd) +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# Copy the app files - DESTDIR="/var/www/$app" - ynh_backup "$DESTDIR" "sources" +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Copy the conf files - ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +#================================================= +# LOAD SETTINGS +#================================================= -# Copy dedicated php-fpm process to backup folder - ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" +app=$YNH_APP_INSTANCE_NAME -# Set app specific variables - dbname=$app - dbuser=$app +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) -# Dump the database - mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./db.sql - ynh_backup "db.sql" "dump.sql" +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup "$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# BACKUP THE PHP-FPM CONFIGURATION +#================================================= + +ynh_backup "/etc/php5/fpm/pool.d/$app.conf" +ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" + +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= + +ynh_mysql_dump_db "$db_name" > db.sql diff --git a/scripts/install b/scripts/install index 00422d0..a641701 100644 --- a/scripts/install +++ b/scripts/install @@ -1,159 +1,189 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -# It also activate set -eu - source .fonctions - TRAP_ON +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Initial data - app=$YNH_APP_INSTANCE_NAME - rainloop_version=$(cat ../sources/rainloop_version) +source _common.sh +source /usr/share/yunohost/helpers -# Source app helpers - source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# Retrieve arguments - domain=$YNH_APP_ARG_DOMAIN - path=$YNH_APP_ARG_PATH - is_public=$YNH_APP_ARG_IS_PUBLIC - password=$YNH_APP_ARG_PASSWORD - ldap=$YNH_APP_ARG_LDAP - lang=$YNH_APP_ARG_LANG +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Correct path using .fonctions -CHECK_PATH +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= -# Check domain/path availability using .fonctions -CHECK_DOMAINPATH +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC +password=$YNH_APP_ARG_PASSWORD +ldap=$YNH_APP_ARG_LDAP +lang=$YNH_APP_ARG_LANG -# Use 'rainloop' as database name and user - dbuser=$app - dbname=$app - dbpass=$(ynh_string_random) +app=$YNH_APP_INSTANCE_NAME -# Initialize database and store mysql password for upgrade - ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" - ynh_app_setting_set "$app" mysqlpwd "$dbpass" +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= -# Create the final path and copy sources - CHECK_FINALPATH - final_path=/var/www/$app +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die "This path already contains a folder" - rainloop_path=${final_path}/app +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) - sudo rm -rf $final_path - sudo mkdir -p $final_path - sudo mkdir -p $rainloop_path +# Check web path availability +ynh_webpath_available $domain $path_url +# Register (book) web path +ynh_webpath_register $app $domain $path_url - # Download sources and keys - sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip - sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip.asc - sudo wget -q https://repository.rainloop.net/RainLoop.asc - # Verify the integrity of sources - sudo gpg --import --quiet RainLoop.asc - sudo gpg --verify --quiet rainloop-community-${rainloop_version}.zip.asc rainloop-community-${rainloop_version}.zip || ynh_die "Download failed" - sudo gpg --batch --delete-key --yes Rainloop - # Unzip - sudo unzip -qq rainloop-community-${rainloop_version}.zip -d $rainloop_path/ +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= - # Install plugins - sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins - sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/. - sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/. - sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/. +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path_url +ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set $app password $password +ynh_app_setting_set $app ldap $ldap -# Autoconfig - sudo mkdir -p $rainloop_path/data/_data_/_default_/configs/ - application_file=$rainloop_path/data/_data_/_default_/configs/application.ini +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# CREATE A MYSQL DATABASE +#================================================= - # Set lang => define from install manifest - case "$lang" in - Francais) - lang="fr" - ;; - English) - lang="en" - ;; - *) - lang="en" - esac - ynh_app_setting_set "$app" lang "$lang" +db_name=$(ynh_sanitize_dbid $app) +ynh_app_setting_set $app db_name $db_name +ynh_mysql_setup_db $db_name $db_name - # Set plugins - plugins="ynh-login-mapping,auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts - if [ "$ldap" = "Yes" ]; - then - plugins="$plugins,ynh-ldap-suggestions" # This plugin is to suggest YunoHost users in recipients list - fi - ynh_app_setting_set "$app" ldap "$ldap" - ynh_app_setting_set "$app" plugins "$plugins" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path/app" + +#================================================= +# NGINX CONFIGURATION +#================================================= + +ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf" +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# CREATE DEDICATED USER +#================================================= + +# Create a system user +ynh_system_user_create $app + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= + +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# SPECIFIC SETUP +#================================================= +# AUTOCONFIG +#================================================= + +# Set lang => define from install manifest +case "$lang" in + Francais) + lang="fr" + ;; + English) + lang="en" + ;; + *) + lang="en" +esac +ynh_app_setting_set "$app" lang "$lang" + +# Set plugins +plugins="ynh-login-mapping,auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts +if [ $ldap -eq 1 ] +then + plugins="$plugins,ynh-ldap-suggestions" # This plugin is to suggest YunoHost users in recipients list +fi +ynh_app_setting_set "$app" plugins "$plugins" + + +mkdir -p "$final_path/app/data/_data_/_default_/configs/" +application_file="$final_path/app/data/_data_/_default_/configs/application.ini" + +sudo cp ../conf/data/configs/application.ini "$application_file" +ynh_replace_string "domain.tld" "$domain" "$application_file" +ynh_replace_string "MYSQLUSER" "$db_name" "$application_file" +ynh_replace_string "MYSQLPASSWORD" "$db_pwd" "$application_file" +ynh_replace_string "LANGTOCHANGE" "$lang" "$application_file" +ynh_replace_string "PLUGINSTOENABLE" "$plugins" "$application_file" - sudo cp ../conf/data/configs/application.ini $application_file - sudo sed -i "s@domain.tld@$domain@g" $application_file - sudo sed -i "s@MYSQLUSER@$dbuser@g" $application_file - sudo sed -i "s@MYSQLPASSWORD@$dbpass@g" $application_file - sudo sed -i "s@LANGTOCHANGE@$lang@g" $application_file - sudo sed -i "s@PLUGINSTOENABLE@$plugins@g" $application_file # Set admin password - sudo php ../conf/config.php --index="$rainloop_path/index.php" --password="$password" - ynh_app_setting_set "$app" password "$password" +php ../conf/config.php --index="$final_path/app/index.php" --password="$password" + # Add default domain configs by looping through all the domains already added - sudo mkdir -p $rainloop_path/data/_data_/_default_/domains/ - # get list of ldap domains - alldomains=`ldapsearch -LLL -x -b ou=domains,dc=yunohost,dc=org -s one "objectclass=top" virtualdomain | grep -v "dn:" | sed "s/virtualdomain://" ` - for ldomain in $alldomains ; do - sudo cp ../conf/data/domains/domain.tld.ini $rainloop_path/data/_data_/_default_/domains/$ldomain.ini - done - # Add wildcard domain for auto-grab - sudo cp ../conf/data/domains/default.ini $rainloop_path/data/_data_/_default_/domains/default.ini +mkdir -p "$final_path/app/data/_data_/_default_/domains/" +# get list of ldap domains +alldomains=`ldapsearch -LLL -x -b ou=domains,dc=yunohost,dc=org -s one "objectclass=top" virtualdomain | grep -v "dn:" | sed "s/virtualdomain://" ` +for ldomain in $alldomains ; do + cp ../conf/data/domains/domain.tld.ini "$final_path/app/data/_data_/_default_/domains/$ldomain.ini" +done +# Add wildcard domain for auto-grab +cp ../conf/data/domains/default.ini "$final_path/app/data/_data_/_default_/domains/default.ini" + # install SSO - at the moment the index is the SSO and rainloop is installed in /app - sudo cp ../sources/sso/sso.php $final_path/index.php - sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php - sudo sed -i "s@ALIASTOCHANGE@$final_path@g" $final_path/index.php - if [ $path = "/" ]; then - sudo sed -i "s@ROOTTOCHANGE@@g" $final_path/index.php - else - sudo sed -i "s@ROOTTOCHANGE@$path@g" $final_path/index.php - fi +cp ../sources/sso/sso.php "$final_path/index.php" +ynh_replace_string "domain.tld" "$domain" "$final_path/index.php" +ynh_replace_string "ALIASTOCHANGE" "$final_path" "$final_path/index.php" +if [ $path_url = "/" ]; then + ynh_replace_string "ROOTTOCHANGE" "" "$final_path/index.php" +else + ynh_replace_string "ROOTTOCHANGE" "$path_url" "$final_path/index.php" +fi + # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server - sudo cp -rf ../sources/pgpback $final_path/. +cp -rf ../sources/pgpback "$final_path/" -# Set permissions to rainloop directory - sudo find $final_path/. -type d -exec chmod 755 {} \; - sudo find $final_path/. -type f -exec chmod 644 {} \; - sudo chown -R www-data:www-data $final_path +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= -# Install Nginx configuration file - nginx_conf_file=/etc/nginx/conf.d/$domain.d/$app.conf - sudo cp ../conf/nginx.conf $nginx_conf_file - if [ $path = "/" ]; then - sudo sed -i "s@ROOTTOCHANGE@@g" $nginx_conf_file - else - sudo sed -i "s@ROOTTOCHANGE@$path@g" $nginx_conf_file - fi - sudo sed -i "s@PATHTOCHANGE@$path@g" $nginx_conf_file - sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" $nginx_conf_file - sudo sed -i "s@NAMETOCHANGE@$app@g" $nginx_conf_file - sudo chown root: $nginx_conf_file - sudo chmod 644 $nginx_conf_file +find $final_path/. -type d -exec chmod 755 {} \; +find $final_path/. -type f -exec chmod 644 {} \; +chown -R $app: $final_path - finalphpconf=/etc/php5/fpm/pool.d/$app.conf - sudo cp ../conf/php-fpm.conf $finalphpconf - sudo sed -i "s@NAMETOCHANGE@$app@g" $finalphpconf - sudo chown root: $finalphpconf - sudo chmod 644 $finalphpconf +#================================================= +# SETUP SSOWAT +#================================================= # Make app public if necessary - ynh_app_setting_set "$app" is_public "$is_public" - if [ "$is_public" = "Yes" ]; - then - ynh_app_setting_set "$app" skipped_uris "/" - fi +if [ $is_public -eq 1 ] +then + ynh_app_setting_set $app skipped_uris "/" +fi -# Reload services - sudo service php5-fpm reload - sudo service nginx reload +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx diff --git a/scripts/remove b/scripts/remove index 6932096..52055bd 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,79 +1,67 @@ #!/bin/bash -set -u -# Exit on command errors and treat unset variables as an error +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source app helpers - source /usr/share/yunohost/helpers +source _common.sh +source /usr/share/yunohost/helpers -REMOVE_NGINX_CONF () { # Suppression de la configuration nginx - if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config - echo "Delete nginx config" - sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf" - fi -} +#================================================= +# LOAD SETTINGS +#================================================= -REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm - if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config - echo "Delete fpm config" - sudo rm "/etc/php5/fpm/pool.d/$app.conf" - fi -} +app=$YNH_APP_INSTANCE_NAME -SECURE_REMOVE () { # Suppression de dossier avec vérification des variables - chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables. - no_var=0 - while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine - do - no_var=1 - global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée. - only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse$ - real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable. - if test -z "$real_var" || [ "$real_var" = "/" ]; then - echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2 - return 1 - fi - chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine. - done - if [ "$no_var" -eq 1 ] - then - if [ -e "$chaine" ]; then - echo "Delete directory $chaine" - sudo rm -r "$chaine" - fi - return 0 - else - echo "No detected variable." >&2 - return 1 - fi -} +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get $app final_path) -REMOVE_BDD () { # Suppression de la base de donnée et de l'utilisateur associé. -# $1 = Nom de la base de donnée - # Utilise '$app' comme nom d'utilisateur et de base de donnée - db_user=$1 - if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then - echo "Delete db" - ynh_mysql_drop_db $db_user - ynh_mysql_drop_user $db_user - fi -} +#================================================= +# STANDARD REMOVE +#================================================= +# REMOVE THE MYSQL DATABASE +#================================================= -# Retrieve parameters - app=$YNH_APP_INSTANCE_NAME - domain=$(ynh_app_setting_get "$app" domain) +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db $db_name $db_name -# Drop MySQL database and user - REMOVE_BDD "$app" +#================================================= +# REMOVE APP MAIN DIR +#================================================= -# Delete app directory and configurations using secure remove - SECURE_REMOVE '/var/www/$app' - REMOVE_NGINX_CONF - REMOVE_FPM_CONF +# Remove the app directory securely +ynh_secure_remove "$final_path" -# Remove GPG key - sudo gpg --batch --delete-key --yes Rainloop +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= -# Reload services - sudo service php5-fpm reload - sudo service nginx reload +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# REMOVE PHP-FPM CONFIGURATION +#================================================= + +# Remove the dedicated php-fpm config +ynh_remove_fpm_config + +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE GPG KEY +#================================================= + +gpg --batch --delete-key --yes Rainloop + +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= + +# Delete a system user +ynh_system_user_delete $app diff --git a/scripts/restore b/scripts/restore index 06d71dc..656cb89 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,56 +1,94 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error - set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Get multi-instances specific variables - app=$YNH_APP_INSTANCE_NAME +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh +fi +source _common.sh +source /usr/share/yunohost/helpers -# Source app helpers - source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# Retrieve old app settings - domain=$(ynh_app_setting_get "$app" domain) - path=$(ynh_app_setting_get "$app" path) - dbname=$app - dbuser=$app - dbpass=$(ynh_app_setting_get "$app" mysqlpwd) +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Check domain/path availability - sudo yunohost app checkurl "${domain}${path}" -a "$app" \ - || ynh_die +#================================================= +# LOAD SETTINGS +#================================================= -# Check destination directory - DESTDIR="/var/www/$app" - [[ -d $DESTDIR ]] && ynh_die \ - "The destination directory '$DESTDIR' already exists.\ - You should safely delete it before restoring this app." +app=$YNH_APP_INSTANCE_NAME -# Check configuration files - nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" - [[ -f $nginx_conf ]] && ynh_die \ - "The NGINX configuration already exists at '${nginx_conf}'. - You should safely delete it before restoring this app." - phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf" - [[ -f $phpfpm_conf ]] && ynh_die \ - "The PHP FPM configuration already exists at '${phpfpm_conf}'. - You should safely delete it before restoring this app." +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) -# Restore the app files - sudo cp -a ./sources "$DESTDIR" +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= -# Create and restore the database - ynh_mysql_create_db $dbname $dbuser $dbpass - ynh_mysql_connect_as $dbuser $dbpass $dbname < ./dump.sql +ynh_webpath_available $domain $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " -# Fix installation directories and permissions - sudo mkdir -p "${DESTDIR}/logs" "${DESTDIR}/temp" - sudo chown -R www-data: "$DESTDIR" +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= -# Restore configuration files - sudo cp -a ./nginx.conf "$nginx_conf" - sudo cp -a ./php-fpm.conf "$phpfpm_conf" +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" -# Reload services - sudo service php5-fpm reload - sudo service nginx reload +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_restore_file "$final_path" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= + +db_pwd=$(ynh_app_setting_get $app mysqlpwd) +ynh_mysql_setup_db $db_name $db_name $db_pwd +ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= + +# Create the dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app: $final_path + +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= + +ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" +ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX AND PHP-FPM +#================================================= + +systemctl reload php5-fpm +systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index 5334d83..f698571 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,105 +1,143 @@ #!/bin/bash - app=$YNH_APP_INSTANCE_NAME - rainloop_version=$(cat ../sources/rainloop_version) -# Source app helpers - source /usr/share/yunohost/helpers - source .fonctions +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Backup the current version of the app, restore it if the upgrade fails -# Check if old backup exists - if sudo yunohost backup list | grep -q $app-before-upgrade > /dev/null 2>&1; - then - sudo yunohost backup delete $app-before-upgrade - else - echo "no old backup to delete" - fi - sudo yunohost backup create --ignore-hooks --apps $app --name $app-before-upgrade --quiet - EXIT_PROPERLY () { - trap '' ERR - set +eu - sudo yunohost backup restore --ignore-hooks $app-before-upgrade --apps $app --force --quiet # Restore the backup if upgrade failed - ynh_die "Upgrade failed. The app was restored to the way it was before the failed upgrade." - } - set -eu - trap EXIT_PROPERLY ERR +source _common.sh +source /usr/share/yunohost/helpers -# Retrieve arguments - domain=$(ynh_app_setting_get "$app" domain) - path=$(ynh_app_setting_get "$app" path) - is_public=$(ynh_app_setting_get "$app" is_public) - password=$(ynh_app_setting_get "$app" password) - ldap=$(ynh_app_setting_get "$app" ldap) - lang=$(ynh_app_setting_get "$app" lang) - dp_pwd=$(ynh_app_setting_get "$app" mysqlpwd) - db_user=$app - plugins=$(ynh_app_setting_get "$app" plugins) +#================================================= +# LOAD SETTINGS +#================================================= -# Correct path using .fonctions -CHECK_PATH +app=$YNH_APP_INSTANCE_NAME -# no update for db now... +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +is_public=$(ynh_app_setting_get $app is_public) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) -# Copy the new sources +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set $app is_public 1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set $app is_public 0 + is_public=0 +fi + +# If db_name doesn't exist, create it +if [ -z $db_name ]; then + db_name=$(ynh_sanitize_dbid $app) + ynh_app_setting_set $app db_name $db_name +fi + +# If final_path doesn't exist, create it +if [ -z $final_path ]; then final_path=/var/www/$app - rainloop_path=${final_path}/app - sudo rm -rf $rainloop_path/rainloop # Remove the previous Rainloop files except data + ynh_app_setting_set $app final_path $final_path +fi - # Download sources and keys - sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip - sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip.asc - sudo wget -q https://repository.rainloop.net/RainLoop.asc - # Verify the integrity of sources - sudo gpg --import --quiet RainLoop.asc - sudo gpg --verify --quiet rainloop-community-${rainloop_version}.zip.asc rainloop-community-${rainloop_version}.zip - sudo gpg --batch --delete-key --yes Rainloop - # Unzip and overwrite - sudo unzip -qq -o rainloop-community-${rainloop_version}.zip -d $rainloop_path/ +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= - # Update ynh plugins: - sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins - sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/. - sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/. - sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/. +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # 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 THE PATH +#================================================= + +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path $path_url) + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" + +#================================================= +# NGINX CONFIGURATION +#================================================= + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# CREATE DEDICATED USER +#================================================= + +# Create a system user +ynh_system_user_create $app + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= + +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# UPDATE SSO AND PGP +#================================================= # update SSO - sudo cp ../sources/sso/sso.php $final_path/index.php - sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php - sudo sed -i "s@ALIASTOCHANGE@$final_path@g" $final_path/index.php - if [ $path = "/" ]; then - sudo sed -i "s@ROOTTOCHANGE@@g" $final_path/index.php - else - sudo sed -i "s@ROOTTOCHANGE@$path@g" $final_path/index.php - fi +cp ../sources/sso/sso.php "$final_path/index.php" +ynh_replace_string "domain.tld" "$domain" "$final_path/index.php" +ynh_replace_string "ALIASTOCHANGE" "$final_path" "$final_path/index.php" +if [ $path_url = "/" ]; then + ynh_replace_string "ROOTTOCHANGE" "" "$final_path/index.php" +else + ynh_replace_string "ROOTTOCHANGE" "$path_url" "$final_path/index.php" +fi + # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server - sudo cp -rf ../sources/pgpback $final_path/. +cp -rf ../sources/pgpback "$final_path/" -# Set permissions to rainloop directory - sudo find $final_path/. -type d -exec chmod 755 {} \; - sudo find $final_path/. -type f -exec chmod 644 {} \; - sudo chown -R www-data:www-data $final_path +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= -# Update Nginx configuration file - nginx_conf_file=/etc/nginx/conf.d/$domain.d/$app.conf - sudo cp ../conf/nginx.conf $nginx_conf_file - if [ $path = "/" ]; then - sudo sed -i "s@ROOTTOCHANGE@@g" $nginx_conf_file - else - sudo sed -i "s@ROOTTOCHANGE@$path@g" $nginx_conf_file - fi - sudo sed -i "s@PATHTOCHANGE@$path@g" $nginx_conf_file - sudo sed -i "s@ALIASTOCHANGE@$final_path/@g" $nginx_conf_file - sudo sed -i "s@NAMETOCHANGE@$app@g" $nginx_conf_file - sudo chown root: $nginx_conf_file - sudo chmod 644 $nginx_conf_file +find $final_path/. -type d -exec chmod 755 {} \; +find $final_path/. -type f -exec chmod 644 {} \; +chown -R $app: $final_path - finalphpconf=/etc/php5/fpm/pool.d/$app.conf - sudo cp ../conf/php-fpm.conf $finalphpconf - sudo sed -i "s@NAMETOCHANGE@$app@g" $finalphpconf - sudo chown root: $finalphpconf - sudo chmod 644 $finalphpconf +#================================================= +# SETUP SSOWAT +#================================================= -# Reload services - sudo service php5-fpm reload - sudo service nginx reload +# Make app public if necessary +if [ $is_public -eq 1 ] +then + ynh_app_setting_set $app skipped_uris "/" +fi + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx diff --git a/sources/plugins/auto-domain-grab/LICENSE b/sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/LICENSE similarity index 100% rename from sources/plugins/auto-domain-grab/LICENSE rename to sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/LICENSE diff --git a/sources/plugins/auto-domain-grab/README b/sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/README similarity index 100% rename from sources/plugins/auto-domain-grab/README rename to sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/README diff --git a/sources/plugins/auto-domain-grab/VERSION b/sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/VERSION similarity index 100% rename from sources/plugins/auto-domain-grab/VERSION rename to sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/VERSION diff --git a/sources/plugins/auto-domain-grab/index.php b/sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/index.php similarity index 100% rename from sources/plugins/auto-domain-grab/index.php rename to sources/extra_files/app/data/_data_/_default_/plugins/auto-domain-grab/index.php diff --git a/sources/plugins/ynh-ldap-suggestions/README b/sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/README similarity index 100% rename from sources/plugins/ynh-ldap-suggestions/README rename to sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/README diff --git a/sources/plugins/ynh-ldap-suggestions/VERSION b/sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/VERSION similarity index 100% rename from sources/plugins/ynh-ldap-suggestions/VERSION rename to sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/VERSION diff --git a/sources/plugins/ynh-ldap-suggestions/YnhLdapSuggestions.php b/sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/YnhLdapSuggestions.php similarity index 100% rename from sources/plugins/ynh-ldap-suggestions/YnhLdapSuggestions.php rename to sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/YnhLdapSuggestions.php diff --git a/sources/plugins/ynh-ldap-suggestions/index.php b/sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/index.php similarity index 100% rename from sources/plugins/ynh-ldap-suggestions/index.php rename to sources/extra_files/app/data/_data_/_default_/plugins/ynh-ldap-suggestions/index.php diff --git a/sources/plugins/ynh-login-mapping/README b/sources/extra_files/app/data/_data_/_default_/plugins/ynh-login-mapping/README similarity index 100% rename from sources/plugins/ynh-login-mapping/README rename to sources/extra_files/app/data/_data_/_default_/plugins/ynh-login-mapping/README diff --git a/sources/plugins/ynh-login-mapping/VERSION b/sources/extra_files/app/data/_data_/_default_/plugins/ynh-login-mapping/VERSION similarity index 100% rename from sources/plugins/ynh-login-mapping/VERSION rename to sources/extra_files/app/data/_data_/_default_/plugins/ynh-login-mapping/VERSION diff --git a/sources/plugins/ynh-login-mapping/index.php b/sources/extra_files/app/data/_data_/_default_/plugins/ynh-login-mapping/index.php similarity index 100% rename from sources/plugins/ynh-login-mapping/index.php rename to sources/extra_files/app/data/_data_/_default_/plugins/ynh-login-mapping/index.php diff --git a/sources/rainloop_version b/sources/rainloop_version deleted file mode 100644 index 720c738..0000000 --- a/sources/rainloop_version +++ /dev/null @@ -1 +0,0 @@ -1.11.1 From af681ad3503cb7886dcde565ec1c4b2f582ba819 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 11 Apr 2018 21:00:01 +0200 Subject: [PATCH 02/53] Add upgrade from a previous commit --- check_process | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/check_process b/check_process index 09ecc87..003bfcd 100644 --- a/check_process +++ b/check_process @@ -15,6 +15,7 @@ setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=80cce268248d4d34b2ad1671ee31d3403f9262c6 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -36,3 +37,7 @@ ;;; Options Email= Notification=none +;;; Upgrade options + ; commit=80cce268248d4d34b2ad1671ee31d3403f9262c6 + name=Fix root install + manifest_arg=domain=DOMAIN&path=PATH&is_public=1&password=password&ldap=1&lang=English& From f6e56c385c384d27c3c18faaf11538b6c016dc9f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 12 Apr 2018 01:01:29 +0200 Subject: [PATCH 03/53] Fix is_public value for upgrade from commit --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 003bfcd..402fccf 100644 --- a/check_process +++ b/check_process @@ -40,4 +40,4 @@ Notification=none ;;; Upgrade options ; commit=80cce268248d4d34b2ad1671ee31d3403f9262c6 name=Fix root install - manifest_arg=domain=DOMAIN&path=PATH&is_public=1&password=password&ldap=1&lang=English& + manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes&password=password&ldap=1&lang=English& From 2a593f16e015053e5a10b1265120457f7c92b4bc Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 12 Apr 2018 18:51:44 +0200 Subject: [PATCH 04/53] Fix ldap value for upgrade from commit --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 402fccf..2cb2826 100644 --- a/check_process +++ b/check_process @@ -40,4 +40,4 @@ Notification=none ;;; Upgrade options ; commit=80cce268248d4d34b2ad1671ee31d3403f9262c6 name=Fix root install - manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes&password=password&ldap=1&lang=English& + manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes&password=password&ldap=Yes&lang=English& From 56e08950f2f9045322b270f8b7c59d1fbd1740d0 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 28 May 2018 10:54:42 +0200 Subject: [PATCH 05/53] Create pull_request_template.md Duplicated from https://github.com/YunoHost-Apps/searx_ynh/pull/35, merged as a micro decision --- pull_request_template.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pull_request_template.md diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..0096533 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,25 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how you fix that* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Validation +--- +*Minor decision* +- **Upgrade previous version** : +- [ ] **Code review** : +- [ ] **Approval (LGTM)** : +- [ ] **Approval (LGTM)** : +- **CI succeeded** : +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* +or +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 804e70b0c7fa160a84ec76569bb84151fcc85716 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 28 Jan 2019 15:09:59 +0100 Subject: [PATCH 06/53] Create rainloop_version Add a rainloop_version file to fix conflict in #49 --- sources/rainloop_version | 1 + 1 file changed, 1 insertion(+) create mode 100644 sources/rainloop_version diff --git a/sources/rainloop_version b/sources/rainloop_version new file mode 100644 index 0000000..0a5af26 --- /dev/null +++ b/sources/rainloop_version @@ -0,0 +1 @@ +1.11.3 From 40bdc35338be5e00e9ec8ef11943682e1d9eb94a Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 28 Jan 2019 15:12:06 +0100 Subject: [PATCH 07/53] Update app.src to 1.11.3 --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 985e078..8b3d7fc 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/RainLoop/rainloop-webmail/releases/download/v1.11.1/rainloop-community-1.11.1.zip -SOURCE_SUM=153150c51fd41403ce089544dad77dfb +SOURCE_URL=https://github.com/RainLoop/rainloop-webmail/releases/download/v1.11.3/rainloop-community-1.11.3.zip +SOURCE_SUM=49a097151abb1b208b74e01ee1680e2d SOURCE_SUM_PRG=md5sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false From 09c5f5ff54f108c6c799bcaf47f5ba9ae6c39400 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 28 Jan 2019 17:21:10 +0100 Subject: [PATCH 08/53] Fix upgrade_from_commit --- check_process | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index 2cb2826..bb5cd2d 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=80cce268248d4d34b2ad1671ee31d3403f9262c6 + upgrade=1 from_commit=e26b7e5823858ea5f526659f320692a2768786b5 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -38,6 +38,6 @@ Email= Notification=none ;;; Upgrade options - ; commit=80cce268248d4d34b2ad1671ee31d3403f9262c6 - name=Fix root install + ; commit=e26b7e5823858ea5f526659f320692a2768786b5 + name=Define ereg() if it does not exists manifest_arg=domain=DOMAIN&path=PATH&is_public=Yes&password=password&ldap=Yes&lang=English& From 42110f9d853d51cab44449ff5b47e5b1857d8b9f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 17:59:01 +0100 Subject: [PATCH 09/53] Apply example_ynh to _common.sh --- scripts/_common.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index 05a7907..4a6deae 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,2 +1,13 @@ #!/bin/bash +#================================================= +# PERSONNAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTUR OFFICIAL HELPERS +#================================================= From a7f408763bf8be82088ef70500d6c60a81707c92 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 18:06:24 +0100 Subject: [PATCH 10/53] update to 1.12.1 --- README.md | 2 +- conf/app.src | 6 +++--- manifest.json | 2 +- sources/rainloop_version | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9c392e6..02beb65 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Rainloop for YunoHost -* [rainloop](http://rainloop.net/ ): 1.11.3 +* [rainloop](http://rainloop.net/ ): 1.12.1 ## English Rainloop is a lightweight webmail. diff --git a/conf/app.src b/conf/app.src index 8b3d7fc..d886508 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://github.com/RainLoop/rainloop-webmail/releases/download/v1.11.3/rainloop-community-1.11.3.zip -SOURCE_SUM=49a097151abb1b208b74e01ee1680e2d -SOURCE_SUM_PRG=md5sum +SOURCE_URL=https://github.com/RainLoop/rainloop-webmail/releases/download/v1.12.1/rainloop-community-1.12.1.zip +SOURCE_SUM=5d7f99d0e145d22617de8c17e43f34842245d5570662f97f4352487671df811b +SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index 0a5abde..6309f2b 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Lightweight multi-account webmail", "fr": "Webmail léger multi-comptes" }, - "version": "1.11.1", + "version": "1.12.1~ynh1", "url": "https://www.rainloop.net/", "license": "AGPL-3.0", "maintainer": { diff --git a/sources/rainloop_version b/sources/rainloop_version index 0a5af26..f8f4f03 100644 --- a/sources/rainloop_version +++ b/sources/rainloop_version @@ -1 +1 @@ -1.11.3 +1.12.1 From 5f1497cb3410a707215ce5f2ea5cd1ad10c3ef1e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 18:10:50 +0100 Subject: [PATCH 11/53] Update license --- README.md | 3 +++ manifest.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 02beb65..fff003f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ Rainloop saves your PGP private keys in the browser storage. This means that you To upgrade the app once a new rainloop version is available, simply run in a local shell via ssh or otherwise : ``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop`` +## License + +**LICENSE:** AGPL-3.0-or-later ## Français Rainloop est un webmail simple et léger. diff --git a/manifest.json b/manifest.json index 6309f2b..6b0f776 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ }, "version": "1.12.1~ynh1", "url": "https://www.rainloop.net/", - "license": "AGPL-3.0", + "license": "AGPL-3.0-or-later", "maintainer": { "name": "scith, Djip007, polytan02" }, From 1df3c31491cca47dd3bbf35b0920cf7ea15e906e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 18:15:01 +0100 Subject: [PATCH 12/53] apply example_ynh to manifest.json --- manifest.json | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/manifest.json b/manifest.json index 6b0f776..8db2e0a 100644 --- a/manifest.json +++ b/manifest.json @@ -13,12 +13,12 @@ "name": "scith, Djip007, polytan02" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.4" }, "multi_instance": true, "services": [ "nginx", - "php5-fpm", + "php7.0-fpm", "mysql" ], "arguments": { @@ -30,7 +30,7 @@ "en": "Choose a domain for Rainloop", "fr": "Choisissez un domaine pour Rainloop" }, - "example": "domain.org" + "example": "example.com" }, { "name": "path", @@ -52,13 +52,28 @@ "default": false }, { - "name": "password", - "type": "password", + "name": "lang", + "type": "string", "ask": { - "en": "Choose a strong password for the 'admin' user", - "fr": "Choisissez un mot de passe fort pour l'administrateur, 'admin'" - } + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" + }, + "choices": ["English", "Francais"], + "default": "English" }, + { + "name": "password", + "type": "password", + "ask": { + "en": "Set the administrator password", + "fr": "Définissez le mot de passe administrateur" + }, + "help": { + "en": "Use the help field to add an information for the admin about this question.", + "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." + }, + "example": "Choose a password" + }, { "name": "ldap", "type": "boolean", @@ -67,15 +82,6 @@ "fr": "Souhaitez-vous ajouter les utilisateurs YunoHost dans les suggestions de destinataires ?" }, "default": true - }, - { - "name": "lang", - "ask": { - "en": "Select default language", - "fr": "Definir la langue par defaut" - }, - "choices": ["English", "Francais"], - "default": "English" } ] } From 92e63af00905c27fabc57a48e7e9fc7832350718 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 18:24:07 +0100 Subject: [PATCH 13/53] switch from lang to language variable --- check_process | 2 +- manifest.json | 6 +++--- scripts/install | 17 +++-------------- scripts/upgrade | 9 +++++++++ 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/check_process b/check_process index bb5cd2d..12eb76e 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ is_public=1 (PUBLIC|public=1|private=0) password="password" ldap=1 - lang="English" + language="fr" ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/manifest.json b/manifest.json index 8db2e0a..095d86a 100644 --- a/manifest.json +++ b/manifest.json @@ -52,14 +52,14 @@ "default": false }, { - "name": "lang", + "name": "language", "type": "string", "ask": { "en": "Choose the application language", "fr": "Choisissez la langue de l'application" }, - "choices": ["English", "Francais"], - "default": "English" + "choices": ["fr", "en"], + "default": "fr" }, { "name": "password", diff --git a/scripts/install b/scripts/install index a641701..9e8a51f 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC password=$YNH_APP_ARG_PASSWORD ldap=$YNH_APP_ARG_LDAP -lang=$YNH_APP_ARG_LANG +language=$YNH_APP_ARG_LANGUAGE app=$YNH_APP_INSTANCE_NAME @@ -100,18 +100,7 @@ ynh_add_fpm_config # AUTOCONFIG #================================================= -# Set lang => define from install manifest -case "$lang" in - Francais) - lang="fr" - ;; - English) - lang="en" - ;; - *) - lang="en" -esac -ynh_app_setting_set "$app" lang "$lang" +ynh_app_setting_set "$app" language "$language" # Set plugins plugins="ynh-login-mapping,auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts @@ -129,7 +118,7 @@ sudo cp ../conf/data/configs/application.ini "$application_file" ynh_replace_string "domain.tld" "$domain" "$application_file" ynh_replace_string "MYSQLUSER" "$db_name" "$application_file" ynh_replace_string "MYSQLPASSWORD" "$db_pwd" "$application_file" -ynh_replace_string "LANGTOCHANGE" "$lang" "$application_file" +ynh_replace_string "LANGTOCHANGE" "$language" "$application_file" ynh_replace_string "PLUGINSTOENABLE" "$plugins" "$application_file" diff --git a/scripts/upgrade b/scripts/upgrade index f698571..80fdbe2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,6 +21,15 @@ is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) +lang=$(ynh_app_setting_get $app lang) + +if [ -n "$lang" ] +then + language="$lang" + ynh_app_setting_set "$app" language "$language" + ynh_app_setting_delete "$app" lang +fi + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= From 39c9d68302d3cb7702f9a47f7686dd7fc7f5686a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 18:26:17 +0100 Subject: [PATCH 14/53] Apply example_ynh to manifest.json --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 095d86a..84701ce 100644 --- a/manifest.json +++ b/manifest.json @@ -27,8 +27,8 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain for Rainloop", - "fr": "Choisissez un domaine pour Rainloop" + "en": "Choose a domain name for Rainloop", + "fr": "Choisissez un nom de domaine pour Rainloop" }, "example": "example.com" }, From 7c7296410663f9341d62319c364ba93166daefa8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 18:40:19 +0100 Subject: [PATCH 15/53] apply example_ynh on install script --- scripts/install | 87 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index 9e8a51f..84419af 100644 --- a/scripts/install +++ b/scripts/install @@ -13,45 +13,63 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_print_info "Retrieve arguments from the manifest ..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC +language=$YNH_APP_ARG_LANGUAGE password=$YNH_APP_ARG_PASSWORD ldap=$YNH_APP_ARG_LDAP -language=$YNH_APP_ARG_LANGUAGE +### If it's a multi-instance app, meaning it can be installed several times independently +### The id of the app as stated in the manifest is available as $YNH_APP_ID +### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) +### The app instance name is available as $YNH_APP_INSTANCE_NAME +### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample +### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 +### - ynhexample__{N} for the subsequent installations, with N=3,4, ... +### The app instance name is probably what interests you most, since this is +### guaranteed to be unique. This is a good unique identifier to define installation path, +### db names, ... app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "Validating arguments ..." +### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". +### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" 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) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Store settings from manifest ..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app password $password +ynh_app_setting_set $app language $language +ynh_app_setting_set $app password $password #9999 Check if it's need to save password ynh_app_setting_set $app ldap $ldap #================================================= @@ -59,6 +77,16 @@ ynh_app_setting_set $app ldap $ldap #================================================= # CREATE A MYSQL DATABASE #================================================= +ynh_print_info "Creating a mysql database ..." + +### Use these lines if you need a database for the application. +### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. +### The password will be stored as 'mysqlpwd' into the app settings, +### and will be available as $db_pwd +### If you're not using these lines: +### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script +### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script +### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name @@ -67,6 +95,11 @@ ynh_mysql_setup_db $db_name $db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files ..." + +### `ynh_setup_source` is used to install an app from a zip or tar.gz file, +### downloaded from an upstream source, like a git repository. +### `ynh_setup_source` use the file conf/app.src ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src @@ -75,14 +108,17 @@ ynh_setup_source "$final_path/app" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx ..." + +### `ynh_add_nginx_config` will use the file conf/nginx.conf -ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf" # Create a dedicated nginx config ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user ..." # Create a system user ynh_system_user_create $app @@ -90,6 +126,18 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Configuring php-fpm ..." + +### `ynh_add_fpm_config` is used to set up a PHP config. +### You can remove it if your app doesn't use PHP. +### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini +### If you're not using these lines: +### - You can remove these files in conf/. +### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script +### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script +### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script +### With the reload at the end of the script. +### - And the section "PHP-FPM CONFIGURATION" in the upgrade script # Create a dedicated php-fpm config ynh_add_fpm_config @@ -100,7 +148,7 @@ ynh_add_fpm_config # AUTOCONFIG #================================================= -ynh_app_setting_set "$app" language "$language" + # Set plugins plugins="ynh-login-mapping,auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts @@ -151,12 +199,28 @@ fi # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server cp -rf ../sources/pgpback "$final_path/" +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= + +### `ynh_store_file_checksum` is used to store the checksum of a file. +### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, +### you can make a backup of this file before modifying it again if the admin had modified it. + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$application_file" + #================================================= # GENERIC FINALIZATION #================================================= # SECURE FILES AND DIRECTORIES #================================================= +### For security reason, any app should set the permissions to root: before anything else. +### Then, if write authorization is needed, any access should be given only to directories +### that really need such authorization. + +# Set permissions to app files find $final_path/. -type d -exec chmod 755 {} \; find $final_path/. -type f -exec chmod 644 {} \; chown -R $app: $final_path @@ -164,15 +228,24 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat ..." # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_app_setting_set $app skipped_uris "/" + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx ..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation completed" From a6aa229e1fde3e8a0b0e10f65b22ba27a8cef82c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 18:43:34 +0100 Subject: [PATCH 16/53] Apply example_ynh to nginx.conf --- conf/nginx.conf | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7f3d212..986f766 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,11 @@ -location __PATH__ { - alias __FINALPATH__/; +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { - if ($scheme = http) { + # Path to source + alias __FINALPATH__/ ; + + # Force usage of https + if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } @@ -18,15 +22,16 @@ location __PATH__ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } +### End of PHP configuration part # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; - } From c394df947b8b423337d467ca8f01f93be2446276 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:00:18 +0100 Subject: [PATCH 17/53] Apply example_ynh on php-fpm.conf --- conf/php-fpm.conf | 306 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 247 insertions(+), 59 deletions(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 6b5de9c..8bd761f 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,10 +1,11 @@ ; Start a new pool named 'www'. -; the variable $pool can we used in any directive and will be replaced by the +; the variable $pool can be used in any directive and will be replaced by the ; pool name ('www' here) -[__NAMETOCHANGE__] +[__NAME__] ; Per pool prefix ; It only applies on the following directives: +; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' @@ -16,21 +17,43 @@ ; Default Value: none ;prefix = /path/to/pools/$pool +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = __USER__ +group = __USER__ + ; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; '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 +; (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/php5-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php7.0-fpm-__NAME__.sock -; Set listen(2) backlog. A value of '-1' means unlimited. -; Default Value: 128 (-1 on FreeBSD and OpenBSD) -;listen.backlog = -1 +; Set listen(2) backlog. +; Default Value: 511 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 511 -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0660 +listen.owner = www-data +listen.group = www-data +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 +;listen.acl_users = +;listen.acl_groups = + +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be @@ -38,26 +61,26 @@ listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock ; Default Value: any ;listen.allowed_clients = 127.0.0.1 -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. -; Default Values: user and group are set as the running user -; mode is set to 0666 -listen.owner = www-data -listen.group = www-data -listen.mode = 0600 +; Specify the nice(2) priority to apply to the pool processes (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool processes will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; process.priority = -19 -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = __USER__ -group = __USER__ +; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user +; or group is differrent than the master process user. It allows to create process +; core dump and ptrace the process for the pool user. +; Default Value: no +; process.dumpable = yes ; Choose how the process manager will control the number of child processes. ; Possible Values: ; static - a fixed number (pm.max_children) of child processes; ; dynamic - the number of child processes are set dynamically based on the -; following directives: +; following directives. With this process management, there will be +; always at least 1 children. ; pm.max_children - the maximum number of children that can ; be alive at the same time. ; pm.start_servers - the number of children created on startup. @@ -69,33 +92,45 @@ group = __USER__ ; state (waiting to process). If the number ; of 'idle' processes is greater than this ; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. ; Note: This value is mandatory. pm = dynamic ; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes to be created when pm is set to 'dynamic'. +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. ; This value sets the limit on the number of simultaneous requests that will be ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. -; Note: Used when pm is set to either 'static' or 'dynamic' +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: This value is mandatory. -pm.max_children = 6 +pm.max_children = 5 ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 -pm.start_servers = 3 +pm.start_servers = 2 ; The desired minimum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = 3 +pm.min_spare_servers = 1 ; The desired maximum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = 5 +pm.max_spare_servers = 3 + +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +;pm.process_idle_timeout = 10s; ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For @@ -104,33 +139,98 @@ pm.max_spare_servers = 5 pm.max_requests = 500 ; The URI to view the FPM status page. If this value is not set, no URI will be -; recognized as a status page. By default, the status page shows the following -; information: -; accepted conn - the number of request accepted by the pool; +; recognized as a status page. It shows the following informations: ; pool - the name of the pool; -; process manager - static or dynamic; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; ; idle processes - the number of idle processes; ; active processes - the number of active processes; -; total processes - the number of idle + active processes. +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; ; max children reached - number of times, the process limit has been reached, ; when pm tries to start more children (works only for -; pm 'dynamic') -; The values of 'idle processes', 'active processes' and 'total processes' are -; updated each second. The value of 'accepted conn' is updated in real time. +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. ; Example output: -; accepted conn: 12073 ; pool: www ; process manager: static -; idle processes: 35 -; active processes: 65 -; total processes: 100 -; max children reached: 1 +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; ; By default the status page output is formatted as text/plain. Passing either -; 'html' or 'json' as a query string will return the corresponding output -; syntax. Example: +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: ; http://www.foo.bar/status ; http://www.foo.bar/status?json ; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: /usr/share/php/7.0/fpm/status.html +; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. @@ -154,12 +254,74 @@ ping.path = /ping ; Default Value: pong ;ping.response = pong -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -request_terminate_timeout = 120s +; The access log file +; Default: not set +;access.log = log/$pool.access.log + +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +;slowlog = log/$pool.log.slow +slowlog = /var/log/nginx/__NAME__.slow.log ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. @@ -167,10 +329,12 @@ request_terminate_timeout = 120s ; Default Value: 0 request_slowlog_timeout = 5s -; The log file for slow requests -; Default Value: not set -; Note: slowlog is mandatory if request_slowlog_timeout is set -slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +request_terminate_timeout = 120s ; Set open file descriptor rlimit. ; Default Value: system defined value @@ -204,6 +368,23 @@ chdir = __FINALPATH__ ; Default Value: no catch_workers_output = yes +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; execute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 .php7 + ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. ; Default Value: clean env @@ -238,6 +419,13 @@ catch_workers_output = yes ;php_admin_flag[log_errors] = on ;php_admin_value[memory_limit] = 32M -php_value[upload_max_filesize] = 10G -php_value[post_max_size] = 10G -php_value[mail.add_x_header] = Off +; Common values to change to increase file upload limit +php_admin_value[upload_max_filesize] = 10G +php_admin_value[post_max_size] = 10G +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 From c360364a50901e5d2259212a300c43595ada5d59 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:01:50 +0100 Subject: [PATCH 18/53] remove php-fpm.ini not needed --- conf/php-fpm.ini | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 conf/php-fpm.ini diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini deleted file mode 100644 index b4608de..0000000 --- a/conf/php-fpm.ini +++ /dev/null @@ -1,3 +0,0 @@ -upload_max_filesize = 10G -post_max_size = 10G -mail.add_x_header = Off From c5d055b4aa38eb07d69e70ec6b303d6a3a36953d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:04:15 +0100 Subject: [PATCH 19/53] Apply example_ynh on remove --- scripts/remove | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/remove b/scripts/remove index 52055bd..ab79cf0 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Load settings" app=$YNH_APP_INSTANCE_NAME @@ -24,6 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE THE MYSQL DATABASE #================================================= +ynh_print_info "Remove the mysql database" # Remove a database if it exists, along with the associated user ynh_mysql_remove_db $db_name $db_name @@ -31,6 +33,7 @@ ynh_mysql_remove_db $db_name $db_name #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Remove app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -38,6 +41,7 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Remove nginx configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -45,6 +49,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Remove php-fpm configuration" # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -62,6 +67,13 @@ gpg --batch --delete-key --yes Rainloop #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Remove the dedicated user" # Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Deletion completed" From 01305a117b83b8c638ac2b0a5f66f7ecc11b9fd0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:05:56 +0100 Subject: [PATCH 20/53] Apply example_ynh to backup --- scripts/backup | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/scripts/backup b/scripts/backup index 0a064c2..d7658fe 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,24 +6,24 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Load settings" app=$YNH_APP_INSTANCE_NAME @@ -36,24 +36,33 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_print_info "Backup the app main dir" ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backup nginx configuration" ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Backup php-fpm configuration" -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" -ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" +ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= +ynh_print_info "Backup the mysql database" ynh_mysql_dump_db "$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed. Please wait for YunoHost to create the backup." From cca04d58be69347a017724e627d9e93674f6adb6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:09:05 +0100 Subject: [PATCH 21/53] Apply example_ynh to restore --- scripts/restore | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/scripts/restore b/scripts/restore index 656cb89..2875535 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,24 +6,24 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Load settings" app=$YNH_APP_INSTANCE_NAME @@ -52,20 +52,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restore the app main directory" ynh_restore_file "$final_path" -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= - -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql - #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_print_info "Recreate the dedicated user" # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -81,14 +75,29 @@ chown -R $app: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" -ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" +ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_print_info "Restore the mysql database" + +db_pwd=$(ynh_app_setting_get $app mysqlpwd) +ynh_mysql_setup_db $db_name $db_name $db_pwd +ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_print_info "Reload nginx and php-fpm" -systemctl reload php5-fpm +systemctl reload php7.0-fpm systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed" From 1659d7fb99a4f42e52c28907113c6de821363f7c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:12:56 +0100 Subject: [PATCH 22/53] apply example_ynh to upgrade --- scripts/upgrade | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 80fdbe2..b01b43f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Load settings" app=$YNH_APP_INSTANCE_NAME @@ -19,6 +20,7 @@ domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) +language=$(ynh_app_setting_get $app language) db_name=$(ynh_app_setting_get $app db_name) lang=$(ynh_app_setting_get $app lang) @@ -33,6 +35,7 @@ fi #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensure downward compatibility" # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -58,6 +61,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backup the app before upgrading" # Backup the current version of the app ynh_backup_before_upgrade @@ -80,6 +84,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Download, check and unpack source" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" @@ -87,6 +92,7 @@ ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Reconfigure nginx" # Create a dedicated nginx config ynh_add_nginx_config @@ -94,13 +100,15 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Create a dedicated user" -# Create a system user +# Create a dedicated user (if not existing) ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Reconfigure php-fpm" # Create a dedicated php-fpm config ynh_add_fpm_config @@ -131,22 +139,32 @@ cp -rf ../sources/pgpback "$final_path/" # SECURE FILES AND DIRECTORIES #================================================= +# Set permissions on app files +chown -R $app: $final_path find $final_path/. -type d -exec chmod 755 {} \; find $final_path/. -type f -exec chmod 644 {} \; -chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Reconfigure SSOwat" # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_app_setting_set $app skipped_uris "/" + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set $app unprotected_uris "/" fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reload nginx" systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade completed" From 04c9bd719d62a3a3dcee2fa7cdc3cd902f1751a3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:15:29 +0100 Subject: [PATCH 23/53] apply example_ynh to check_process --- check_process | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/check_process b/check_process index 12eb76e..5c96dba 100644 --- a/check_process +++ b/check_process @@ -1,12 +1,17 @@ -;; Test Rainloop - auto_remove=1 - ; Manifest +# See here for more information +# https://github.com/YunoHost/package_check#syntax-check_process-file + +# Move this file from check_process.default to check_process when you have filled it. + +;; Test complet + ; Manifest domain="domain.tld" (DOMAIN) path="/rainloop" (PATH) - is_public=1 (PUBLIC|public=1|private=0) - password="password" - ldap=1 language="fr" + is_public=1 (PUBLIC|public=1|private=0) + password="pass" + ldap=1 + ; Checks pkg_linter=1 setup_sub_dir=1 @@ -20,20 +25,20 @@ multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 1=auto Level 2=auto Level 3=auto -# Level 4: - Level 4=1 -# Level 5: - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 +# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it. +# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well. + Level 4=1 + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 ;;; Options Email= Notification=none From b082797a6740da0c8868dd0c05f18f30906b5c8c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:29:26 +0100 Subject: [PATCH 24/53] apply example_ynh on README.md --- README.md | 87 ++++++++++++++++++++++++++++++++++++---------------- README_fr.md | 76 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 26 deletions(-) create mode 100644 README_fr.md diff --git a/README.md b/README.md index fff003f..1d7615f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,32 @@ # Rainloop for YunoHost - -* [rainloop](http://rainloop.net/ ): 1.12.1 - -## English + +[![Integration level](https://dash.yunohost.org/integration/rainloop.svg)](https://dash.yunohost.org/appci/app/rainloop) +[![Install rainloop with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=rainloop) + +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allow you to install rainloop 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.* + +## Overview Rainloop is a lightweight webmail. - + +**Shipped version:** 1.12.1 + +## License + +**LICENSE:** AGPL-3.0-or-later + +## Screenshots + +![](Link to an screenshot for this app) + +## Demo + +* [Official demo](Link to a demo site for this app) + +## Configuration + To configure it, go to http://DOMAIN.TLD/rainloop/app/?admin - The default login is : admin @@ -18,29 +40,42 @@ Each user can add a remote carddav server from their own parameters interface. Rainloop saves your PGP private keys in the browser storage. This means that you will loose your private keys if you clear your browser storage (e.g., private browsing, different computer...). This packages integrates [PGPback by chtixof](https://github.com/chtixof/pgpback_ynh) so you can store your PGP private keys on the server securely. Go to **http://DOMAIN.TLD/rainloop/pgpback** to backup your PGP keys on the server or restore them. -To upgrade the app once a new rainloop version is available, simply run in a local shell via ssh or otherwise : -``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop`` +## Documentation -## License + * Official documentation: https://www.rainloop.net/docs/ -**LICENSE:** AGPL-3.0-or-later - -## Français -Rainloop est un webmail simple et léger. - -Pour le configurer après l'installation, veuillez vous rendre sur http://DOMAIN.TLD/rainloop/app/?admin - -- Le nom d'utilisateur admin par défaut est : admin -- Le mot de passe admin par défaut est : Mot de passe choisi lors de l'installation -- Si vous avez oublié votre mot de passe, vous pouvez le retrouver avec ``sudo yunohost app settings rainloop password`` - -Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leurs propres paramètres. - -- Si vous utilisez Baikal, l'adresse à renseigner est du type : https://DOMAIN.TLD/baikal/card.php/addressbooks/UTILISATEUR/default/ -- Si vous utilisez NextCloud, l'adresse à renseigner est du type : https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts +## YunoHost specific features -Rainloop stocke les clés PGP privées dans le stockage de navigateur. Cela implique que vos clés seront perdues quand vous videz le stockage de navigateur (navigation incognito, changement d'ordinateur, ...). Ce paquet intègre [PGPback de chtixof](https://github.com/chtixof/pgpback_ynh) pour que vous puissiez stocker vos clés privées PGP de manière sécurisée sur le serveur. Rendez-vous **http://DOMAIN.TLD/rainloop/pgpback** pour stocker vos clés privées PGP sur le serveur ou les restaurer dans un nouveau navigateur. +#### Multi-users support -Pour mettre à jour rainloop lorsqu'une nouvelle version est disponible, lancez en console locale (ssh ou autre) : -``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop`` +Are LDAP and HTTP auth supported? +Can the app be used by multiple users? +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) + + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/rainloop_ynh/issues + * App website: http://rainloop.net/ + * App github website: https://github.com/RainLoop/rainloop-webmail + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +or +sudo yunohost app upgrade rainloop -u https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +``` diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..44d986f --- /dev/null +++ b/README_fr.md @@ -0,0 +1,76 @@ +# App exemple pour YunoHost + +[![Integration level](https://dash.yunohost.org/integration/rainloop.svg)](https://dash.yunohost.org/appci/app/rainloop) +[![Install rainloop with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=rainloop) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer rainloop rapidement et simplement sur un serveur Yunohost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* + +## Vue d'ensemble +Rainloop est un webmail simple et léger. + +**Version incluse:** 1.12.1 + +## Captures d'écran + +![](Lien vers une capture d'écran pour cette application) + +## Démo + +* [Démo officielle](Lien vers un site de démonstration pour cette application) + +## Configuration + +Pour le configurer après l'installation, veuillez vous rendre sur http://DOMAIN.TLD/rainloop/app/?admin + +- Le nom d'utilisateur admin par défaut est : admin +- Le mot de passe admin par défaut est : Mot de passe choisi lors de l'installation +- Si vous avez oublié votre mot de passe, vous pouvez le retrouver avec ``sudo yunohost app settings rainloop password`` + +Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leurs propres paramètres. + +- Si vous utilisez Baikal, l'adresse à renseigner est du type : https://DOMAIN.TLD/baikal/card.php/addressbooks/UTILISATEUR/default/ +- Si vous utilisez NextCloud, l'adresse à renseigner est du type : https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts + +Rainloop stocke les clés PGP privées dans le stockage de navigateur. Cela implique que vos clés seront perdues quand vous videz le stockage de navigateur (navigation incognito, changement d'ordinateur, ...). Ce paquet intègre [PGPback de chtixof](https://github.com/chtixof/pgpback_ynh) pour que vous puissiez stocker vos clés privées PGP de manière sécurisée sur le serveur. Rendez-vous **http://DOMAIN.TLD/rainloop/pgpback** pour stocker vos clés privées PGP sur le serveur ou les restaurer dans un nouveau navigateur. + +## Documentation + + * Documentation officielle: https://www.rainloop.net/docs/ + +## Caractéristiques spécifiques YunoHost + +#### Support multi-utilisateurs + +L'authentification LDAP et HTTP est-elle prise en charge? +L'application peut-elle être utilisée par plusieurs utilisateurs? + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) + +## Links + + * Signaler un bug: https://github.com/YunoHost-Apps/rainloop_ynh/issues + * Site de l'application: http://rainloop.net/ + * Site Github de l'application: https://github.com/RainLoop/rainloop-webmail + * Site web YunoHost: https://yunohost.org/ + +--- + +Informations pour les développeurs +---------------- + +**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +ou +sudo yunohost app upgrade rainloop -u https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +``` From ee40fa67236009753d79dbbf5d1ca205b0b7b0b6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:29:46 +0100 Subject: [PATCH 25/53] Add change_url --- scripts/change_url | 113 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 scripts/change_url diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..31c0ee5 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,113 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= +ynh_print_info "Retrieve arguments from the manifest" + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Load settings" + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get $app final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get "$app" db_name) +#db_pwd=$(ynh_app_setting_get $app db_pwd) + +#================================================= +# CHECK THE SYNTAX OF THE PATHS +#================================================= +ynh_print_info "Check the syntax of the paths" + +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) + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_print_info "Modify url in nginx configuration" + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# 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 + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + +# 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" + 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" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reload nginx" + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Change of url completed" From 12bd4b774805c4fc6b287c6aa4b46f121a66b10c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:36:11 +0100 Subject: [PATCH 26/53] Add screenshot --- README.md | 6 +----- README_fr.md | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1d7615f..be023bc 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,7 @@ Rainloop is a lightweight webmail. ## Screenshots -![](Link to an screenshot for this app) - -## Demo - -* [Official demo](Link to a demo site for this app) +![](http://www.rainloop.net/static/media/screenshots/v2/12.png) ## Configuration diff --git a/README_fr.md b/README_fr.md index 44d986f..cd2952f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -15,11 +15,7 @@ Rainloop est un webmail simple et léger. ## Captures d'écran -![](Lien vers une capture d'écran pour cette application) - -## Démo - -* [Démo officielle](Lien vers un site de démonstration pour cette application) +![](http://www.rainloop.net/static/media/screenshots/v2/12.png) ## Configuration From 971911ab1bc619939f2aef47c6bd5bed823b14a5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:37:12 +0100 Subject: [PATCH 27/53] Add license --- README_fr.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README_fr.md b/README_fr.md index cd2952f..0f8912f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,6 +13,10 @@ Rainloop est un webmail simple et léger. **Version incluse:** 1.12.1 +## License + +**LICENSE:** AGPL-3.0-or-later + ## Captures d'écran ![](http://www.rainloop.net/static/media/screenshots/v2/12.png) From 99f1a8c4b5624512eb64d07e730176b17f088c80 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:41:15 +0100 Subject: [PATCH 28/53] Add demo link --- README.md | 4 ++++ README_fr.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index be023bc..3516948 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ Rainloop is a lightweight webmail. ![](http://www.rainloop.net/static/media/screenshots/v2/12.png) +## Demo + +* [Official demo](https://mail.rainloop.net/) + ## Configuration To configure it, go to http://DOMAIN.TLD/rainloop/app/?admin diff --git a/README_fr.md b/README_fr.md index 0f8912f..2996c57 100644 --- a/README_fr.md +++ b/README_fr.md @@ -21,6 +21,10 @@ Rainloop est un webmail simple et léger. ![](http://www.rainloop.net/static/media/screenshots/v2/12.png) +## Démo + +* [Démo officielle](https://mail.rainloop.net/) + ## Configuration Pour le configurer après l'installation, veuillez vous rendre sur http://DOMAIN.TLD/rainloop/app/?admin From f974e14dc125336b7676a6cae7547f3dfe13b17f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 19:53:02 +0100 Subject: [PATCH 29/53] Fix php-fpm.conf --- conf/php-fpm.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 8bd761f..488cd35 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,7 +1,7 @@ ; Start a new pool named 'www'. ; the variable $pool can be used in any directive and will be replaced by the ; pool name ('www' here) -[__NAME__] +[__NAMETOCHANGE__] ; Per pool prefix ; It only applies on the following directives: @@ -33,7 +33,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-__NAME__.sock +listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) From 011efb5db0e7b82a4adada28affca8052b5601a1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 20:02:35 +0100 Subject: [PATCH 30/53] Fix upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index b01b43f..88bd8c8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,7 +87,7 @@ path_url=$(ynh_normalize_url_path $path_url) ynh_print_info "Download, check and unpack source" # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source "$final_path/app" #================================================= # NGINX CONFIGURATION From bf207b546f679bb739a3ca4812fa01a18f560a54 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 20:23:18 +0100 Subject: [PATCH 31/53] Fix change_url --- scripts/change_url | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 31c0ee5..5912915 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -97,6 +97,10 @@ fi # ... #================================================= +application_file="$final_path/app/data/_data_/_default_/configs/application.ini" +ynh_replace_string "default_domain = .^" "default_domain = \"$new_domain\"" "$application_file" +ynh_replace_string "$old_domain$old_path" "$new_domain$new_path" "$final_path/index.php" + #================================================= # GENERIC FINALISATION #================================================= From a41177d100321c0af701929d7380be8df9674096 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 Feb 2019 20:31:14 +0100 Subject: [PATCH 32/53] Fix svg --- README.md | 6 +++--- README_fr.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3516948..40980f3 100644 --- a/README.md +++ b/README.md @@ -53,9 +53,9 @@ Can the app be used by multiple users? #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) ## Links diff --git a/README_fr.md b/README_fr.md index 2996c57..e99f220 100644 --- a/README_fr.md +++ b/README_fr.md @@ -53,9 +53,9 @@ L'application peut-elle être utilisée par plusieurs utilisateurs? #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) ## Links From 6b1d42496bdec84a9e4be6608940cbf4248d0924 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Feb 2019 12:48:05 +0100 Subject: [PATCH 33/53] Variable rename from language to lang. --- check_process | 2 +- manifest.json | 2 +- scripts/install | 6 +++--- scripts/upgrade | 11 +---------- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/check_process b/check_process index 5c96dba..7dcddeb 100644 --- a/check_process +++ b/check_process @@ -7,7 +7,7 @@ ; Manifest domain="domain.tld" (DOMAIN) path="/rainloop" (PATH) - language="fr" + lang="fr" is_public=1 (PUBLIC|public=1|private=0) password="pass" ldap=1 diff --git a/manifest.json b/manifest.json index 84701ce..fd53967 100644 --- a/manifest.json +++ b/manifest.json @@ -52,7 +52,7 @@ "default": false }, { - "name": "language", + "name": "lang", "type": "string", "ask": { "en": "Choose the application language", diff --git a/scripts/install b/scripts/install index 84419af..21146dd 100644 --- a/scripts/install +++ b/scripts/install @@ -28,7 +28,7 @@ ynh_print_info "Retrieve arguments from the manifest ..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -language=$YNH_APP_ARG_LANGUAGE +lang=$YNH_APP_ARG_LANG password=$YNH_APP_ARG_PASSWORD ldap=$YNH_APP_ARG_LDAP @@ -68,7 +68,7 @@ ynh_print_info "Store settings from manifest ..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public -ynh_app_setting_set $app language $language +ynh_app_setting_set $app lang $lang ynh_app_setting_set $app password $password #9999 Check if it's need to save password ynh_app_setting_set $app ldap $ldap @@ -166,7 +166,7 @@ sudo cp ../conf/data/configs/application.ini "$application_file" ynh_replace_string "domain.tld" "$domain" "$application_file" ynh_replace_string "MYSQLUSER" "$db_name" "$application_file" ynh_replace_string "MYSQLPASSWORD" "$db_pwd" "$application_file" -ynh_replace_string "LANGTOCHANGE" "$language" "$application_file" +ynh_replace_string "LANGTOCHANGE" "$lang" "$application_file" ynh_replace_string "PLUGINSTOENABLE" "$plugins" "$application_file" diff --git a/scripts/upgrade b/scripts/upgrade index 88bd8c8..a0284c4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,17 +20,8 @@ domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) -language=$(ynh_app_setting_get $app language) -db_name=$(ynh_app_setting_get $app db_name) - lang=$(ynh_app_setting_get $app lang) - -if [ -n "$lang" ] -then - language="$lang" - ynh_app_setting_set "$app" language "$language" - ynh_app_setting_delete "$app" lang -fi +db_name=$(ynh_app_setting_get $app db_name) #================================================= # ENSURE DOWNWARD COMPATIBILITY From 07dfaf234bd9a7731634f38103407e253b42c805 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Feb 2019 14:05:07 +0100 Subject: [PATCH 34/53] Remove not needed comments --- check_process | 7 ------- conf/nginx.conf | 1 - scripts/backup | 4 ---- scripts/change_url | 2 +- scripts/install | 50 ---------------------------------------------- scripts/restore | 4 ---- 6 files changed, 1 insertion(+), 67 deletions(-) diff --git a/check_process b/check_process index 7dcddeb..f8eeef1 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,3 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) @@ -30,8 +25,6 @@ Level 1=auto Level 2=auto Level 3=auto -# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it. -# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well. Level 4=1 Level 5=auto Level 6=auto diff --git a/conf/nginx.conf b/conf/nginx.conf index 986f766..f5d5170 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -30,7 +30,6 @@ location __PATH__/ { fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } -### End of PHP configuration part # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/scripts/backup b/scripts/backup index d7658fe..0818680 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/change_url b/scripts/change_url index 5912915..e2bc138 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -94,7 +94,7 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# ... +# CONFIGURE #================================================= application_file="$final_path/app/data/_data_/_default_/configs/application.ini" diff --git a/scripts/install b/scripts/install index 21146dd..b24fff1 100644 --- a/scripts/install +++ b/scripts/install @@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -32,16 +28,6 @@ lang=$YNH_APP_ARG_LANG password=$YNH_APP_ARG_PASSWORD ldap=$YNH_APP_ARG_LDAP -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4, ... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names, ... app=$YNH_APP_INSTANCE_NAME #================================================= @@ -49,8 +35,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_print_info "Validating arguments ..." -### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -79,15 +63,6 @@ ynh_app_setting_set $app ldap $ldap #================================================= ynh_print_info "Creating a mysql database ..." -### Use these lines if you need a database for the application. -### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. -### The password will be stored as 'mysqlpwd' into the app settings, -### and will be available as $db_pwd -### If you're not using these lines: -### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script -### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script -### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script - db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name ynh_mysql_setup_db $db_name $db_name @@ -97,10 +72,6 @@ ynh_mysql_setup_db $db_name $db_name #================================================= ynh_print_info "Setting up source files ..." -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path/app" @@ -110,8 +81,6 @@ ynh_setup_source "$final_path/app" #================================================= ynh_print_info "Configuring nginx ..." -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated nginx config ynh_add_nginx_config @@ -128,17 +97,6 @@ ynh_system_user_create $app #================================================= ynh_print_info "Configuring php-fpm ..." -### `ynh_add_fpm_config` is used to set up a PHP config. -### You can remove it if your app doesn't use PHP. -### `ynh_add_fpm_config` will use the files conf/php-fpm.conf and conf/php-fpm.ini -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script -### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script -### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script -### With the reload at the end of the script. -### - And the section "PHP-FPM CONFIGURATION" in the upgrade script - # Create a dedicated php-fpm config ynh_add_fpm_config @@ -203,10 +161,6 @@ cp -rf ../sources/pgpback "$final_path/" # STORE THE CONFIG FILE CHECKSUM #================================================= -### `ynh_store_file_checksum` is used to store the checksum of a file. -### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, -### you can make a backup of this file before modifying it again if the admin had modified it. - # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$application_file" @@ -216,10 +170,6 @@ ynh_store_file_checksum "$application_file" # SECURE FILES AND DIRECTORIES #================================================= -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. - # Set permissions to app files find $final_path/. -type d -exec chmod 755 {} \; find $final_path/. -type f -exec chmod 644 {} \; diff --git a/scripts/restore b/scripts/restore index 2875535..58fde33 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,10 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors From 0b53c4f6f68be3c57458346cbd61aa266ea2166f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Feb 2019 14:19:01 +0100 Subject: [PATCH 35/53] removed not needed --- scripts/change_url | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index e2bc138..13ddd0b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,10 +30,6 @@ ynh_print_info "Load settings" # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get $app final_path) -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get "$app" db_name) -#db_pwd=$(ynh_app_setting_get $app db_pwd) - #================================================= # CHECK THE SYNTAX OF THE PATHS #================================================= From d65b500036ac6f51dccabd58eba8b6c479a90160 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Feb 2019 18:27:46 +0100 Subject: [PATCH 36/53] Desactivate change_url check. Even if working, there is an error with CI. Error already here in the master branch --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index f8eeef1..dac7494 100644 --- a/check_process +++ b/check_process @@ -20,7 +20,7 @@ multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=1 + change_url=0 ;;; Levels Level 1=auto Level 2=auto From daad1682c89ff26e07e8b8094e07944da325e2c9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 13 Feb 2019 19:21:57 +0100 Subject: [PATCH 37/53] Trying to manage change_url --- check_process | 2 +- scripts/change_url | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index dac7494..f8eeef1 100644 --- a/check_process +++ b/check_process @@ -20,7 +20,7 @@ multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 1=auto Level 2=auto diff --git a/scripts/change_url b/scripts/change_url index 13ddd0b..e19b82f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -95,7 +95,21 @@ fi application_file="$final_path/app/data/_data_/_default_/configs/application.ini" ynh_replace_string "default_domain = .^" "default_domain = \"$new_domain\"" "$application_file" -ynh_replace_string "$old_domain$old_path" "$new_domain$new_path" "$final_path/index.php" +if [ $old_path = "/" ] && [ $new_path = "/" ] +then + ynh_replace_string "$old_domain" "$new_domain" "$final_path/index.php" +elif [ $old_path != "/" ] && [ $new_path != "/" ] +then + ynh_replace_string "$old_domain$old_path" "$new_domain$new_path" "$final_path/index.php" +elif [ $old_path != "/" ] && [ $new_path = "/" ] +then + ynh_replace_string "$old_domain$old_path" "$new_domain" "$final_path/index.php" +elif [ $old_path = "/" ] && [ $new_path != "/" ] +then + ynh_replace_string "$old_domain" "$new_domain$new_path" "$final_path/index.php" +else + ynh_die "Error changing the URL" +fi #================================================= # GENERIC FINALISATION From 0664ec55c9c0d11280d3a6f04378ee9921029f02 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 25 Feb 2019 19:36:03 +0100 Subject: [PATCH 38/53] Normalization from example_ynh --- README.md | 104 ++++++++++++++++++++---------- check_process | 1 - conf/data/configs/application.ini | 14 ++-- conf/nginx.conf | 7 +- manifest.json | 3 +- scripts/backup | 7 +- scripts/install | 34 +++++----- scripts/restore | 7 +- scripts/upgrade | 10 +-- sources/sso/sso.php | 6 +- 10 files changed, 110 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 9c392e6..8f56a24 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,79 @@ -# Rainloop for YunoHost - -* [rainloop](http://rainloop.net/ ): 1.11.3 - -## English -Rainloop is a lightweight webmail. - -To configure it, go to http://DOMAIN.TLD/rainloop/app/?admin - -- The default login is : admin -- The default password is : Password chosen during install +# Rainloop for YunoHost + +[![Integration level](https://dash.yunohost.org/integration/rainloop.svg)](https://dash.yunohost.org/appci/app/rainloop) +[![Install Rainloop with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=rainloop) + +*[Lire ce readme en français.](./README_fr.md)* + +> *This package allow you to install Rainloop 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.* + +## Overview + +Rainloop is a lightweight webmail. + +**Shipped version:** 1.11.3 + +## Screenshots + +![](https://www.rainloop.net/static/media/screenshots/v2/12.png) + +## Demo + +* [YunoHost demo](https://demo.yunohost.org/rainloop/app/) +* [Official demo](https://mail.rainloop.net/) + +## Configuration + +Go to http://DOMAIN.TLD/rainloop/app/?admin + +- The default login is : admin +- The default password is : Password chosen during install - If you lost the admin password, you can retrieve it using ``sudo yunohost app settings rainloop password`` - -Each user can add a remote carddav server from their own parameters interface. + +Each user can add a remote carddav server from their own parameters interface. - If you use baikal, the CardDav address is: https://DOMAIN.TLD/baikal/card.php/addressbooks/USER/default/ - If you use NextCloud, the CardDav address is: https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts - -Rainloop saves your PGP private keys in the browser storage. This means that you will loose your private keys if you clear your browser storage (e.g., private browsing, different computer...). This packages integrates [PGPback by chtixof](https://github.com/chtixof/pgpback_ynh) so you can store your PGP private keys on the server securely. Go to **http://DOMAIN.TLD/rainloop/pgpback** to backup your PGP keys on the server or restore them. -To upgrade the app once a new rainloop version is available, simply run in a local shell via ssh or otherwise : -``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop`` +## Documentation - -## Français -Rainloop est un webmail simple et léger. - -Pour le configurer après l'installation, veuillez vous rendre sur http://DOMAIN.TLD/rainloop/app/?admin - -- Le nom d'utilisateur admin par défaut est : admin -- Le mot de passe admin par défaut est : Mot de passe choisi lors de l'installation -- Si vous avez oublié votre mot de passe, vous pouvez le retrouver avec ``sudo yunohost app settings rainloop password`` - -Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leurs propres paramètres. - -- Si vous utilisez Baikal, l'adresse à renseigner est du type : https://DOMAIN.TLD/baikal/card.php/addressbooks/UTILISATEUR/default/ -- Si vous utilisez NextCloud, l'adresse à renseigner est du type : https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts + * Official documentation: https://www.rainloop.net/docs/configuration/ + * YunoHost documentation: https://yunohost.org/#/app_rainloop -Rainloop stocke les clés PGP privées dans le stockage de navigateur. Cela implique que vos clés seront perdues quand vous videz le stockage de navigateur (navigation incognito, changement d'ordinateur, ...). Ce paquet intègre [PGPback de chtixof](https://github.com/chtixof/pgpback_ynh) pour que vous puissiez stocker vos clés privées PGP de manière sécurisée sur le serveur. Rendez-vous **http://DOMAIN.TLD/rainloop/pgpback** pour stocker vos clés privées PGP sur le serveur ou les restaurer dans un nouveau navigateur. +## YunoHost specific features -Pour mettre à jour rainloop lorsqu'une nouvelle version est disponible, lancez en console locale (ssh ou autre) : -``sudo yunohost app upgrade -u https://github.com/YunoHost-Apps/rainloop_ynh rainloop`` +#### Multi-users support +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) + +## Limitations + +## Additional information + +* Rainloop saves your PGP private keys in the browser storage. This means that you will loose your private keys if you clear your browser storage (e.g., private browsing, different computer...). This packages integrates [PGPback by chtixof](https://github.com/chtixof/pgpback_ynh) so you can store your PGP private keys on the server securely. Go to **http://DOMAIN.TLD/rainloop/pgpback** to backup your PGP keys on the server or restore them. + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/rainloop_ynh/issues + * Rainloop website: https://www.rainloop.net/ + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +or +sudo yunohost app upgrade rainloop -u https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index bb5cd2d..2dcc5da 100644 --- a/check_process +++ b/check_process @@ -1,5 +1,4 @@ ;; Test Rainloop - auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) path="/rainloop" (PATH) diff --git a/conf/data/configs/application.ini b/conf/data/configs/application.ini index 4b22ba1..71a4cc5 100644 --- a/conf/data/configs/application.ini +++ b/conf/data/configs/application.ini @@ -17,10 +17,10 @@ allow_themes = On allow_user_background = Off ; Language used by default -language = "LANGTOCHANGE" +language = "__LANGTOCHANGE__" ; Admin Panel interface language -language_admin = "LANGTOCHANGE" +language_admin = "__LANGTOCHANGE__" ; Allow language selection on settings screen allow_languages_on_settings = On @@ -58,9 +58,9 @@ allow_sharing = On allow_sync = On sync_interval = 20 type = "mysql" -pdo_dsn = "mysql:host=127.0.0.1;port=3306;dbname=MYSQLUSER" -pdo_user = "MYSQLUSER" -pdo_password = "MYSQLPASSWORD" +pdo_dsn = "mysql:host=127.0.0.1;port=3306;dbname=__MYSQLUSER__" +pdo_user = "__MYSQLUSER__" +pdo_password = "__MYSQLPASSWORD__" suggestions_limit = 30 [security] @@ -114,7 +114,7 @@ messagelist_actions = On attachments_actions = On [login] -default_domain = "domain.tld" +default_domain = "__DOMAIN__" ; Allow language selection on webmail login screen allow_languages_on_login = On @@ -138,7 +138,7 @@ sign_me_auto = "DefaultOff" enable = On ; List of enabled plugins -enabled_list = "PLUGINSTOENABLE" +enabled_list = "__PLUGINSTOENABLE__" [defaults] ; Editor mode used by default (Plain, Html, HtmlForced or PlainForced) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7f3d212..8a5987b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,6 +1,10 @@ -location __PATH__ { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + # Path to source alias __FINALPATH__/; + # Force usage of https if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } @@ -28,5 +32,4 @@ location __PATH__ { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; - } diff --git a/manifest.json b/manifest.json index 0a5abde..b2a2492 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Lightweight multi-account webmail", "fr": "Webmail léger multi-comptes" }, - "version": "1.11.1", + "version": "1.11.1~ynh2", "url": "https://www.rainloop.net/", "license": "AGPL-3.0", "maintainer": { @@ -70,6 +70,7 @@ }, { "name": "lang", + "type": "string", "ask": { "en": "Select default language", "fr": "Definir la langue par defaut" diff --git a/scripts/backup b/scripts/backup index 0a064c2..02fb585 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,12 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/install b/scripts/install index a641701..d105cc9 100644 --- a/scripts/install +++ b/scripts/install @@ -39,8 +39,6 @@ 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) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url @@ -76,7 +74,6 @@ ynh_setup_source "$final_path/app" # NGINX CONFIGURATION #================================================= -ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf" # Create a dedicated nginx config ynh_add_nginx_config @@ -111,32 +108,33 @@ case "$lang" in *) lang="en" esac -ynh_app_setting_set "$app" lang "$lang" +ynh_app_setting_set $app lang $lang # Set plugins -plugins="ynh-login-mapping,auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts +# This plugin is trying to automatically grab unknown domains if users want to add external email accounts +plugins="ynh-login-mapping,auto-domain-grab" if [ $ldap -eq 1 ] then - plugins="$plugins,ynh-ldap-suggestions" # This plugin is to suggest YunoHost users in recipients list + # This plugin is to suggest YunoHost users in recipients list + plugins="$plugins,ynh-ldap-suggestions" fi -ynh_app_setting_set "$app" plugins "$plugins" +ynh_app_setting_set $app plugins "$plugins" mkdir -p "$final_path/app/data/_data_/_default_/configs/" application_file="$final_path/app/data/_data_/_default_/configs/application.ini" -sudo cp ../conf/data/configs/application.ini "$application_file" -ynh_replace_string "domain.tld" "$domain" "$application_file" -ynh_replace_string "MYSQLUSER" "$db_name" "$application_file" -ynh_replace_string "MYSQLPASSWORD" "$db_pwd" "$application_file" -ynh_replace_string "LANGTOCHANGE" "$lang" "$application_file" -ynh_replace_string "PLUGINSTOENABLE" "$plugins" "$application_file" +cp ../conf/data/configs/application.ini "$application_file" +ynh_replace_string "__DOMAIN__" $domain "$application_file" +ynh_replace_string "__MYSQLUSER__" $db_name "$application_file" +ynh_replace_string "__MYSQLPASSWORD__" "$db_pwd" "$application_file" +ynh_replace_string "__LANGTOCHANGE__" $lang "$application_file" +ynh_replace_string "__PLUGINSTOENABLE__" "$plugins" "$application_file" # Set admin password php ../conf/config.php --index="$final_path/app/index.php" --password="$password" - # Add default domain configs by looping through all the domains already added mkdir -p "$final_path/app/data/_data_/_default_/domains/" # get list of ldap domains @@ -150,12 +148,12 @@ cp ../conf/data/domains/default.ini "$final_path/app/data/_data_/_default_/domai # install SSO - at the moment the index is the SSO and rainloop is installed in /app cp ../sources/sso/sso.php "$final_path/index.php" -ynh_replace_string "domain.tld" "$domain" "$final_path/index.php" -ynh_replace_string "ALIASTOCHANGE" "$final_path" "$final_path/index.php" +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/index.php" +ynh_replace_string "__ALIASTOCHANGE__" "$final_path" "$final_path/index.php" if [ $path_url = "/" ]; then - ynh_replace_string "ROOTTOCHANGE" "" "$final_path/index.php" + ynh_replace_string "__ROOTTOCHANGE__" "" "$final_path/index.php" else - ynh_replace_string "ROOTTOCHANGE" "$path_url" "$final_path/index.php" + ynh_replace_string "__ROOTTOCHANGE__" "$path_url" "$final_path/index.php" fi diff --git a/scripts/restore b/scripts/restore index 656cb89..89798b6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,12 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f698571..f41984e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -86,7 +86,7 @@ ynh_add_nginx_config # CREATE DEDICATED USER #================================================= -# Create a system user +# Create a dedicated user (if not existing) ynh_system_user_create $app #================================================= @@ -104,12 +104,12 @@ ynh_add_fpm_config # update SSO cp ../sources/sso/sso.php "$final_path/index.php" -ynh_replace_string "domain.tld" "$domain" "$final_path/index.php" -ynh_replace_string "ALIASTOCHANGE" "$final_path" "$final_path/index.php" +ynh_replace_string "__DOMAIN__" "$domain" "$final_path/index.php" +ynh_replace_string "__ALIASTOCHANGE__" "$final_path" "$final_path/index.php" if [ $path_url = "/" ]; then - ynh_replace_string "ROOTTOCHANGE" "" "$final_path/index.php" + ynh_replace_string "__ROOTTOCHANGE__" "" "$final_path/index.php" else - ynh_replace_string "ROOTTOCHANGE" "$path_url" "$final_path/index.php" + ynh_replace_string "__ROOTTOCHANGE__" "$path_url" "$final_path/index.php" fi diff --git a/sources/sso/sso.php b/sources/sso/sso.php index 98980ae..b8a374a 100644 --- a/sources/sso/sso.php +++ b/sources/sso/sso.php @@ -2,7 +2,7 @@ // Enable RainLoop Api and include index file $_ENV['RAINLOOP_INCLUDE_AS_API'] = true; -include 'ALIASTOCHANGE/app/index.php'; +include '__ALIASTOCHANGE__/app/index.php'; // Retrieve email and password if (isset($_SERVER['HTTP_EMAIL']) && isset($_SERVER['PHP_AUTH_PW'])) { @@ -11,8 +11,8 @@ if (isset($_SERVER['HTTP_EMAIL']) && isset($_SERVER['PHP_AUTH_PW'])) { $ssoHash = \RainLoop\Api::GetUserSsoHash($email, $password); // redirect to webmail sso url - \header('Location: https://domain.tldROOTTOCHANGE/app/index.php?sso&hash='.$ssoHash); + \header('Location: https://__DOMAIN____ROOTTOCHANGE__/app/index.php?sso&hash='.$ssoHash); } else { - \header('Location: https://domain.tldROOTTOCHANGE/app/index.php'); + \header('Location: https://__DOMAIN____ROOTTOCHANGE__/app/index.php'); } From 3d11de2bbc723f88ded7e3cfa468211c9b718b1c Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 25 Feb 2019 19:36:27 +0100 Subject: [PATCH 39/53] Normalization from example_ynh --- README_fr.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 README_fr.md diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..0a3aba6 --- /dev/null +++ b/README_fr.md @@ -0,0 +1,79 @@ +# Rainloop pour YunoHost + +[![Integration level](https://dash.yunohost.org/integration/rainloop.svg)](https://dash.yunohost.org/appci/app/rainloop) +[![Install Rainloop with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=rainloop) + +*[Read this readme in english.](./README.md)* + +> *Ce package vous permet d'installer Rainloop rapidement et simplement sur un serveur Yunohost. +Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* + +## Vue d'ensemble + +Rainloop est un webmail léger. + +**Version incluse:** 1.11.3 + +## Captures d'écran + +![](https://www.rainloop.net/static/media/screenshots/v2/12.png) + +## Démo + +* [Démo YunoHost](https://demo.yunohost.org/rainloop/app/) +* [Démo officielle](https://mail.rainloop.net/) + +## Configuration + +Veuillez vous rendre sur http://DOMAIN.TLD/rainloop/app/?admin + +- Le nom d'utilisateur admin par défaut est : admin +- Le mot de passe admin par défaut est : Mot de passe choisi lors de l'installation +- Si vous avez oublié votre mot de passe, vous pouvez le retrouver avec ``sudo yunohost app settings rainloop password`` + +Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leurs propres paramètres. + +- Si vous utilisez Baikal, l'adresse à renseigner est du type : https://DOMAIN.TLD/baikal/card.php/addressbooks/UTILISATEUR/default +- Si vous utilisez NextCloud, l'adresse à renseigner est du type : https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts + +## Documentation + + * Documentation officielle: https://www.rainloop.net/docs/configuration/ + * Documentation YunoHost: https://yunohost.org/#/app_rainloop_fr + +## Caractéristiques spécifiques YunoHost + +#### Support multi-utilisateurs + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) + +## Limitations + +## Informations additionnelles + +* Rainloop stocke les clés PGP privées dans le stockage de navigateur. Cela implique que vos clés seront perdues quand vous videz le stockage de navigateur (navigation incognito, changement d'ordinateur, ...). Ce paquet intègre [PGPback de chtixof](https://github.com/chtixof/pgpback_ynh) pour que vous puissiez stocker vos clés privées PGP de manière sécurisée sur le serveur. Rendez-vous **http://DOMAIN.TLD/rainloop/pgpback** pour stocker vos clés privées PGP sur le serveur ou les restaurer dans un nouveau navigateur. + +## Links + + * Signaler un bug: https://github.com/YunoHost-Apps/rainloop_ynh/issues + * Site de Rainloop: https://www.rainloop.net/ + * Site web YunoHost: https://yunohost.org/ + +--- + +Informations pour les développeurs +---------------- + +**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing). + +Pour essayer la branche testing, procédez comme suit. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +ou +sudo yunohost app upgrade rainloop -u https://github.com/YunoHost-Apps/rainloop_ynh/tree/testing --debug +``` From deb9810068cfc1aa73e4d449d40b29e9407b07e2 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 25 Feb 2019 19:38:00 +0100 Subject: [PATCH 40/53] Add progression with ynh_print_info --- manifest.json | 2 +- scripts/backup | 11 +++++++++++ scripts/install | 16 ++++++++++++++++ scripts/remove | 13 +++++++++++++ scripts/restore | 12 ++++++++++++ scripts/upgrade | 16 ++++++++++++++++ 6 files changed, 69 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b2a2492..e42e24e 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "name": "scith, Djip007, polytan02" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.2.0" }, "multi_instance": true, "services": [ diff --git a/scripts/backup b/scripts/backup index 02fb585..6331abb 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -31,18 +32,21 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Backing up php-fpm configuration..." ynh_backup "/etc/php5/fpm/pool.d/$app.conf" ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" @@ -50,5 +54,12 @@ ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= # BACKUP THE MYSQL DATABASE #================================================= +ynh_print_info "Backing up the MySQL database..." ynh_mysql_dump_db "$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index d105cc9..1f4b167 100644 --- a/scripts/install +++ b/scripts/install @@ -32,6 +32,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -45,6 +46,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -57,6 +59,7 @@ ynh_app_setting_set $app ldap $ldap #================================================= # CREATE A MYSQL DATABASE #================================================= +ynh_print_info "Creating a MySQL database..." db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name @@ -65,6 +68,7 @@ ynh_mysql_setup_db $db_name $db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Setting up source files..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src @@ -73,6 +77,7 @@ ynh_setup_source "$final_path/app" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -80,6 +85,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user..." # Create a system user ynh_system_user_create $app @@ -87,6 +93,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Configuring php-fpm..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -96,6 +103,7 @@ ynh_add_fpm_config #================================================= # AUTOCONFIG #================================================= +ynh_print_info "Configuring rainloop..." # Set lang => define from install manifest case "$lang" in @@ -173,6 +181,7 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -183,5 +192,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 52055bd..f630a9d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -24,6 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE THE MYSQL DATABASE #================================================= +ynh_print_info "Removing the MySQL database" # Remove a database if it exists, along with the associated user ynh_mysql_remove_db $db_name $db_name @@ -31,6 +33,7 @@ ynh_mysql_remove_db $db_name $db_name #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -38,6 +41,7 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -45,6 +49,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Removing php-fpm configuration" # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -54,6 +59,7 @@ ynh_remove_fpm_config #================================================= # REMOVE GPG KEY #================================================= +ynh_print_info "Removing GPG key" gpg --batch --delete-key --yes Rainloop @@ -62,6 +68,13 @@ gpg --batch --delete-key --yes Rainloop #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" # Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 89798b6..6926735 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,6 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -30,6 +31,7 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -47,12 +49,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" #================================================= # RESTORE THE MYSQL DATABASE #================================================= +ynh_print_info "Restoring the MySQL database..." db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd @@ -61,6 +65,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_print_info "Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -84,6 +89,13 @@ ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= +ynh_print_info "Reloading nginx web server and php-fpm..." systemctl reload php5-fpm systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index f41984e..48915ea 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -24,6 +25,7 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= +ynh_print_info "Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -49,6 +51,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -71,6 +74,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_print_info "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" @@ -78,6 +82,7 @@ ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -85,6 +90,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -92,6 +98,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_print_info "Upgrading php-fpm configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -101,6 +108,7 @@ ynh_add_fpm_config #================================================= # UPDATE SSO AND PGP #================================================= +ynh_print_info "Upgrading rainloop configuration..." # update SSO cp ../sources/sso/sso.php "$final_path/index.php" @@ -129,6 +137,7 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -139,5 +148,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From 5ccd2d13bd4cc451775c3c468f3d11ef635772f6 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 25 Feb 2019 19:39:14 +0100 Subject: [PATCH 41/53] Use php7 --- conf/nginx.conf | 2 +- conf/php-fpm.conf | 315 +++++++++++++++++++++++++++++++++++++--------- conf/php-fpm.ini | 3 - manifest.json | 2 +- scripts/backup | 3 +- scripts/restore | 5 +- 6 files changed, 258 insertions(+), 72 deletions(-) delete mode 100644 conf/php-fpm.ini diff --git a/conf/nginx.conf b/conf/nginx.conf index 8a5987b..d96b561 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -22,7 +22,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 6b5de9c..59e6c01 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,10 +1,11 @@ ; Start a new pool named 'www'. -; the variable $pool can we used in any directive and will be replaced by the +; the variable $pool can be used in any directive and will be replaced by the ; pool name ('www' here) [__NAMETOCHANGE__] ; Per pool prefix ; It only applies on the following directives: +; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' @@ -16,21 +17,43 @@ ; Default Value: none ;prefix = /path/to/pools/$pool +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = __USER__ +group = __USER__ + ; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; '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 +; (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/php5-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock -; Set listen(2) backlog. A value of '-1' means unlimited. -; Default Value: 128 (-1 on FreeBSD and OpenBSD) -;listen.backlog = -1 +; Set listen(2) backlog. +; Default Value: 511 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 511 -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0660 +listen.owner = www-data +listen.group = www-data +;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 +;listen.acl_users = +;listen.acl_groups = + +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be @@ -38,26 +61,26 @@ listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock ; Default Value: any ;listen.allowed_clients = 127.0.0.1 -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. -; Default Values: user and group are set as the running user -; mode is set to 0666 -listen.owner = www-data -listen.group = www-data -listen.mode = 0600 +; Specify the nice(2) priority to apply to the pool processes (only if set) +; The value can vary from -19 (highest priority) to 20 (lower priority) +; Note: - It will only work if the FPM master process is launched as root +; - The pool processes will inherit the master process priority +; unless it specified otherwise +; Default Value: no set +; process.priority = -19 -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = __USER__ -group = __USER__ +; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user +; or group is differrent than the master process user. It allows to create process +; core dump and ptrace the process for the pool user. +; Default Value: no +; process.dumpable = yes ; Choose how the process manager will control the number of child processes. ; Possible Values: ; static - a fixed number (pm.max_children) of child processes; ; dynamic - the number of child processes are set dynamically based on the -; following directives: +; following directives. With this process management, there will be +; always at least 1 children. ; pm.max_children - the maximum number of children that can ; be alive at the same time. ; pm.start_servers - the number of children created on startup. @@ -69,73 +92,150 @@ group = __USER__ ; state (waiting to process). If the number ; of 'idle' processes is greater than this ; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. ; Note: This value is mandatory. pm = dynamic ; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes to be created when pm is set to 'dynamic'. +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. ; This value sets the limit on the number of simultaneous requests that will be ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. -; Note: Used when pm is set to either 'static' or 'dynamic' +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' ; Note: This value is mandatory. -pm.max_children = 6 +pm.max_children = 5 ; The number of child processes created on startup. ; Note: Used only when pm is set to 'dynamic' ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 -pm.start_servers = 3 +pm.start_servers = 2 ; The desired minimum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = 3 +pm.min_spare_servers = 1 ; The desired maximum number of idle server processes. ; Note: Used only when pm is set to 'dynamic' ; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = 5 +pm.max_spare_servers = 3 + +; The number of seconds after which an idle process will be killed. +; Note: Used only when pm is set to 'ondemand' +; Default Value: 10s +;pm.process_idle_timeout = 10s; ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; Default Value: 0 -pm.max_requests = 500 +;pm.max_requests = 500 ; The URI to view the FPM status page. If this value is not set, no URI will be -; recognized as a status page. By default, the status page shows the following -; information: -; accepted conn - the number of request accepted by the pool; +; recognized as a status page. It shows the following informations: ; pool - the name of the pool; -; process manager - static or dynamic; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; ; idle processes - the number of idle processes; ; active processes - the number of active processes; -; total processes - the number of idle + active processes. +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; ; max children reached - number of times, the process limit has been reached, ; when pm tries to start more children (works only for -; pm 'dynamic') -; The values of 'idle processes', 'active processes' and 'total processes' are -; updated each second. The value of 'accepted conn' is updated in real time. +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. ; Example output: -; accepted conn: 12073 ; pool: www ; process manager: static -; idle processes: 35 -; active processes: 65 -; total processes: 100 -; max children reached: 1 +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; ; By default the status page output is formatted as text/plain. Passing either -; 'html' or 'json' as a query string will return the corresponding output -; syntax. Example: +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: ; http://www.foo.bar/status ; http://www.foo.bar/status?json ; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: /usr/share/php/7.0/fpm/status.html +; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. ; Default Value: not set -pm.status_path = /fpm-status +;pm.status_path = /status ; The ping URI to call the monitoring page of FPM. If this value is not set, no ; URI will be recognized as a ping page. This could be used to test from outside @@ -147,39 +247,102 @@ pm.status_path = /fpm-status ; anything, but it may not be a good idea to use the .php extension or it ; may conflict with a real PHP file. ; Default Value: not set -ping.path = /ping +;ping.path = /ping ; This directive may be used to customize the response of a ping request. The ; response is formatted as text/plain with a 200 response code. ; Default Value: pong ;ping.response = pong -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -request_terminate_timeout = 120s +; The access log file +; Default: not set +;access.log = log/$pool.access.log + +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +;slowlog = log/$pool.log.slow ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 -request_slowlog_timeout = 5s +;request_slowlog_timeout = 0 -; The log file for slow requests -; Default Value: not set -; Note: slowlog is mandatory if request_slowlog_timeout is set -slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +request_terminate_timeout = 1d ; Set open file descriptor rlimit. ; Default Value: system defined value -rlimit_files = 4096 +;rlimit_files = 1024 ; Set max core size rlimit. ; Possible Values: 'unlimited' or an integer greater or equal to 0 ; Default Value: system defined value -rlimit_core = 0 +;rlimit_core = 0 ; Chroot to this directory at the start. This value must be defined as an ; absolute path. When this value is not set, chroot is not used. @@ -202,7 +365,24 @@ chdir = __FINALPATH__ ; Note: on highloaded environement, this can cause some delay in the page ; process time (several ms). ; Default Value: no -catch_workers_output = yes +;catch_workers_output = yes + +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; execute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 .php7 ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. @@ -238,6 +418,17 @@ catch_workers_output = yes ;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 + php_value[upload_max_filesize] = 10G php_value[post_max_size] = 10G php_value[mail.add_x_header] = Off diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini deleted file mode 100644 index b4608de..0000000 --- a/conf/php-fpm.ini +++ /dev/null @@ -1,3 +0,0 @@ -upload_max_filesize = 10G -post_max_size = 10G -mail.add_x_header = Off diff --git a/manifest.json b/manifest.json index e42e24e..b0df892 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "multi_instance": true, "services": [ "nginx", - "php5-fpm", + "php7.0-fpm", "mysql" ], "arguments": { diff --git a/scripts/backup b/scripts/backup index 6331abb..271844f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,8 +48,7 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_print_info "Backing up php-fpm configuration..." -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" -ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" +ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/restore b/scripts/restore index 6926735..921fc65 100644 --- a/scripts/restore +++ b/scripts/restore @@ -81,8 +81,7 @@ chown -R $app: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" -ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" +ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # GENERIC FINALIZATION @@ -91,7 +90,7 @@ ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" #================================================= ynh_print_info "Reloading nginx web server and php-fpm..." -systemctl reload php5-fpm +systemctl reload php7.0-fpm systemctl reload nginx #================================================= From d1559677f5d849d2d68cc69e7e65f133e973bec9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 15:01:28 +0100 Subject: [PATCH 42/53] Apply last example_ynh --- scripts/_common.sh | 4 ++-- scripts/backup | 12 ++++++------ scripts/change_url | 8 ++++---- scripts/install | 10 +++++----- scripts/remove | 14 +++++++------- scripts/restore | 13 +++++++------ scripts/upgrade | 20 ++++++++++---------- 7 files changed, 41 insertions(+), 40 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 4a6deae..b905339 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# PERSONNAL HELPERS +# PERSONAL HELPERS #================================================= #================================================= @@ -9,5 +9,5 @@ #================================================= #================================================= -# FUTUR OFFICIAL HELPERS +# FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 0818680..271844f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,7 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Load settings" +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -32,28 +32,28 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backup the app main dir" +ynh_print_info "Backing up the main app directory..." ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backup nginx configuration" +ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Backup php-fpm configuration" +ynh_print_info "Backing up php-fpm configuration..." ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info "Backup the mysql database" +ynh_print_info "Backing up the MySQL database..." ynh_mysql_dump_db "$db_name" > db.sql @@ -61,4 +61,4 @@ ynh_mysql_dump_db "$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed. Please wait for YunoHost to create the backup." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index e19b82f..d279118 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,7 +25,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Load settings" +ynh_print_info "Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get $app final_path) @@ -61,7 +61,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Modify url in nginx configuration" +ynh_print_info "Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -116,7 +116,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reload nginx" +ynh_print_info "Reloading nginx web server..." systemctl reload nginx @@ -124,4 +124,4 @@ systemctl reload nginx # END OF SCRIPT #================================================= -ynh_print_info "Change of url completed" +ynh_print_info "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index b24fff1..4510754 100644 --- a/scripts/install +++ b/scripts/install @@ -33,7 +33,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating arguments ..." +ynh_print_info "Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -47,7 +47,7 @@ ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info "Store settings from manifest ..." +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url @@ -79,7 +79,7 @@ ynh_setup_source "$final_path/app" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx ..." +ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -190,7 +190,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx ..." +ynh_print_info "Reloading nginx web server..." systemctl reload nginx @@ -198,4 +198,4 @@ systemctl reload nginx # END OF SCRIPT #================================================= -ynh_print_info "Installation completed" +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index ab79cf0..7094419 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Load settings" +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -25,7 +25,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_print_info "Remove the mysql database" +ynh_print_info "Removing the MySQL database" # Remove a database if it exists, along with the associated user ynh_mysql_remove_db $db_name $db_name @@ -33,7 +33,7 @@ ynh_mysql_remove_db $db_name $db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Remove app main directory" +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -41,7 +41,7 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Remove nginx configuration" +ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -49,7 +49,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Remove php-fpm configuration" +ynh_print_info "Removing php-fpm configuration" # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -67,7 +67,7 @@ gpg --batch --delete-key --yes Rainloop #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Remove the dedicated user" +ynh_print_info "Removing the dedicated system user" # Delete a system user ynh_system_user_delete $app @@ -76,4 +76,4 @@ ynh_system_user_delete $app # END OF SCRIPT #================================================= -ynh_print_info "Deletion completed" +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 58fde33..a5e21df 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,7 +19,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Load settings" +ynh_print_info "Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -31,6 +31,7 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_print_info "Validating restoration parameters..." ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -48,14 +49,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restore the app main directory" +ynh_print_info "Restoring the app main directory..." ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreate the dedicated user" +ynh_print_info "Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create $app @@ -76,7 +77,7 @@ ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_print_info "Restore the mysql database" +ynh_print_info "Restoring the MySQL database..." db_pwd=$(ynh_app_setting_get $app mysqlpwd) ynh_mysql_setup_db $db_name $db_name $db_pwd @@ -87,7 +88,7 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_print_info "Reload nginx and php-fpm" +ynh_print_info "Reloading nginx web server and php-fpm..." systemctl reload php7.0-fpm systemctl reload nginx @@ -96,4 +97,4 @@ systemctl reload nginx # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed" +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index a0284c4..186e2cb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Load settings" +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -26,7 +26,7 @@ db_name=$(ynh_app_setting_get $app db_name) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensure downward compatibility" +ynh_print_info "Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then @@ -52,7 +52,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backup the app before upgrading" +ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -75,7 +75,7 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Download, check and unpack source" +ynh_print_info "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path/app" @@ -83,7 +83,7 @@ ynh_setup_source "$final_path/app" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Reconfigure nginx" +ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config @@ -91,7 +91,7 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Create a dedicated user" +ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create $app @@ -99,7 +99,7 @@ ynh_system_user_create $app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Reconfigure php-fpm" +ynh_print_info "Upgrading php-fpm configuration..." # Create a dedicated php-fpm config ynh_add_fpm_config @@ -138,7 +138,7 @@ find $final_path/. -type f -exec chmod 644 {} \; #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Reconfigure SSOwat" +ynh_print_info "Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -150,7 +150,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reload nginx" +ynh_print_info "Reloading nginx web server..." systemctl reload nginx @@ -158,4 +158,4 @@ systemctl reload nginx # END OF SCRIPT #================================================= -ynh_print_info "Upgrade completed" +ynh_print_info "Upgrade of $app completed" From 6c0e86aa946e9013392627a58223bc47da26797d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 15:02:33 +0100 Subject: [PATCH 43/53] remove not needed licence information on README.md --- README.md | 4 ---- README_fr.md | 4 ---- 2 files changed, 8 deletions(-) diff --git a/README.md b/README.md index 40980f3..23d2202 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,6 @@ Rainloop is a lightweight webmail. **Shipped version:** 1.12.1 -## License - -**LICENSE:** AGPL-3.0-or-later - ## Screenshots ![](http://www.rainloop.net/static/media/screenshots/v2/12.png) diff --git a/README_fr.md b/README_fr.md index e99f220..375fd24 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,10 +13,6 @@ Rainloop est un webmail simple et léger. **Version incluse:** 1.12.1 -## License - -**LICENSE:** AGPL-3.0-or-later - ## Captures d'écran ![](http://www.rainloop.net/static/media/screenshots/v2/12.png) From 34b3db4c185bed60a64462c7a97ac88e6dcf87b4 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 9 Mar 2019 13:02:31 +0100 Subject: [PATCH 44/53] Corrections after conflict merge --- README.md | 2 -- manifest.json | 26 +++++++++++++------------- scripts/install | 1 - scripts/upgrade | 1 - 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 7aeb532..c6d5364 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,6 @@ Each user can add a remote carddav server from their own parameters interface. - If you use baikal, the CardDav address is: https://DOMAIN.TLD/baikal/card.php/addressbooks/USER/default/ - If you use NextCloud, the CardDav address is: https://DOMAIN.TLD/nextcloud/remote.php/carddav/addressbooks/USER/contacts -Rainloop saves your PGP private keys in the browser storage. This means that you will loose your private keys if you clear your browser storage (e.g., private browsing, different computer...). This packages integrates [PGPback by chtixof](https://github.com/chtixof/pgpback_ynh) so you can store your PGP private keys on the server securely. Go to **http://DOMAIN.TLD/rainloop/pgpback** to backup your PGP keys on the server or restore them. - ## Documentation * Official documentation: https://www.rainloop.net/docs/configuration/ diff --git a/manifest.json b/manifest.json index e47b5fc..a884fb3 100644 --- a/manifest.json +++ b/manifest.json @@ -51,19 +51,19 @@ }, "default": false }, - { - "name": "password", - "type": "password", - "ask": { - "en": "Set the administrator password", - "fr": "Définissez le mot de passe administrateur" - }, - "help": { - "en": "Use the help field to add an information for the admin about this question.", - "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." - }, - "example": "Choose a password" - }, + { + "name": "password", + "type": "password", + "ask": { + "en": "Set the administrator password", + "fr": "Définissez le mot de passe administrateur" + }, + "help": { + "en": "Use the help field to add an information for the admin about this question.", + "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." + }, + "example": "Choose a password" + }, { "name": "ldap", "type": "boolean", diff --git a/scripts/install b/scripts/install index 9fe7f63..c843404 100644 --- a/scripts/install +++ b/scripts/install @@ -166,7 +166,6 @@ else ynh_replace_string "__ROOTTOCHANGE__" "$path_url" "$final_path/index.php" fi - # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server cp -rf ../sources/pgpback "$final_path/" diff --git a/scripts/upgrade b/scripts/upgrade index b441b6a..0502049 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -121,7 +121,6 @@ else ynh_replace_string "__ROOTTOCHANGE__" "$path_url" "$final_path/index.php" fi - # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server cp -rf ../sources/pgpback "$final_path/" From d405ddee0ce6402458160534edf92a0d2d317fed Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 9 Mar 2019 19:20:49 +0100 Subject: [PATCH 45/53] Corrections after conflict merge --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index f8eeef1..3400f69 100644 --- a/check_process +++ b/check_process @@ -2,9 +2,9 @@ ; Manifest domain="domain.tld" (DOMAIN) path="/rainloop" (PATH) - lang="fr" + lang="English" is_public=1 (PUBLIC|public=1|private=0) - password="pass" + password="pass" ldap=1 ; Checks From e2daada17cc9ce3582ca26a648a8ec4a3b83a8cb Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 24 Mar 2019 16:47:13 +0100 Subject: [PATCH 46/53] Update pull_request_template.md --- pull_request_template.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 0096533..fc9b81b 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,7 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20-BRANCH-%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20-BRANCH-%20(Official)/) *Please replace '-BRANCH-' in this link for a PR from a local branch.* -or -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-%20(Official_fork)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-%20(Official_fork)/) *Replace '-NUM-' by the PR number in this link for a PR from a forked repository.* +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-/) +*Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 71b45a0ae1f4988f01435d14982570d638a354eb Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 15 Apr 2019 20:55:23 +0200 Subject: [PATCH 47/53] Move from ci-apps-dev to ci-apps-hq --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index fc9b81b..667862d 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -19,6 +19,6 @@ - [ ] **Approval (LGTM)** : - [ ] **Approval (LGTM)** : - **CI succeeded** : -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-/) +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/rainloop_ynh%20PR-NUM-/) *Please replace '-NUM-' in this link by the PR number.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 3ea4dc5cf6f797e1827eaa6b3ac833d61bd7eebb Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 18 May 2019 16:47:43 +0200 Subject: [PATCH 48/53] Normalization from example_ynh --- README.md | 6 ++-- README_fr.md | 6 ++-- check_process | 9 ----- manifest.json | 2 +- scripts/backup | 26 +++++++------- scripts/change_url | 51 +++++++++++---------------- scripts/install | 88 ++++++++++++++++++++++------------------------ scripts/remove | 28 +++++++-------- scripts/restore | 47 +++++++++++++------------ scripts/upgrade | 78 ++++++++++++++++++++++------------------ 10 files changed, 165 insertions(+), 176 deletions(-) diff --git a/README.md b/README.md index c6d5364..60aadea 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,9 @@ Each user can add a remote carddav server from their own parameters interface. #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) ## Limitations diff --git a/README_fr.md b/README_fr.md index 2f7543f..63639cb 100644 --- a/README_fr.md +++ b/README_fr.md @@ -47,9 +47,9 @@ Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leurs pr #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Official%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/rainloop%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/rainloop/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/rainloop%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/rainloop/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/rainloop%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/rainloop/) ## Limitations diff --git a/check_process b/check_process index 3400f69..3473ae1 100644 --- a/check_process +++ b/check_process @@ -22,16 +22,7 @@ port_already_use=0 change_url=1 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=1 Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email= Notification=none diff --git a/manifest.json b/manifest.json index a884fb3..dc9ed69 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "name": "scith, Djip007, polytan02" }, "requirements": { - "yunohost": ">= 3.2.0" + "yunohost": ">= 3.5.0" }, "multi_instance": true, "services": [ diff --git a/scripts/backup b/scripts/backup index 271844f..a1d85d7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,46 +19,46 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +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) -db_name=$(ynh_app_setting_get $app db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_script_progression --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backing up nginx web server configuration..." +ynh_script_progression --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Backing up php-fpm configuration..." +ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_print_info "Backing up the MySQL database..." +ynh_script_progression --message="Backing up the MySQL database..." -ynh_mysql_dump_db "$db_name" > db.sql +ynh_mysql_dump_db --database="$db_name" > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/change_url b/scripts/change_url index d279118..c092929 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= -ynh_print_info "Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -25,20 +24,10 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get $app final_path) - -#================================================= -# CHECK THE SYNTAX OF THE PATHS -#================================================= -ynh_print_info "Check the syntax of the paths" - -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) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -61,7 +50,7 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_script_progression --message="Updating nginx web server configuration..." --weight=2 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -69,7 +58,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf 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" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" @@ -81,10 +70,10 @@ fi 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 #================================================= @@ -92,23 +81,25 @@ fi #================================================= # CONFIGURE #================================================= +ynh_script_progression --message="Reconfiguring rainloop..." --weight=2 application_file="$final_path/app/data/_data_/_default_/configs/application.ini" -ynh_replace_string "default_domain = .^" "default_domain = \"$new_domain\"" "$application_file" -if [ $old_path = "/" ] && [ $new_path = "/" ] +ynh_replace_string --match_string="default_domain = .^" --replace_string="default_domain = \"$new_domain\"" --target_file="$application_file" + +if [ "$old_path" = "/" ] && [ "$new_path" = "/" ] then - ynh_replace_string "$old_domain" "$new_domain" "$final_path/index.php" -elif [ $old_path != "/" ] && [ $new_path != "/" ] + ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/index.php" +elif [ "$old_path" != "/" ] && [ "$new_path" != "/" ] then - ynh_replace_string "$old_domain$old_path" "$new_domain$new_path" "$final_path/index.php" -elif [ $old_path != "/" ] && [ $new_path = "/" ] + ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain$new_path" --target_file="$final_path/index.php" +elif [ "$old_path" != "/" ] && [ "$new_path" = "/" ] then - ynh_replace_string "$old_domain$old_path" "$new_domain" "$final_path/index.php" -elif [ $old_path = "/" ] && [ $new_path != "/" ] + ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain" --target_file="$final_path/index.php" +elif [ "$old_path" = "/" ] && [ "$new_path" != "/" ] then - ynh_replace_string "$old_domain" "$new_domain$new_path" "$final_path/index.php" + ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain$new_path" --target_file="$final_path/index.php" else - ynh_die "Error changing the URL" + ynh_die --message="Error changing the URL" fi #================================================= @@ -116,12 +107,12 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index c843404..9f01527 100644 --- a/scripts/install +++ b/scripts/install @@ -19,7 +19,6 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_print_info "Retrieve arguments from the manifest ..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -33,53 +32,50 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=2 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) +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_print_info "Storing installation settings..." +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 is_public $is_public -ynh_app_setting_set $app lang $lang -ynh_app_setting_set $app password $password #9999 Check if it's need to save password -ynh_app_setting_set $app ldap $ldap +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=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=lang --value=$lang +ynh_app_setting_set --app=$app --key=password --value=$password +ynh_app_setting_set --app=$app --key=ldap --value=$ldap #================================================= # STANDARD MODIFICATIONS #================================================= # CREATE A MYSQL DATABASE #================================================= -ynh_print_info "Creating a MySQL database..." +ynh_script_progression --message="Creating a MySQL database..." --weight=2 -db_name=$(ynh_sanitize_dbid $app) -ynh_app_setting_set $app db_name $db_name -ynh_mysql_setup_db $db_name $db_name +db_name=$(ynh_sanitize_dbid --db_name=$app) +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=3 -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path/app" +ynh_setup_source --dest_dir="$final_path/app" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx web server..." +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config @@ -87,15 +83,15 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Configuring system user..." +ynh_script_progression --message="Configuring system user..." --weight=2 # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Configuring php-fpm..." +ynh_script_progression --message="Configuring php-fpm..." --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config @@ -105,7 +101,7 @@ ynh_add_fpm_config #================================================= # AUTOCONFIG #================================================= -ynh_print_info "Configuring rainloop..." +ynh_script_progression --message= "Configuring rainloop..." --weight=3 # Set lang => define from install manifest case "$lang" in @@ -118,7 +114,7 @@ case "$lang" in *) lang="en" esac -ynh_app_setting_set $app lang $lang +ynh_app_setting_set --app=$app --key=lang --value=$lang # Set plugins # This plugin is trying to automatically grab unknown domains if users want to add external email accounts @@ -128,18 +124,18 @@ then # This plugin is to suggest YunoHost users in recipients list plugins="$plugins,ynh-ldap-suggestions" fi -ynh_app_setting_set $app plugins "$plugins" +ynh_app_setting_set --app=$app --key=plugins --value="$plugins" mkdir -p "$final_path/app/data/_data_/_default_/configs/" application_file="$final_path/app/data/_data_/_default_/configs/application.ini" cp ../conf/data/configs/application.ini "$application_file" -ynh_replace_string "__DOMAIN__" $domain "$application_file" -ynh_replace_string "__MYSQLUSER__" $db_name "$application_file" -ynh_replace_string "__MYSQLPASSWORD__" "$db_pwd" "$application_file" -ynh_replace_string "__LANGTOCHANGE__" $lang "$application_file" -ynh_replace_string "__PLUGINSTOENABLE__" "$plugins" "$application_file" +ynh_replace_string --match_string="__DOMAIN__" --replace_string=$domain --target_file="$application_file" +ynh_replace_string --match_string="__MYSQLUSER__" --replace_string=$db_name --target_file="$application_file" +ynh_replace_string --match_string="__MYSQLPASSWORD__" --replace_string="$db_pwd" --target_file="$application_file" +ynh_replace_string --match_string="__LANGTOCHANGE__" --replace_string=$lang --target_file="$application_file" +ynh_replace_string --match_string="__PLUGINSTOENABLE__" --replace_string="$plugins" --target_file="$application_file" # Set admin password @@ -148,8 +144,8 @@ php ../conf/config.php --index="$final_path/app/index.php" --password="$password # Add default domain configs by looping through all the domains already added mkdir -p "$final_path/app/data/_data_/_default_/domains/" # get list of ldap domains -alldomains=`ldapsearch -LLL -x -b ou=domains,dc=yunohost,dc=org -s one "objectclass=top" virtualdomain | grep -v "dn:" | sed "s/virtualdomain://" ` -for ldomain in $alldomains ; do +alldomains=$(ldapsearch -LLL -x -b ou=domains,dc=yunohost,dc=org -s one "objectclass=top" virtualdomain | grep -v "dn:" | sed "s/virtualdomain://") +for ldomain in $alldomains; do cp ../conf/data/domains/domain.tld.ini "$final_path/app/data/_data_/_default_/domains/$ldomain.ini" done # Add wildcard domain for auto-grab @@ -158,12 +154,12 @@ cp ../conf/data/domains/default.ini "$final_path/app/data/_data_/_default_/domai # install SSO - at the moment the index is the SSO and rainloop is installed in /app cp ../sources/sso/sso.php "$final_path/index.php" -ynh_replace_string "__DOMAIN__" "$domain" "$final_path/index.php" -ynh_replace_string "__ALIASTOCHANGE__" "$final_path" "$final_path/index.php" -if [ $path_url = "/" ]; then - ynh_replace_string "__ROOTTOCHANGE__" "" "$final_path/index.php" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/index.php" +ynh_replace_string --match_string="__ALIASTOCHANGE__" --replace_string="$final_path" --target_file="$final_path/index.php" +if [ "$path_url" = "/" ]; then + ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="" --target_file="$final_path/index.php" else - ynh_replace_string "__ROOTTOCHANGE__" "$path_url" "$final_path/index.php" + ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="$path_url" --target_file="$final_path/index.php" fi # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server @@ -174,7 +170,7 @@ cp -rf ../sources/pgpback "$final_path/" #================================================= # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$application_file" +ynh_store_file_checksum --file="$application_file" #================================================= # GENERIC FINALIZATION @@ -190,24 +186,24 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index f630a9d..966deae 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,36 +12,36 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= # REMOVE THE MYSQL DATABASE #================================================= -ynh_print_info "Removing the MySQL database" +ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db $db_name $db_name +ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -49,7 +49,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Removing php-fpm configuration" +ynh_script_progression --message="Removing php-fpm configuration..." --weight=2 # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -59,7 +59,7 @@ ynh_remove_fpm_config #================================================= # REMOVE GPG KEY #================================================= -ynh_print_info "Removing GPG key" +ynh_script_progression --message="Removing GPG key" gpg --batch --delete-key --yes Rainloop @@ -68,13 +68,13 @@ gpg --batch --delete-key --yes Rainloop #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user" +ynh_script_progression --message="Removing the dedicated system user..." --weight=2 # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 921fc65..b8b9f18 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,24 +19,24 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_script_progression --message="Loading settings..." --time --weight=2 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -44,31 +44,31 @@ test ! -d $final_path \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_print_info "Restoring the MySQL database..." +ynh_script_progression --message="Restoring the MySQL database..." --time --weight=2 -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_mysql_setup_db $db_name $db_name $db_pwd -ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=2 # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS @@ -81,20 +81,21 @@ chown -R $app: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" + #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_print_info "Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 -systemctl reload php7.0-fpm -systemctl reload nginx +ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" --time --last diff --git a/scripts/upgrade b/scripts/upgrade index 0502049..b01e320 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,47 +12,53 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) -final_path=$(ynh_app_setting_get $app final_path) -lang=$(ynh_app_setting_get $app lang) -db_name=$(ynh_app_setting_get $app db_name) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +lang=$(ynh_app_setting_get --app=$app --key=lang) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_script_progression --message="Ensuring downward compatibility..." # Fix is_public as a boolean value if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 + ynh_app_setting_set --app=$app --key=is_public --value=1 is_public=1 elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 + ynh_app_setting_set --app=$app --key=is_public --value=0 is_public=0 fi # If db_name doesn't exist, create it -if [ -z $db_name ]; then - db_name=$(ynh_sanitize_dbid $app) - ynh_app_setting_set $app db_name $db_name +if [ -z "$db_name" ]; then + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi # If final_path doesn't exist, create it -if [ -z $final_path ]; then +if [ -z "$final_path" ]; then final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=4 # Backup the current version of the app ynh_backup_before_upgrade @@ -68,22 +74,26 @@ ynh_abort_if_errors #================================================= # Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STANDARD UPGRADE STEPS #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path/app" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." --weight=8 + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path/app" +fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 # Create a dedicated nginx config ynh_add_nginx_config @@ -91,15 +101,15 @@ ynh_add_nginx_config #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_print_info "Upgrading php-fpm configuration..." +ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config @@ -109,16 +119,16 @@ ynh_add_fpm_config #================================================= # UPDATE SSO AND PGP #================================================= -ynh_print_info "Upgrading rainloop configuration..." +ynh_script_progression --message="Upgrading rainloop configuration..." # update SSO cp ../sources/sso/sso.php "$final_path/index.php" -ynh_replace_string "__DOMAIN__" "$domain" "$final_path/index.php" -ynh_replace_string "__ALIASTOCHANGE__" "$final_path" "$final_path/index.php" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/index.php" +ynh_replace_string --match_string="__ALIASTOCHANGE__" --replace_string="$final_path" --target_file="$final_path/index.php" if [ $path_url = "/" ]; then - ynh_replace_string "__ROOTTOCHANGE__" "" "$final_path/index.php" + ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="" --target_file="$final_path/index.php" else - ynh_replace_string "__ROOTTOCHANGE__" "$path_url" "$final_path/index.php" + ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="$path_url" --target_file="$final_path/index.php" fi # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server @@ -138,24 +148,24 @@ find $final_path/. -type f -exec chmod 644 {} \; #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set $app unprotected_uris "/" + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" --last From dcfc516a1a828ac06896106b8fdaceff304e5652 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 18 May 2019 16:48:43 +0200 Subject: [PATCH 49/53] Use fail2ban --- conf/data/configs/application.ini | 8 ++++---- scripts/backup | 17 +++++++++++++++++ scripts/install | 20 ++++++++++++++++++++ scripts/remove | 16 ++++++++++++++++ scripts/restore | 14 ++++++++++++++ scripts/upgrade | 22 ++++++++++++++++++++++ 6 files changed, 93 insertions(+), 4 deletions(-) diff --git a/conf/data/configs/application.ini b/conf/data/configs/application.ini index 71a4cc5..88b62ca 100644 --- a/conf/data/configs/application.ini +++ b/conf/data/configs/application.ini @@ -169,7 +169,7 @@ write_on_timeout_only = 0 ; Required for development purposes only. ; Disabling this option is not recommended. hide_passwords = On -time_offset = 0 +time_offset = __TIME_ZONE__ session_filter = "" ; Log filename. @@ -201,9 +201,9 @@ session_filter = "" filename = "log-{date:Y-m-d}.txt" ; Enable auth logging in a separate file (for fail2ban) -auth_logging = Off -auth_logging_filename = "fail2ban/auth-{date:Y-m-d}.txt" -auth_logging_format = "[{date:Y-m-d H:i:s}] Auth failed: ip={request:ip} user={imap:login} host={imap:host} port={imap:port}" +auth_logging = On +auth_logging_filename = "fail2ban/auth-fail.log" +auth_logging_format = "[{date:Y-m-d H:i:s T}] Auth failed: ip={request:ip} user={imap:login} host={imap:host} port={imap:port}" [debug] ; Special option required for development purposes diff --git a/scripts/backup b/scripts/backup index a1d85d7..dee9312 100644 --- a/scripts/backup +++ b/scripts/backup @@ -57,6 +57,23 @@ ynh_script_progression --message="Backing up the MySQL database..." ynh_mysql_dump_db --database="$db_name" > db.sql +#================================================= +# BACKUP FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Backing up fail2ban configuration..." + +ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= +ynh_script_progression --message="Backing up logrotate configuration..." + +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 9f01527..d87194d 100644 --- a/scripts/install +++ b/scripts/install @@ -136,6 +136,7 @@ ynh_replace_string --match_string="__MYSQLUSER__" --replace_string=$db_name --ta ynh_replace_string --match_string="__MYSQLPASSWORD__" --replace_string="$db_pwd" --target_file="$application_file" ynh_replace_string --match_string="__LANGTOCHANGE__" --replace_string=$lang --target_file="$application_file" ynh_replace_string --match_string="__PLUGINSTOENABLE__" --replace_string="$plugins" --target_file="$application_file" +ynh_replace_string --match_string="__TIME_ZONE__" --replace_string="$(date +%:::z)" --target_file="$application_file" # Set admin password @@ -183,6 +184,25 @@ find $final_path/. -type d -exec chmod 755 {} \; find $final_path/. -type f -exec chmod 644 {} \; chown -R $app: $final_path +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." + +mkdir -p $final_path/app/data/_data_/_default_/logs/fail2ban +touch $final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate --logfile=$final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log + +#================================================= +# SETUP FAIL2BAN +#================================================= +ynh_script_progression --message="Configuring fail2ban..." --weight=8 + +# Create a dedicated fail2ban config +ynh_add_fail2ban_config --logpath="$final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log" --failregex="Auth failed: ip=.*$" + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index 966deae..c1e303f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -54,6 +54,22 @@ ynh_script_progression --message="Removing php-fpm configuration..." --weight=2 # Remove the dedicated php-fpm config ynh_remove_fpm_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate + +#================================================= +# REMOVE FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Removing fail2ban configuration..." --weight=8 + +# Remove the dedicated fail2ban config +ynh_remove_fail2ban_config + #================================================= # SPECIFIC REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index b8b9f18..8d80b4b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -83,6 +83,20 @@ chown -R $app: $final_path ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" +#================================================= +# RESTORE FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the fail2ban configuration..." --time --weight=6 + +ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" +ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" +ynh_systemd_action --action=restart --service_name=fail2ban + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index b01e320..47222e9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -121,6 +121,9 @@ ynh_add_fpm_config #================================================= ynh_script_progression --message="Upgrading rainloop configuration..." +# Upgrade time_offset value for fail2ban +ynh_replace_string --match_string="^time_offset = .*" --replace_string="time_offset = $(date +%:::z)" --target_file="$final_path/app/data/_data_/_default_/configs/application.ini" + # update SSO cp ../sources/sso/sso.php "$final_path/index.php" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/index.php" @@ -134,6 +137,17 @@ fi # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server cp -rf ../sources/pgpback "$final_path/" +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2 + +mkdir -p $final_path/app/data/_data_/_default_/logs/fail2ban +touch $final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --logfile=$final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log --non-append + #================================================= # GENERIC FINALIZATION #================================================= @@ -145,6 +159,14 @@ chown -R $app: $final_path find $final_path/. -type d -exec chmod 755 {} \; find $final_path/. -type f -exec chmod 644 {} \; +#================================================= +# UPGRADE FAIL2BAN +#================================================= +ynh_script_progression --message="Reconfiguring fail2ban..." --weight=9 + +# Create a dedicated fail2ban config +ynh_add_fail2ban_config --logpath="$final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log" --failregex="Auth failed: ip=.*$" + #================================================= # SETUP SSOWAT #================================================= From 17c58bc1de167eea5e8728f41f6de6edb566a0b4 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 18 May 2019 17:03:29 +0200 Subject: [PATCH 50/53] Fix log permission --- scripts/install | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/install b/scripts/install index d87194d..0bddbc2 100644 --- a/scripts/install +++ b/scripts/install @@ -175,15 +175,6 @@ ynh_store_file_checksum --file="$application_file" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -find $final_path/. -type d -exec chmod 755 {} \; -find $final_path/. -type f -exec chmod 644 {} \; -chown -R $app: $final_path - #================================================= # SETUP LOGROTATE #================================================= @@ -195,6 +186,15 @@ touch $final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log # Use logrotate to manage application logfile(s) ynh_use_logrotate --logfile=$final_path/app/data/_data_/_default_/logs/fail2ban/auth-fail.log +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions to app files +find $final_path/. -type d -exec chmod 755 {} \; +find $final_path/. -type f -exec chmod 644 {} \; +chown -R $app: $final_path + #================================================= # SETUP FAIL2BAN #================================================= From 405d49effd5a435be0fca3b7b7bc5de9baaaaead Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 30 May 2019 00:27:10 +0200 Subject: [PATCH 51/53] Replace properly path_url into the index for change_url --- scripts/change_url | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c092929..7c81b01 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -86,21 +86,7 @@ ynh_script_progression --message="Reconfiguring rainloop..." --weight=2 application_file="$final_path/app/data/_data_/_default_/configs/application.ini" ynh_replace_string --match_string="default_domain = .^" --replace_string="default_domain = \"$new_domain\"" --target_file="$application_file" -if [ "$old_path" = "/" ] && [ "$new_path" = "/" ] -then - ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain" --target_file="$final_path/index.php" -elif [ "$old_path" != "/" ] && [ "$new_path" != "/" ] -then - ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain$new_path" --target_file="$final_path/index.php" -elif [ "$old_path" != "/" ] && [ "$new_path" = "/" ] -then - ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain" --target_file="$final_path/index.php" -elif [ "$old_path" = "/" ] && [ "$new_path" != "/" ] -then - ynh_replace_string --match_string="$old_domain" --replace_string="$new_domain$new_path" --target_file="$final_path/index.php" -else - ynh_die --message="Error changing the URL" -fi +ynh_replace_string --match_string="$old_domain${old_path%/}" --replace_string="$new_domain${new_path%/}" --target_file="$final_path/index.php" #================================================= # GENERIC FINALISATION From 10def7c68e7808585a549e249e18d304f38bac4c Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 30 May 2019 00:29:15 +0200 Subject: [PATCH 52/53] use ${path_url%/} as well in upgrade script --- scripts/upgrade | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 47222e9..db1f6cf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -128,11 +128,7 @@ ynh_replace_string --match_string="^time_offset = .*" --replace_string="time_off cp ../sources/sso/sso.php "$final_path/index.php" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/index.php" ynh_replace_string --match_string="__ALIASTOCHANGE__" --replace_string="$final_path" --target_file="$final_path/index.php" -if [ $path_url = "/" ]; then - ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="" --target_file="$final_path/index.php" -else - ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="$path_url" --target_file="$final_path/index.php" -fi +ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="${path_url%/}" --target_file="$final_path/index.php" # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server cp -rf ../sources/pgpback "$final_path/" From 33f40f7f1f1fadf54a635d733e4dd46e162d24f0 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 30 May 2019 00:31:13 +0200 Subject: [PATCH 53/53] And in install script... --- scripts/install | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 0bddbc2..47c9ff7 100644 --- a/scripts/install +++ b/scripts/install @@ -157,11 +157,7 @@ cp ../conf/data/domains/default.ini "$final_path/app/data/_data_/_default_/domai cp ../sources/sso/sso.php "$final_path/index.php" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/index.php" ynh_replace_string --match_string="__ALIASTOCHANGE__" --replace_string="$final_path" --target_file="$final_path/index.php" -if [ "$path_url" = "/" ]; then - ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="" --target_file="$final_path/index.php" -else - ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="$path_url" --target_file="$final_path/index.php" -fi +ynh_replace_string --match_string="__ROOTTOCHANGE__" --replace_string="${path_url%/}" --target_file="$final_path/index.php" # Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server cp -rf ../sources/pgpback "$final_path/"