#!/bin/bash source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script # Source app helpers source /usr/share/yunohost/helpers # Récupère les infos de l'application. app=$YNH_APP_INSTANCE_NAME domain=$(sudo yunohost app setting $app domain) path=$(sudo yunohost app setting $app path) admin=$(sudo yunohost app setting $app admin) language=$(sudo yunohost app setting $app language) is_public=$(sudo yunohost app setting $app is_public) 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 sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Modifie les variables dans le fichier de configuration nginx 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 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/credentials.json" db_pwd=$(sudo yunohost app setting $app mysqlpwd) 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 if test -z $language; then language=en # En cas d'upgrade d'une version ne gérant pas la langue, la langue est anglais par défaut sudo yunohost app setting $app language -v $language fi sudo sed -i "s/__LANGUAGE__/$language/g" "$final_path/settings.json" 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 600 "$final_path/credentials.json" # Restreint l'accès à credentials.json # Configuration de logrotate sed -i "s@__APP__@$app@g" ../conf/logrotate sudo cp ../conf/logrotate /etc/logrotate.d/$app # Mise en place du script systemd sudo service $app stop sudo cp ../conf/etherpad.service /etc/systemd/system/$app.service sudo chown root: /etc/systemd/system/$app.service sudo sed -i "s@__FINALPATH__@$final_path/@g" /etc/systemd/system/$app.service sudo sed -i "s@__APP__@$app@g" /etc/systemd/system/$app.service ## Démarrage auto du 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 # 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 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