1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git synced 2024-09-03 18:36:09 +02:00

Merge pull request #26 from YunoHost-Apps/testing

Upgrade package
This commit is contained in:
Maniack Crudelis 2017-12-22 19:35:36 +01:00 committed by GitHub
commit 821482f6e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 616 additions and 184 deletions

View file

@ -3,6 +3,8 @@
[![Integration level](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20%28Community%29/lastBuild/consoleFull)
[![Install Etherpad with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=etherpad_mypads)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allow you to install etherpad 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.*
@ -18,8 +20,8 @@ This package will install the same plugins than [Framapad](https://framapad.org/
## Configuration
You can access to 2 different admin panels, for etherpad by accessing `domain.tld/admin` and for mypads by `domain.tld/mypads/?/admin`
Or, you can find a config file for etherpad at this path `/var/www/etherpad_mypads/settings.json`
You can access to 2 different admin panels, for etherpad by accessing `domain.tld/admin` and for mypads by `domain.tld/mypads/?/admin`.
Or, you can find a config file for etherpad at this path `/var/www/etherpad_mypads/settings.json`.
## Documentation

88
README_fr.md Normal file
View file

@ -0,0 +1,88 @@
# Etherpad avec plugin mypads pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20%28Community%29/lastBuild/consoleFull)
[![Installer Etherpad avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=etherpad_mypads)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer etherpad rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/install_fr) pour savoir comment l'installer et en profiter.*
## Résumé
Etherpad est un éditeur en ligne Open Source hautement personnalisable qui permet l'édition collaborative en temps réel.
Ce paquet installera les mêmes plugins que [Framapad](https://framapad.org/).
**Version embarquée:** 1.6.2
## Captures d'écran
![](http://etherpad.org/img/screenshot.png)
## Configuration
Vous pouvez accéder à 2 panneaux d'administration différents, pour etherpad en accédant à `domain.tld/admin` et pour mypads par `domain.tld/mypads/?/admin`.
Ou, vous pouvez trouver un fichier de configuration pour etherpad à `/var/www/etherpad_mypads/settings.json`.
## Documentation
* Documentation officielle: http://etherpad.org/doc/v1.6.2
* Documentation YunoHost: Il n'y a pas d'autre documentation, n'hésitez pas à contribuer.
## Fonctionnalités spécifiques à YunoHost
#### Support multi-utilisateurs
Supportée, **sans LDAP ni SSO**.
#### Architectures supportées.
* Testé sur x86_64
## Limitations
* Si vous demandez d'installer le plugin mypads, vous devez installer à la racine d'un domaine ou d'un sous-domaine dédié. Sinon, mypads sera inaccessible.
## Informations additionnelles
* Ce paquet installera les plugins suivants:
* ep_align - *Ajoute Gauche/Centre/Droite/Justifier à des lignes de texte dans un pad*
* ep_author_hover - *Ajoute des noms d'auteurs*
* ep_automatic_logut - *Déconnecte automatiquement l'utilisateur après une certaine période de temps (Prévient la surcharge du serveur)*
* ep_comments_page - *Ajoute des commentaires sur la sidebar et le lie au texte.*
* ep_countable - *Affiche les paragraphes, phrases, mots et nombres de caractères.*
* ep_delete_empty_pads - *Supprimer les pads qui n'ont jamais été édités*
* ep_font_color - *Appliquer les couleurs aux polices de caractères*
* ep_headings2 - *Ajoute le support de titre à Etherpad Lite.*
* ep_markdown - *Modifier et exporter en tant que Markdown dans Etherpad*
* ep_mypads - *Groupes et pads privés pour etherpad*
* ep_page_view - *Ajouter la prise en charge de 'page view', avec une option d'activation/désactivation dans Paramètres, ainsi que 'Page Breaks' avec Control + Entrée*
* ep_spellcheck - *Ajouter le support pour faire de la vérification orthographique*
* ep_subscript_and_superscript - *Ajouter la prise en charge de Subscript et Superscript*.
* ep_table_of_contents - *Voir une table des matières pour votre pad*
* ep_user_font_size - *Permet de définir taille de la police dans les paramètres, cela n'affecte pas les vues des autres personnes*.
* Parce qu'il n'y a pas de support ldap avec le plugin mypads, aucun utilisateur n'est créé lors de l'installation.
Vous devez vous connecter au panneau d'administration pour créer les premiers utilisateurs.
Login et mot de passe sont ceux que vous avez choisis lors de l'installation.
## Liens
* Reporter un bug: https://github.com/YunoHost-Apps/etherpad_mypads_ynh/issues
* Site de etherpad: http://etherpad.org/
* Site du plugin mypads: https://git.framasoft.org/framasoft/ep_mypads
* Site de YunoHost: https://yunohost.org/
---
Informations à l'intention des développeurs
----------------
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing).
Pour tester la branche testing, merci de procéder ainsi.
```
sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose
ou
sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose
```

View file

@ -6,7 +6,7 @@
"en": "Framapad clone, a online editor providing collaborative editing in real-time.",
"fr": "Clone de Framapad, un éditeur en ligne fournissant l'édition collaborative en temps réel."
},
"version": "1.6.2",
"version": "1.6.2~ynh1",
"url": "https://framapad.org",
"license": "Apache-2.0",
"maintainer": {
@ -27,8 +27,8 @@
"name": "domain",
"type": "domain",
"ask": {
"en": "Choose a dedicated domain for Etherpad Mypads.",
"fr": "Choisissez un domaine dédié pour Etherpad Mypads."
"en": "Choose a domain for Etherpad Mypads.",
"fr": "Choisissez un domaine pour Etherpad Mypads."
},
"example": "sub.domain.org"
},

View file

@ -1,31 +1,5 @@
#!/bin/bash
#=================================================
# DISPLAYING
#=================================================
NO_PRINT () { # Supprime l'affichage dans stdout pour la commande en argument.
set +x
$@
set -x
}
WARNING () { # Écrit sur le canal d'erreur pour passer en warning.
$@ >&2
}
SUPPRESS_WARNING () { # Force l'écriture sur la sortie standard
$@ 2>&1
}
QUIET () { # Redirige la sortie standard dans /dev/null
$@ > /dev/null
}
ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
$@ > /dev/null 2>&1
}
#=================================================
# BACKUP
#=================================================
@ -42,8 +16,8 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
if [ $free_space -le $backup_size ]
then
WARNING echo "Espace insuffisant pour sauvegarder $file_to_analyse."
WARNING echo "Espace disponible: $(HUMAN_SIZE $free_space)"
ynh_print_err "Espace insuffisant pour sauvegarder $file_to_analyse."
ynh_print_err "Espace disponible: $(HUMAN_SIZE $free_space)"
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
fi
}
@ -57,7 +31,7 @@ IS_PACKAGE_CHECK () { # Détermine une exécution en conteneur (Non testé)
}
#=================================================
# NODEJS
# EXPERIMENTAL HELPERS
#=================================================
# INFOS
@ -234,6 +208,361 @@ EOF
chmod +x "/etc/cron.daily/node_update"
}
#=================================================
# Start or restart a service and follow its booting
#
# usage: ynh_check_starting "Line to match" [Log file] [Timeout]
#
# | arg: Line to match - The line to find in the log to attest the service have finished to boot.
# | arg: Log file - The log file to watch
# /var/log/$app/$app.log will be used if no other log is defined.
# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds.
ynh_check_starting () {
local line_to_match="$1"
local app_log="${2:-/var/log/$app/$app.log}"
local timeout=${3:-300}
ynh_clean_check_starting () {
# Stop the execution of tail.
kill -s 15 $pid_tail 2>&1
ynh_secure_remove "$templog" 2>&1
}
echo "Starting of $app" >&2
systemctl restart $app
local templog="$(mktemp)"
# Following the starting of the app in its log
tail -f -n1 "$app_log" > "$templog" &
# Get the PID of the tail command
local pid_tail=$!
local i=0
for i in `seq 1 $timeout`
do
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
if grep --quiet "$line_to_match" "$templog"
then
echo "The service $app has correctly started." >&2
break
fi
echo -n "." >&2
sleep 1
done
if [ $i -eq $timeout ]
then
echo "The service $app didn't fully started before the timeout." >&2
fi
echo ""
ynh_clean_check_starting
}
#=================================================
ynh_print_log () {
echo "${1}"
}
# Print an info on stdout
#
# usage: ynh_print_info "Text to print"
# | arg: text - The text to print
ynh_print_info () {
ynh_print_log "[INFO] ${1}"
}
# Print a warning on stderr
#
# usage: ynh_print_warn "Text to print"
# | arg: text - The text to print
ynh_print_warn () {
ynh_print_log "[WARN] ${1}" >&2
}
# Print a error on stderr
#
# usage: ynh_print_err "Text to print"
# | arg: text - The text to print
ynh_print_err () {
ynh_print_log "[ERR] ${1}" >&2
}
# Execute a command and print the result as an error
#
# usage: ynh_exec_err command to execute
# usage: ynh_exec_err "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_err () {
ynh_print_err "$(eval $@)"
}
# Execute a command and print the result as a warning
#
# usage: ynh_exec_warn command to execute
# usage: ynh_exec_warn "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_warn () {
ynh_print_warn "$(eval $@)"
}
# Execute a command and force the result to be printed on stdout
#
# usage: ynh_exec_warn_less command to execute
# usage: ynh_exec_warn_less "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_warn_less () {
eval $@ 2>&1
}
# Execute a command and redirect stdout in /dev/null
#
# usage: ynh_exec_quiet command to execute
# usage: ynh_exec_quiet "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_quiet () {
eval $@ > /dev/null
}
# Execute a command and redirect stdout and stderr in /dev/null
#
# usage: ynh_exec_fully_quiet command to execute
# usage: ynh_exec_fully_quiet "command to execute | following command"
# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe.
#
# | arg: command - command to execute
ynh_exec_fully_quiet () {
eval $@ > /dev/null 2>&1
}
# Remove any logs for all the following commands.
#
# usage: ynh_print_OFF
# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging.
ynh_print_OFF () {
set +x
}
# Restore the logging after ynh_print_OFF
#
# usage: ynh_print_ON
ynh_print_ON () {
set -x
# Print an echo only for the log, to be able to know that ynh_print_ON has been called.
echo ynh_print_ON > /dev/null
}
#=================================================
# Install or update the main directory yunohost.multimedia
#
# usage: ynh_multimedia_build_main_dir
ynh_multimedia_build_main_dir () {
wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip 2>&1
unzip -q master.zip
./yunohost.multimedia-master/script/ynh_media_build.sh
}
# Add a directory in yunohost.multimedia
# This "directory" will be a symbolic link to a existing directory.
#
# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
#
# | arg: Source directory - The real directory which contains your medias.
# | arg: Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
ynh_multimedia_addfolder () {
local source_dir="$1"
local dest_dir="$2"
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
}
# Move a directory in yunohost.multimedia, and replace by a symbolic link
#
# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
#
# | arg: Source directory - The real directory which contains your medias.
# It will be moved to "Destination directory"
# A symbolic link will replace it.
# | arg: Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
ynh_multimedia_movefolder () {
local source_dir="$1"
local dest_dir="$2"
./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir"
}
# Allow an user to have an write authorisation in multimedia directories
#
# usage: ynh_multimedia_addaccess user_name
#
# | arg: user_name - The name of the user which gain this access.
ynh_multimedia_addaccess () {
local user_name=$1
groupadd -f multimedia
usermod -a -G multimedia $user_name
}
#=================================================
# Create a dedicated fail2ban config (jail and filter conf files)
#
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
# | arg: log_file - Log file to be checked by fail2ban
# | arg: failregex - Failregex to be looked for by fail2ban
# | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3
# | arg: ports - Ports blocked for a banned IP address - default: http,https
ynh_add_fail2ban_config () {
# Process parameters
logpath=$1
failregex=$2
max_retry=${3:-3}
ports=${4:-http,https}
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
sudo tee $finalfail2banjailconf <<EOF
[$app]
enabled = true
port = $ports
filter = $app
logpath = $logpath
maxretry = $max_retry"
EOF
sudo tee $finalfail2banfilterconf <<EOF
[INCLUDES]
before = common.conf
[Definition]
failregex = $failregex
ignoreregrex ="
EOF
ynh_store_file_checksum "$finalfail2banjailconf"
ynh_store_file_checksum "$finalfail2banfilterconf"
sudo systemctl restart fail2ban
}
# Remove the dedicated fail2ban config (jail and filter conf files)
#
# usage: ynh_remove_fail2ban_config
ynh_remove_fail2ban_config () {
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
sudo systemctl restart fail2ban
}
#=================================================
# Read the value of a key in a ynh manifest file
#
# usage: ynh_read_manifest manifest key
# | arg: manifest - Path of the manifest to read
# | arg: key - Name of the key to find
ynh_read_manifest () {
manifest="$1"
key="$2"
python3 -c "import sys, json;print(json.load(open('$manifest'))['$key'])"
}
# Exit without error if the package is up to date
#
# This helper should be used to avoid an upgrade of a package
# when it's not needed.
#
# To force an upgrade, even if the package is up to date,
# you have to set the variable YNH_FORCE_UPGRADE before.
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
#
# usage: ynh_abort_if_up_to_date
ynh_abort_if_up_to_date () {
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
local package_check=${PACKAGE_CHECK_EXEC:-0}
local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
if [ "$version" = "$last_version" ]
then
if [ "$force_upgrade" != "0" ]
then
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
unset YNH_FORCE_UPGRADE
elif [ "$package_check" != "0" ]
then
echo "Upgrade forced for package check." >&2
else
ynh_die "Up-to-date, nothing to do" 0
fi
fi
}
#=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
# example: "root admin@domain"
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
# example: "root admin@domain user1 user2"
ynh_send_readme_to_admin() {
local app_message="${1:-...No specific informations...}"
local recipients="${2:-root}"
# Retrieve the email of users
find_mails () {
local list_mails="$1"
local mail
local recipients=" "
# Read each mail in argument
for mail in $list_mails
do
# Keep root or a real email address as it is
if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
then
recipients="$recipients $mail"
else
# But replace an user name without a domain after by its email
if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
then
recipients="$recipients $mail"
fi
fi
done
echo "$recipients"
}
recipients=$(find_mails "$recipients")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific informations for the application $app.
$app_message
---
Automatic diagnosis data from YunoHost
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
# Send the email to the recipients
echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
}
#=================================================
#============= FUTURE YUNOHOST HELPER ============

