Outils pour utilisateurs

Outils du site


admin:services:paste.chapril.org

Ceci est une ancienne révision du document !


Service paste.chapril.org

Introduction

Ce service est basé sur privatebin
site principal : https://privatebin.info
sources : https://github.com/PrivateBin/PrivateBin
installation : https://github.com/PrivateBin/PrivateBin/wiki/Installation
Les données peuvent être stockées en SQL ou en fichier plat, ici la solution retenue est fichiers plats

Préparation

création d'un utilisateur (non indispensable mais fait pour chapril)

useradd pastechaprilorg
usermod -a -G www-data pastechaprilorg

Ajouter le module php7.0-gd

apt-get install php7.0-gd

Installation

Déploiement du code

cd /var/www/
wget https://github.com/PrivateBin/PrivateBin/archive/x.x.x.tar.gz
tar xf x.x.x.tar.gz && rm x.x.x.tar.gz
mv PrivateBin-x.x.x paste.chapril.org
chown www-data:www-data  -R /var/www/paste.chapril.org

Fichiers de logs

cd /var/log/apache2/
mkdir paste.chapril.org

Configuration d'apache2

Créer le fichier /etc/apache2/sites-avalailable/paste.chapril.org.conf avec le contenu ci-dessous

<VirtualHost *:80>
	     ServerName paste.chapril.org
	     ServerAdmin webmaster@localhost
	     DocumentRoot /var/www/paste.chapril.org/
	     php_admin_value open_basedir "/var/www/paste.chapril.org/"

	     <Directory "/var/www/paste.chapril.org/">
	     	 AllowOverride All
	     </Directory>

	     ErrorLog ${APACHE_LOG_DIR}/paste.chapril.org/paste.chapril.org-error.log
	     CustomLog ${APACHE_LOG_DIR}/paste.chapril.org/paste.chapril.org-access.log combined-proxy
</VirtualHost>

Activation de la configuration

    a2ensite paste.chapril.org.conf
    systemctl reload apache2

Configuration

cd /var/www/paste.chapril.org/cfg
cp conf.sample.php conf.php
Dans la section [traffic] du fichier conf.php
dir = PATH "/var/www/paste.chapril.org/data"
Dans la section [purge] du fichier conf.php
dir = PATH "data"
Dans la section [model_options] du fichier conf.php
dir = PATH "data"

Création d'un répertoire pour les données et affectation des droits

cd /var/www/paste.chapril.org
mkdir data  
chown www-data:www-data data
chmod -R u+rwX /var/www/paste.chapril.org/data

Rapport d'activité

Créer le répertoire rapport_activite dans /srv/paste.chapril.org/tools

mkdir /srv/paste.chapril.org/tools
mkdir /srv/paste.chapril.org/tools/rapport_activite

Copier dans ce répertoire le script rapport_activite.sh https://forge.april.org/Chapril/paste.chapril.org-tools/src/branch/master/rapport_activite/rapport_activite.sh et le rendre executable. (Si nécessaire se mettre sur la dernière branche)

puis créer la tache cron en ajoutant un fichier pastechaprilorg dans /etc/cron.d avec la ligne suivante

1 0 1 * * root /srv/paste.chapril.org/tools/rapport_activite/rapport_activite.sh -p  >> /srv/paste.chapril.org/Exploitation/rapport_paste.log 2>&1

Création d'un dossier de projet

Créer le répertoire /srv/paste.chapril.org/Exploitation Avec dedans un fichier rapport_paste.log

mkdir /srv/paste.chapril.org/Exploitation
touch rapport_paste.log

Monitoring

Mettre dans le dossier /usr/lib/nagios/plugins un fichier check_pastechaprilorg_update et une copie dans /srv/paste.chapril.org/tools/monitoring

function usage() {
	echo "Usage : $0"
}

#
if [ "$#" -ne 0 ]; then
    usage
else
    lastVersion=$(curl -s https://privatebin.info/|grep Current|cut -d' ' -f3|cut -d'<' -f1)
    currentVersion=$(cd /var/www/paste.chapril.org && git branch | grep '*'|cut -c 11-100 )
    #echo $lastVersion
    #echo $currentVersion
    if [ $currentVersion = $lastVersion ]; then
	echo  "OK"
	result=0
    else
	echo  "WARNING : new version available, current is $currentVersion, last is $lastVersion."
	result=1
    fi    
fi
exit $result

Installation d'un mise à jour

Émettre un avis de maintenance planifiée.

Désactiver le site.

a2dissite paste.chapril.org.conf
systemctl restart apache2

Faire une sauvegarde du dossier en production.(Changer la date!)

cp -a /var/www/paste.chapril.org  /srv/paste.chapril.org/paste.chapril.org20200412

Se mettre sur la dernière branche master,créer une nouvelle branche master et se mettre dessus.

git checkout master-x.x.x
git branch master-x.x.(x+1)
git checkout master-x.x.(x+1)

Tout vider sauf .git et .gitignore.

Récupérer le fichier tar de la nouvelle version et le décompresser.

Si nécessaire déplacer l'ensemble des fichiers dans /var/www/paste.chapril.org.

wget https://github.com/PrivateBin/PrivateBin/archive/x.x.(x+1).tar.gz
tar xf x.x.(x+1).tar.gz && rm x.x.(x+1).tar.gz

Récupérer dans la sauvegarde le répertoire data et le fichier paste.log

cp -a /srv/paste.chapril.org/paste.chapril.org20200412/data /var/www/paste.chapril.org/
cp  /srv/paste.chapril.org/paste.chapril.org20200412/paste.log /var/www/paste.chapril.org/paste.log

Faire le commit

git commit -m "version (x.x.x+1) (#1111)"

Revenir sur la dernière branche chapril-x.x.x, créer une nouvelle branche chapril-x.x.(x+1) et se mettre dessus et faire le merge de la branche master-x.x.(x+1) dans chapril-x.x.(x+1).

git checkout chapril-x.x.x
git branch chapril-x.x.(x+1)
git checkout chapril-x.x.(x+1)
git merge master-x.x.(x+1)

Résoudre le problèmes éventuels. Réactiver le site et mettre l'avis de maintenance à terminé. Faire un push vers la forge et la faire pointer vers la dernière branche

a2ensite paste.chapril.org.conf
systemctl restart apache2
git push --all
admin/services/paste.chapril.org.1586978242.txt.gz · Dernière modification : 2020/04/15 19:17 de dclermonte