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

Corrections admin etherpad

This commit is contained in:
Maniack Crudelis 2016-08-12 14:04:56 +02:00
parent f4de52d610
commit 72a01320f9
5 changed files with 59 additions and 33 deletions

26
conf/credentials.json Normal file
View file

@ -0,0 +1,26 @@
/*
This file must be valid JSON. But comments are allowed
*/
{
//The Type of the database. You can choose between dirty, postgres, sqlite and mysql
//You shouldn't use "dirty" for for anything else than testing or development },
/* An Example of MySQL Configuration */
"dbType" : "mysql",
"dbSettings" : {
"user" : "__DB_USER__",
"host" : "localhost",
"password": "__DB_PWD__",
"database": "__DB_USER__",
"charset" : "utf8mb4"
},
/* Users for basic authentication. is_admin = true gives access to /admin.
If you do not uncomment this, /admin will not be available! */
"users": {
"__ADMIN__": {
"password": "__PASSWD__",
"is_admin": true
}
},
}

View file

@ -41,14 +41,7 @@
// }, // },
/* An Example of MySQL Configuration */ /* An Example of MySQL Configuration */
"dbType" : "mysql", // Withdrawn and moved...
"dbSettings" : {
"user" : "__DB_USER__",
"host" : "localhost",
"password": "__DB_PWD__",
"database": "__DB_USER__",
"charset" : "utf8mb4"
},
//the default text of a pad //the default text of a pad
"defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n", "defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n",
@ -142,12 +135,7 @@
/* Users for basic authentication. is_admin = true gives access to /admin. /* Users for basic authentication. is_admin = true gives access to /admin.
If you do not uncomment this, /admin will not be available! */ If you do not uncomment this, /admin will not be available! */
"users": { // Withdrawn and moved...
"__ADMIN__": {
"password": "__PASSWD__",
"is_admin": true
}
},
// restrict socket.io transport methods // restrict socket.io transport methods
"socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"],

View file

@ -115,13 +115,13 @@ POOL_FPM () { # Créer le fichier de configuration du pool php-fpm et le configu
STORE_MD5_CONFIG () { # Enregistre la somme de contrôle du fichier de config 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 # $1 = Nom du fichier de conf pour le stockage dans settings.yml
# $2 = Nom complet et chemin du fichier de conf. # $2 = Nom complet et chemin du fichier de conf.
sudo yunohost app setting $app $1_file_md5 -v $(md5sum "$2" | cut -d' ' -f1) sudo yunohost app setting $app $1_file_md5 -v $(sudo md5sum "$2" | cut -d' ' -f1)
} }
CHECK_MD5_CONFIG () { # Créé un backup du fichier de config si il a été modifié. 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 # $1 = Nom du fichier de conf pour le stockage dans settings.yml
# $2 = Nom complet et chemin du fichier de conf. # $2 = Nom complet et chemin du fichier de conf.
if [ "$(sudo yunohost app setting $app $1_file_md5)" != $(md5sum "$2" | cut -d' ' -f1) ]; then if [ "$(sudo yunohost app setting $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. 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 fi
} }

View file

