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