From 72a01320f9dcc8bf36fda005ed68c1b2e946dd90 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 12 Aug 2016 14:04:56 +0200 Subject: [PATCH] Corrections admin etherpad --- conf/credentials.json | 26 ++++++++++++++++++++++++++ conf/settings.json | 16 ++-------------- scripts/.fonctions | 4 ++-- scripts/install | 19 ++++++++++++------- scripts/upgrade | 27 +++++++++++++++++---------- 5 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 conf/credentials.json diff --git a/conf/credentials.json b/conf/credentials.json new file mode 100644 index 0000000..80c3c52 --- /dev/null +++ b/conf/credentials.json @@ -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 + } + }, +} diff --git a/conf/settings.json b/conf/settings.json index e6f5748..af0f014 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -41,14 +41,7 @@ // }, /* An Example of MySQL Configuration */ - "dbType" : "mysql", - "dbSettings" : { - "user" : "__DB_USER__", - "host" : "localhost", - "password": "__DB_PWD__", - "database": "__DB_USER__", - "charset" : "utf8mb4" - }, +// Withdrawn and moved... //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", @@ -142,12 +135,7 @@ /* 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 - } - }, +// Withdrawn and moved... // restrict socket.io transport methods "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], diff --git a/scripts/.fonctions b/scripts/.fonctions index 25ea8b7..906918a 100755 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -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 # $1 = Nom du fichier de conf pour le stockage dans settings.yml # $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é. # $1 = Nom du fichier de conf pour le stockage dans settings.yml # $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. fi } diff --git a/scripts/install b/scripts/install index cb8545b..6f4ec93 100644 --- a/scripts/install +++ b/scripts/install @@ -65,8 +65,10 @@ sudo apt-get install npm nodejs-legacy -qy # Créer l'user etherpad if ! grep -q "^etherpad:" /etc/passwd # Test l'existence de l'utilisateur then # Si il n'existe pas, l'user etherpad est créé - sudo useradd etherpad -r + sudo useradd etherpad -d /home/.etherpad fi +sudo mkdir -p /home/.etherpad +sudo chown etherpad: -R /home/.etherpad # Créer le dossier de log sudo mkdir -p /var/log/$app @@ -83,24 +85,25 @@ sudo npm install forever -g >> $install_log 2>&1 # Configure etherpad 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/__DB_USER__/$db_user/g" "$final_path/settings.json" -sudo sed -i "s/__DB_PWD__/$db_pwd/g" "$final_path/settings.json" -sudo sed -i "s/__ADMIN__/$admin/g" "$final_path/settings.json" -sudo sed -i "s/__PASSWD__/$password/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/credentials.json" +sudo sed -i "s/__ADMIN__/$admin/g" "$final_path/credentials.json" +sudo sed -i "s/__PASSWD__/$password/g" "$final_path/credentials.json" if [ "$abiword" -eq 1 ] then sudo apt-get install abiword -qy # Installation 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 - STORE_MD5_CONFIG "settings.json" "$final_path/settings.json" # Enregistre la somme de contrôle du fichier de config fi 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 # Les fichiers appartiennent à etherpad 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 @@ -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 if [ "$is_public" = "Yes" ]; then 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 # Recharge la configuration Nginx diff --git a/scripts/upgrade b/scripts/upgrade index 8db910a..0f7cd07 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,7 +15,6 @@ final_path=$(sudo yunohost app setting $app final_path) port=$(sudo yunohost app setting $app port) 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 # 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 # 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 "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/credentials.json "$final_path/credentials.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) -sudo sed -i "s/__DB_PWD__/$db_pwd/g" "$final_path/settings.json" -sudo sed -i "s/__ADMIN__/$admin/g" "$final_path/settings.json" -sudo sed -i "s/__PASSWD__/$password/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/credentials.json" +sudo sed -i "s/__PASSWD__/$password/g" "$final_path/credentials.json" if [ "$abiword" -eq 1 ] then 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 fi 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 # Les fichiers appartiennent à etherpad 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 @@ -64,14 +65,18 @@ sudo sed -i "s@__APP__@$app@g" /etc/systemd/system/$app.service sudo systemctl enable $app.service # Ajoute un lien vers etherpad pour créer des pads anonymes depuis Mypads. -sudo sed -i "s@^ *\"DESCRIPTION\": .*@&Pads anonymes@g" $final_path/node_modules/ep_mypads/static/l10n/fr.json -sudo sed -i "s@^ *\"DESCRIPTION\": .*@&Anonymous pads@g" $final_path/node_modules/ep_mypads/static/l10n/en.json +# sudo sed -i "s@^ *\"DESCRIPTION\": .*@&Pads anonymes@g" $final_path/node_modules/ep_mypads/static/l10n/fr.json +# sudo sed -i "s@^ *\"DESCRIPTION\": .*@&Anonymous pads@g" $final_path/node_modules/ep_mypads/static/l10n/en.json # Et un lien vers l'admin etherpad depuis Mypads. -sudo sed -i "s@^ *\"FOOTER\": .*2.0@& | Etherpad admin@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@& | Etherpad admin@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 "" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad. sudo sed -i "$mod_line s@div>@&\n\t

Mypads
@" $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 echo "Démarrage d'etherpad" >&2 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 if [ "$is_public" = "Yes" ]; then 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 # Recharge la configuration Nginx