Update install_elog.sh
Run CI Tests / test (push) Has been cancelled

This commit is contained in:
2025-08-07 00:48:10 +02:00
parent 6f05d6046f
commit d1d79db247
+34 -58
View File
@@ -1,77 +1,53 @@
#!/bin/bash
set +e # Arrête le script en cas d'erreur critique
set -e
# 1. Installation des dépendances
echo "🔧 Installation des dépendances..."
sudo apt-get update
sudo apt-get install -y make gcc libssl-dev apache2-utils wget
echo "📦 Installation de ELOG..."
# 2. Téléchargement et compilation
echo "⬇️ Téléchargement d'ELOG 2.7.1..."
cd /tmp
wget https://downloads.sourceforge.net/project/elog/elog/2.7.1/elog-2.7.1-1.tar.gz || \
wget http://mirror.switch.ch/ftp/mirror/elog/elog-2.7.1-1.tar.gz
sudo apt update
sudo apt install -y make gcc wget tar curl apache2-utils
echo "📦 Extraction et compilation..."
tar xzf elog-*.tar.gz
# Télécharger ELOG
wget https://downloads.sourceforge.net/project/elog/elog/2.7.1/elog-2.7.1-1.tar.gz
tar -xvzf elog-2.7.1-1.tar.gz
cd elog-2.7.1
./configure --prefix=/usr/local
make
sudo make install
cd ..
# 3. Configuration système
echo "📂 Configuration des répertoires..."
sudo mkdir -p /var/log/elog/demo
sudo chown -R $USER:$USER /var/log/elog
sudo chmod -R 775 /var/log/elog
# Installer dans ~/.local/bin
mkdir -p ~/.local/bin
cp elog-2.7.1/elogd ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
echo "$HOME/.local/bin" >> $GITHUB_PATH
# 4. Configuration ELOG (optimisée)
echo "⚙️ Création du fichier de configuration..."
sudo tee /usr/local/etc/elogd.cfg > /dev/null <<'EOF'
# Créer une instance ELOG
mkdir -p elog_instance/logbooks
# Générer le fichier mot de passe
htpasswd -cb elog_instance/elog.passwd robot testpassword
# Configuration avec accès restreint
cat > elog_instance/elogd.cfg <<EOF
[global]
port = 8080
logdir = /var/log/elog
Edit Mode = 1
logdir = logbooks
allowposting = 1
encoding = utf-8
Logging level = 2
allowhtml = 1
[demo]
dir = /var/log/elog/demo
dir = logbooks/demo
allow = robot
passwdfile = /var/log/elog/elog.passwd
Attributes = Author, Type, Category, Subject
Options Type = Routine, Problem, Other
Options Category = General, Hardware, Software
Required Attributes = Author, Type
passwdfile = elog.passwd
EOF
# 5. Configuration authentification
echo "🔐 Configuration du mot de passe..."
htpasswd -bc /var/log/elog/elog.passwd robot testpassword
# Lancer le serveur
~/.local/bin/elogd -c elog_instance/elogd.cfg &
sleep 3
# 6. Démarrage du serveur
echo "🚀 Démarrage du serveur ELOG..."
pkill elogd || true
/usr/local/bin/elogd -c /usr/local/etc/elogd.cfg -d 7 -p 8080 &
sleep 5 # Temps de démarrage
# Vérification
echo "✅ elogd version:"
~/.local/bin/elogd -h | head -n 1
# 7. Test de fonctionnement
echo "🧪 Test du système..."
TEST_MSG="Test_$(date +%s)"
curl -sS -X POST -u robot:testpassword \
-F "Text=$TEST_MSG" \
-F "Author=robot" \
-F "Type=Routine" \
http://localhost:8080/demo?
echo "📬 Accès test au logbook :"
curl http://localhost:8080/demo/ || echo "Pas encore de logbook 'demo'"
if curl -s http://localhost:8080/demo | grep -q "$TEST_MSG"; then
echo -e "\n\033[1;32m✅ INSTALLATION RÉUSSIE!\033[0m"
echo "Accès: http://localhost:8080/demo"
echo "Identifiants: robot/testpassword"
echo "Logs: tail -f /var/log/elog/elogd.log"
else
echo -e "\n\033[1;31m❌ ÉCHEC DE L'INSTALLATION\033[0m"
echo "Debug:"
tail -n 20 /var/log/elog/elogd.log
fi
echo "✅ ELOG setup terminé"