@ -65,8 +65,10 @@ sudo apt-get install npm nodejs-legacy -qy
# Créer l'user etherpad # Créer l'user etherpad
if ! grep -q "^etherpad:" /etc/passwd # Test l'existence de l'utilisateur if ! grep -q "^etherpad:" /etc/passwd # Test l'existence de l'utilisateur
then # Si il n'existe pas, l'user etherpad est créé then # Si il n'existe pas, l'user etherpad est créé
sudo useradd etherpad -r sudo useradd etherpad -d /home/.etherpad
fi fi
sudo mkdir -p /home/.etherpad
sudo chown etherpad: -R /home/.etherpad
# Créer le dossier de log # Créer le dossier de log
sudo mkdir -p /var/log/$app sudo mkdir -p /var/log/$app
@ -83,24 +85,25 @@ sudo npm install forever -g >> $install_log 2>&1
# Configure etherpad # Configure etherpad
sudo cp ../conf/settings.json "$final_path/settings.json" sudo cp ../conf/settings.json "$final_path/settings.json"
sudo cp ../conf/credentials.json "$final_path/credentials.json"
sudo sed -i "s/__PORT__/$port/g" "$final_path/settings.json" sudo sed -i "s/__PORT__/$port/g" "$final_path/settings.json"
sudo sed -i "s/__DB_USER__/$db_user/g" "$final_path/settings.json" sudo sed -i "s/__DB_USER__/$db_user/g" "$final_path/credentials.json"
sudo sed -i "s/__DB_PWD__/$db_pwd/g" "$final_path/settings.json" sudo sed -i "s/__DB_PWD__/$db_pwd/g" "$final_path/credentials.json"
sudo sed -i "s/__ADMIN__/$admin/g" "$final_path/settings.json" sudo sed -i "s/__ADMIN__/$admin/g" "$final_path/credentials.json"
sudo sed -i "s/__PASSWD__/$password/g" "$final_path/settings.json" sudo sed -i "s/__PASSWD__/$password/g" "$final_path/credentials.json"
if [ "$abiword" -eq 1 ] if [ "$abiword" -eq 1 ]
then then
sudo apt-get install abiword -qy # Installation de abiword sudo apt-get install abiword -qy # Installation de abiword
abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword
sudo sed -i "s@\"abiword\" : null@\"abiword\" : \"$abiword_path\"@" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad sudo sed -i "s@\"abiword\" : null@\"abiword\" : \"$abiword_path\"@" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
STORE_MD5_CONFIG "settings.json" "$final_path/settings.json" # Enregistre la somme de contrôle du fichier de config
fi fi
STORE_MD5_CONFIG "settings.json" "$final_path/settings.json" # Enregistre la somme de contrôle du fichier de config STORE_MD5_CONFIG "settings.json" "$final_path/settings.json" # Enregistre la somme de contrôle du fichier de config
STORE_MD5_CONFIG "credentials.json" "$final_path/credentials.json" # Enregistre la somme de contrôle du fichier de config
# Configure les droits d'accès au fichiers # Configure les droits d'accès au fichiers
# Les fichiers appartiennent à etherpad # Les fichiers appartiennent à etherpad
sudo chown -R etherpad: $final_path sudo chown -R etherpad: $final_path
sudo chmod 700 $final_path/settings.json # Restreint l'accès à settings.json sudo chmod 600 $final_path/credentials.json # Restreint l'accès à credentials.json
# Configuration de logrotate # Configuration de logrotate
@ -160,6 +163,8 @@ sudo service $app start # Démarre etherpad. Le démarrage est fait le plus tôt
# Make app public if necessary # Make app public if necessary
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
sudo yunohost app setting $app skipped_uris -v "/" sudo yunohost app setting $app skipped_uris -v "/"
else
sudo yunohost app setting $app skipped_uris -v "/admin" # La page d'admin etherpad ne supporte pas le sso...
fi fi
# Recharge la configuration Nginx # Recharge la configuration Nginx

View file