51
scripts/_sed Normal file
View file

@ -0,0 +1,51 @@
#!/bin/bash
# https://github.com/YunoHost/yunohost/pull/394
# Substitute/replace a string (or expression) by another in a file
#
# usage: ynh_replace_string match_string replace_string target_file
# | arg: match_string - String to be searched and replaced in the file
# | arg: replace_string - String that will replace matches
# | arg: target_file - File in which the string will be replaced.
#
# As this helper is based on sed command, regular expressions and
# references to sub-expressions can be used
# (see sed manual page for more information)
ynh_replace_string () {
local delimit=@
local match_string=$1
local replace_string=$2
local workfile=$3
# Escape the delimiter if it's in the string.
match_string=${match_string//${delimit}/"\\${delimit}"}
replace_string=${replace_string//${delimit}/"\\${delimit}"}
sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile"
}
# Substitute/replace a password by another in a file
#
# usage: ynh_replace_password_string match_string replace_string target_file
# | arg: match_string - String to be searched and replaced in the file
# | arg: replace_string - String that will replace matches
# | arg: target_file - File in which the string will be replaced.
#
# This helper will use ynh_replace_string, but as you can use special
# characters, you can't use some regular expressions and sub-expressions.
ynh_replace_password_string () {
local match_string=$1
local replace_string=$2
local workfile=$3
# Escape any backslash to preserve them as simple backslash.
match_string=${match_string//\\/"\\\\"}
replace_string=${replace_string//\\/"\\\\"}
# Escape the & character, who has a special function in sed.
match_string=${match_string//&/"\&"}
replace_string=${replace_string//&/"\&"}
ynh_replace_string "$match_string" "$replace_string" "$workfile"
}

View file

@ -8,6 +8,7 @@
source _common.sh
source /usr/share/yunohost/helpers
source _sed
#=================================================
# RETRIEVE ARGUMENTS
@ -58,27 +59,15 @@ then
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# MANAGE FAILURE OF THE SCRIPT
#=================================================
if [ $change_domain -eq 0 ]
then
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# Nettoyage des résidus d'installation non pris en charge par le script remove.
if test -n "$PID_TAIL"
then
SUPPRESS_WARNING kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
ynh_secure_remove "$tempfile"
fi
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
fi
ynh_clean_setup () {
# Nettoyage des résidus d'installation non pris en charge par le script remove.
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD MODIFICATIONS
@ -138,30 +127,9 @@ fi
systemctl reload nginx
#=================================================
# START ETHERPAD IN BACKGROUND
#=================================================
# Démarre etherpad
WARNING echo "Redémarrage d'etherpad"
tempfile="$(mktemp)"
tail -f -n1 /var/log/$app/etherpad.log > "$tempfile" & # Suit le démarrage dans le log
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
systemctl start $app # Redémarre etherpad. Le démarrage est fait le plus tôt possible, car il est très long...
#=================================================
# CHECK ETHERPAD STARTING
#=================================================
for i in `seq 1 120`
do # La boucle attend le démarrage d'etherpad. Ou 2 minutes. Cette boucle évite simplement un 502 au début, car le démarrage est long...
if grep -q "You can access your Etherpad instance at" "$tempfile"; then
WARNING echo "Le service $app a démarré correctement."
break # Si le log annonce le démarrage d'etherpad, sort de la boucle.
fi
WARNING echo -n "."
sleep 1
done
echo ""
QUIET kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
ynh_secure_remove "$tempfile"
# Wait for etherpad fully started
ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120"

View file

@ -10,6 +10,7 @@ source _common.sh
source /usr/share/yunohost/helpers
# Load common variables for all scripts.
source _variables
source _sed
#=================================================
# MANAGE FAILURE OF THE SCRIPT
@ -17,12 +18,7 @@ source _variables
ynh_clean_setup () {
# Nettoyage des résidus d'installation non pris en charge par le script remove.
if test -n "$PID_TAIL"
then
SUPPRESS_WARNING kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
ynh_secure_remove "$tempfile"
fi
echo ""
ynh_clean_check_starting
}
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
@ -33,7 +29,7 @@ ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est dét
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD
ynh_print_OFF; password=$YNH_APP_ARG_PASSWORD; ynh_print_ON
language=$YNH_APP_ARG_LANGUAGE
is_public=$YNH_APP_ARG_IS_PUBLIC
export=$YNH_APP_ARG_EXPORT
@ -45,10 +41,12 @@ app=$YNH_APP_INSTANCE_NAME
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
#=================================================
ynh_print_OFF
if [ "${#password}" -lt 8 ] || [ "${#password}" -gt 30 ]
then
ynh_die "The password must be between 8 and 30 characters."
fi
ynh_print_ON
if [ "$path_url" != "/" ] && [ $mypads -eq 1 ]
then
@ -74,7 +72,7 @@ ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app admin $admin
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app password $password
ynh_print_OFF; ynh_app_setting_set $app password $password; ynh_print_ON
ynh_app_setting_set $app language $language
ynh_app_setting_set $app export $export
ynh_app_setting_set $app mypads $mypads
@ -171,7 +169,7 @@ ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
ynh_replace_string "__DB_USER__" "$db_name" "$final_path/credentials.json"
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json"
ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json"
ynh_replace_string "__PASSWD__" "$password" "$final_path/credentials.json"
ynh_print_OFF; ynh_replace_password_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON
if [ "$export" = "abiword" ]
then
abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword
@ -251,16 +249,6 @@ then
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad.
fi
#=================================================
# START ETHERPAD IN BACKGROUND
#=================================================
WARNING echo "Démarrage d'etherpad"
tempfile="$(mktemp)"
tail -f -n1 /var/log/$app/etherpad.log > "$tempfile" & # Suit le démarrage dans le log
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
systemctl start $app # Démarre etherpad. Le démarrage est fait le plus tôt possible, car il est très long...
#=================================================
# SETUP SSOWAT
#=================================================
@ -281,34 +269,45 @@ systemctl reload nginx
# CHECK ETHERPAD STARTING
#=================================================
# Wait for etherpad fully started
ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120"
if [ $mypads -eq 1 ]
then
lang_OK=0
else
lang_OK=1
ynh_replace_string "__LANGUAGE__" "$language" "$script_dir/../conf/lang_mypads.sql"
mysql -u $db_name -p$db_pwd $db_name < "$script_dir/../conf/lang_mypads.sql"
# Wait for etherpad fully started
ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120"
fi
for i in `seq 1 120`
do # La boucle attend le démarrage d'etherpad. Ou 2 minutes. Cette boucle évite simplement un 502 au début, car le démarrage est long...
if [ $mypads -eq 1 ]
then
if grep -q "You can access your Etherpad instance at" "$tempfile" && [ "$lang_OK" -eq 0 ] ; then
# Si le log annonce une première fois le démarrage d'etherpad, applique la langue de mypads et redémarre le service.
WARNING echo "Le service $app a démarré correctement."
ynh_replace_string "__LANGUAGE__" "$language" "$script_dir/../conf/lang_mypads.sql"
mysql -u $db_name -p$db_pwd $db_name < "$script_dir/../conf/lang_mypads.sql"
echo ""
systemctl restart $app
cat /dev/null > "$tempfile" # Purge le log de suivi du démarrage.
lang_OK=1
i=1;
fi
fi
if grep -q "You can access your Etherpad instance at" "$tempfile" && [ "$lang_OK" -eq 1 ]; then
WARNING echo "Le service $app a démarré correctement."
break # Si le log annonce une deuxième fois le démarrage d'etherpad, sort de la boucle.
fi
WARNING echo -n "."
sleep 1
done
SUPPRESS_WARNING kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
ynh_secure_remove "$tempfile"
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
if [ $mypads -eq 1 ]
then
Informations1="You can access to 2 different admin panels, for etherpad by accessing https://$domain${path_url%/}/admin and for mypads by https://$domain${path_url%/}/mypads/?/admin."
Informations2="
Because there's no ldap support with mypads plugin, no user is created at the installation.
You have to connect to the admin panel to create the first users.
"
else
Informations1="You can access to the admin panel, by accessing https://$domain${path_url%/}/admin."
Informations2=""
fi
ynh_print_OFF
message="$Informations1
Or, you can find a config file for etherpad at this path /var/www/etherpad_mypads/settings.json.
Your credentials for the admin panel are:
- login : $admin
- password : $password
$Informations2
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh"
ynh_send_readme_to_admin "$message" "$admin"
ynh_print_ON

View file

@ -34,7 +34,7 @@ ynh_remove_systemd_config
if yunohost service status | grep -q $app # Test l'existence du service dans Yunohost
then
echo "Remove $app service"
ynh_print_info "Remove $app service" >&2
yunohost service remove $app
fi

View file

@ -20,6 +20,10 @@ source ../settings/scripts/_variables
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
# Nettoyage des résidus d'installation non pris en charge par le script remove.
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -30,16 +34,19 @@ ynh_abort_if_errors
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path_url)
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)
export=$(ynh_app_setting_get $app export)
mypads=$(ynh_app_setting_get $app mypads)
admin=$(ynh_app_setting_get $app admin)
ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
yunohost app checkurl "${domain}${path_url}" -a "$app" \
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 "
@ -126,16 +133,6 @@ ynh_restore_file "/etc/systemd/system/$app.service"
## Démarrage auto du service
systemctl enable $app.service
#=================================================
# START ETHERPAD IN BACKGROUND
#=================================================
echo "Démarrage d'etherpad" >&2
tempfile="$(mktemp)"
tail -f -n1 /var/log/$app/etherpad.log > "$tempfile" & # Suit le démarrage dans le log
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
systemctl start $app # Démarre etherpad. Le démarrage est fait le plus tôt possible, car il est très long...
#=================================================
# RELOAD NGINX
#=================================================
@ -146,16 +143,36 @@ systemctl reload nginx
# CHECK ETHERPAD STARTING
#=================================================
# Surveille le démarrage du service.
for i in `seq 1 60`
do # La boucle attend le démarrage d'etherpad. Ou 1 minute. Cette boucle évite simplement un 502 au début, car le démarrage est long...
if grep -q "You can access your Etherpad instance at" "$tempfile"; then
echo "Le service $app a démarré correctement." >&2
break # Si le log annonce le démarrage d'etherpad, sort de la boucle.
fi
echo -n "." >&2
sleep 1
done
echo ""
kill -s 15 $PID_TAIL > /dev/null # Arrête l'exécution de tail.
ynh_secure_remove "$tempfile"
# Wait for etherpad fully started
ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120"
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
if [ $mypads -eq 1 ]
then
Informations1="You can access to 2 different admin panels, for etherpad by accessing https://$domain${path_url%/}/admin and for mypads by https://$domain${path_url%/}/mypads/?/admin."
Informations2="
Because there's no ldap support with mypads plugin, no user is created at the installation.
You have to connect to the admin panel to create the first users.
"
else
Informations1="You can access to the admin panel, by accessing https://$domain${path_url%/}/admin."
Informations2=""
fi
ynh_print_OFF
message="$Informations1
Or, you can find a config file for etherpad at this path /var/www/etherpad_mypads/settings.json.
Your credentials for the admin panel are:
- login : $admin
- password : $password
$Informations2
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh"
ynh_send_readme_to_admin "$message" "$admin"
ynh_print_ON

View file

@ -10,6 +10,7 @@ source _common.sh
source /usr/share/yunohost/helpers
# Load common variables for all scripts.
source _variables
source _sed
#=================================================
# LOAD SETTINGS
@ -28,6 +29,12 @@ export=$(ynh_app_setting_get $app export)
db_name=$(ynh_app_setting_get $app db_name)
mypads=$(ynh_app_setting_get $app mypads)
#=================================================
# CHECK VERSION
#=================================================
ynh_abort_if_up_to_date
#=================================================
# FIX OLD THINGS
#=================================================
@ -81,11 +88,7 @@ fi
ynh_backup_before_upgrade
ynh_clean_setup () {
# Nettoyage des résidus d'installation non pris en charge par le script remove.
if test -n "$PID_TAIL"
then
SUPPRESS_WARNING kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
ynh_secure_remove "$tempfile"
fi
ynh_clean_check_starting
# restore it if the upgrade fails
ynh_restore_upgradebackup
@ -152,10 +155,10 @@ cp ../conf/credentials.json "$final_path/credentials.json"
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json"
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
password=$(ynh_app_setting_get $app password)
ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json"
ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json"
ynh_replace_string "__PASSWD__" "$password" "$final_path/credentials.json"
ynh_print_OFF; ynh_replace_password_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON
if [ "$export" = "abiword" ]
then
abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword
@ -192,10 +195,7 @@ chown $app -R /var/log/$app/etherpad.log
# SETUP LOGROTATE
#=================================================
# Remove logrotate config
ynh_remove_logrotate
# And replace it
ynh_use_logrotate
ynh_use_logrotate --non-append
#=================================================
# SETUP SYSTEMD
@ -215,17 +215,6 @@ then
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad.
fi
#=================================================
# START ETHERPAD IN BACKGROUND
#=================================================
# Démarre etherpad
WARNING echo "Redémarrage d'etherpad"
tempfile="$(mktemp)"
tail -f -n1 /var/log/$app/etherpad.log > "$tempfile" & # Suit le démarrage dans le log
PID_TAIL=$! # Récupère le PID de la commande tail, qui est passée en arrière plan.
systemctl start $app # Redémarre etherpad. Le démarrage est fait le plus tôt possible, car il est très long...
#=================================================
# SETUP SSOWAT
#=================================================
@ -247,16 +236,5 @@ systemctl reload nginx
# CHECK ETHERPAD STARTING
#=================================================
for i in `seq 1 120`
do # La boucle attend le démarrage d'etherpad. Ou 2 minutes. Cette boucle évite simplement un 502 au début, car le démarrage est long...
if grep -q "You can access your Etherpad instance at" "$tempfile"; then
WARNING echo "Le service $app a démarré correctement."
break # Si le log annonce le démarrage d'etherpad, sort de la boucle.
fi
WARNING echo -n "."
sleep 1
done
echo ""
QUIET kill -s 15 $PID_TAIL # Arrête l'exécution de tail.
ynh_secure_remove "$tempfile"
# Wait for etherpad fully started
ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120"