@ -15,7 +15,6 @@ final_path=$(sudo yunohost app setting $app final_path)
port=$(sudo yunohost app setting $app port) port=$(sudo yunohost app setting $app port)
abiword=$(sudo yunohost app setting $app abiword) abiword=$(sudo yunohost app setting $app abiword)
SETUP_SOURCE "1.6.0.tar.gz" # Télécharge la source, décompresse et copie dans $final_path SETUP_SOURCE "1.6.0.tar.gz" # Télécharge la source, décompresse et copie dans $final_path
# Et copie le fichier de config nginx # Et copie le fichier de config nginx
@ -27,26 +26,28 @@ sudo sed -i "s@__PORT__@$port@g" /etc/nginx/conf.d/$domain.d/$app.conf
# Configure etherpad # Configure etherpad
# Copie ou modification d'un fichier de config # Copie ou modification d'un fichier de config
sudo chmod 777 $final_path/settings.json # Autorise l'accès à settings.json
CHECK_MD5_CONFIG "settings.json" "$final_path/settings.json" # Créé un backup du fichier de config si il a été modifié. CHECK_MD5_CONFIG "settings.json" "$final_path/settings.json" # Créé un backup du fichier de config si il a été modifié.
CHECK_MD5_CONFIG "credentials.json" "$final_path/credentials.json" # Créé un backup du fichier de config si il a été modifié.
sudo cp ../conf/settings.json "$final_path/settings.json" sudo cp ../conf/settings.json "$final_path/settings.json"
sudo cp ../conf/credentials.json "$final_path/credentials.json"
sudo sed -i "s/__PORT__/$port/g" "$final_path/settings.json" sudo sed -i "s/__PORT__/$port/g" "$final_path/settings.json"
sudo sed -i "s/__DB_USER__/$app/g" "$final_path/settings.json" sudo sed -i "s/__DB_USER__/$app/g" "$final_path/credentials.json"
db_pwd=$(sudo yunohost app setting $app mysqlpwd) db_pwd=$(sudo yunohost app setting $app mysqlpwd)
sudo sed -i "s/__DB_PWD__/$db_pwd/g" "$final_path/settings.json" sudo sed -i "s/__DB_PWD__/$db_pwd/g" "$final_path/credentials.json"
sudo sed -i "s/__ADMIN__/$admin/g" "$final_path/settings.json" sudo sed -i "s/__ADMIN__/$admin/g" "$final_path/credentials.json"
sudo sed -i "s/__PASSWD__/$password/g" "$final_path/settings.json" sudo sed -i "s/__PASSWD__/$password/g" "$final_path/credentials.json"
if [ "$abiword" -eq 1 ] if [ "$abiword" -eq 1 ]
then then
abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword abiword_path=`which abiword` # Récupère l'emplacement de l'exécutable de abiword
sudo sed -i "s@\"abiword\" : null@\"abiword\" : \"$abiword_path\"@" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad sudo sed -i "s@\"abiword\" : null@\"abiword\" : \"$abiword_path\"@" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
fi fi
STORE_MD5_CONFIG "settings.json" "$final_path/settings.json" # Réenregistre la somme de contrôle du fichier de config STORE_MD5_CONFIG "settings.json" "$final_path/settings.json" # Réenregistre la somme de contrôle du fichier de config
STORE_MD5_CONFIG "credentials.json" "$final_path/credentials.json" # Réenregistre la somme de contrôle du fichier de config
# Configure les droits d'accès au fichiers # Configure les droits d'accès au fichiers
# Les fichiers appartiennent à etherpad # Les fichiers appartiennent à etherpad
sudo chown -R etherpad: $final_path sudo chown -R etherpad: $final_path
sudo chmod 700 $final_path/settings.json # Restreint l'accès à settings.json sudo chmod 600 "$final_path/credentials.json" # Restreint l'accès à credentials.json
# Configuration de logrotate # Configuration de logrotate
@ -64,14 +65,18 @@ sudo sed -i "s@__APP__@$app@g" /etc/systemd/system/$app.service
sudo systemctl enable $app.service sudo systemctl enable $app.service
# Ajoute un lien vers etherpad pour créer des pads anonymes depuis Mypads. # Ajoute un lien vers etherpad pour créer des pads anonymes depuis Mypads.
sudo sed -i "s@^ *\"DESCRIPTION\": .*</ul>@&<a href=../>Pads anonymes</a>@g" $final_path/node_modules/ep_mypads/static/l10n/fr.json # sudo sed -i "s@^ *\"DESCRIPTION\": .*</ul>@&<a href=../>Pads anonymes</a>@g" $final_path/node_modules/ep_mypads/static/l10n/fr.json
sudo sed -i "s@^ *\"DESCRIPTION\": .*</ul>@&<a href=../>Anonymous pads</a>@g" $final_path/node_modules/ep_mypads/static/l10n/en.json # sudo sed -i "s@^ *\"DESCRIPTION\": .*</ul>@&<a href=../>Anonymous pads</a>@g" $final_path/node_modules/ep_mypads/static/l10n/en.json
# Et un lien vers l'admin etherpad depuis Mypads. # Et un lien vers l'admin etherpad depuis Mypads.
sudo sed -i "s@^ *\"FOOTER\": .*2.0@& | <a href='../admin'>Etherpad admin</a>@g" $final_path/node_modules/ep_mypads/static/l10n/en.json $final_path/node_modules/ep_mypads/static/l10n/fr.json # sudo sed -i "s@^ *\"FOOTER\": .*2.0@& | <a href='../admin'>Etherpad admin</a>@g" $final_path/node_modules/ep_mypads/static/l10n/en.json $final_path/node_modules/ep_mypads/static/l10n/fr.json
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad. mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad.
sudo 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. sudo 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.
sudo mkdir -p /home/.etherpad
sudo chown etherpad: -R /home/.etherpad
sudo usermod -d /home/.etherpad etherpad
# Démarre etherpad # Démarre etherpad
echo "Démarrage d'etherpad" >&2 echo "Démarrage d'etherpad" >&2
tempfile="$(mktemp)" tempfile="$(mktemp)"
@ -82,6 +87,8 @@ sudo service $app start # Démarre etherpad. Le démarrage est fait le plus tôt
# Make app public if necessary # Make app public if necessary
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
sudo yunohost app setting $app skipped_uris -v "/" sudo yunohost app setting $app skipped_uris -v "/"
else
sudo yunohost app setting $app skipped_uris -v "/admin" # La page d'admin etherpad ne supporte pas le sso...
fi fi
# Recharge la configuration Nginx # Recharge la configuration Nginx