From ff317ed996ceca91ada7e6f9f814454633fde6fd Mon Sep 17 00:00:00 2001 From: tligui_y Date: Thu, 14 Aug 2025 14:32:57 +0200 Subject: [PATCH] Update install_elog.sh --- install_elog.sh | 134 +++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 80 deletions(-) diff --git a/install_elog.sh b/install_elog.sh index d4fd9af4..8fb1aabc 100644 --- a/install_elog.sh +++ b/install_elog.sh @@ -1,102 +1,76 @@ #!/bin/bash +set -euo pipefail -echo "๐Ÿ“ฆ Installing ELOG..." - +echo "๐Ÿ“ฆ Installing build deps..." sudo apt update -sudo apt install -y make gcc wget tar curl apache2-utils +sudo apt install -y git make gcc wget tar curl apache2-utils -# Download 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 -make -cd .. +# 1) Clone / Update ELOG (GIT) +echo "๐Ÿ“ฅ Cloning ELOG (Bitbucket) ..." +rm -rf /tmp/elog-build +mkdir -p /tmp/elog-build +cd /tmp/elog-build +git clone --recursive https://bitbucket.org/ritt/elog +cd elog -# Install in ~/.local/bin -mkdir -p ~/.local/bin -cp elog-2.7.1/elogd ~/.local/bin +# 2) Build +echo "๐Ÿ› ๏ธ Building elogd ..." +make -j"$(nproc)" + +# 3) Install locally (no sudo-wide install) +echo "๐Ÿ“Œ Installing to ~/.local/bin ..." +mkdir -p "$HOME/.local/bin" +cp elogd "$HOME/.local/bin/" export PATH="$HOME/.local/bin:$PATH" -echo "$HOME/.local/bin" >> $GITHUB_PATH +# (optionnel en CI) echo "$HOME/.local/bin" >> $GITHUB_PATH || true -# Create an ELOG instance +# 4) Prepare instance directories +echo "๐Ÿ“ Preparing instance ..." +cd ~ mkdir -p elog_instance/logbooks/demo -# Check the existence of the directory -logbook_directory="elog_instance/logbooks/demo" -echo "Checking the existence of the directory $logbook_directory" +# 5) Permissions (optionnel, utile en CI) +sudo chown -R "$USER":"$USER" elog_instance +chmod -R 775 elog_instance/logbooks -# Verify if the directory exists -if [ ! -d "$logbook_directory" ]; then - echo "The directory $logbook_directory does not exist. Creating the directory..." - mkdir -p $logbook_directory -else - echo "The directory $logbook_directory exists." -fi - -# Check write permissions -if [ -w "$logbook_directory" ]; then - echo "The directory $logbook_directory has write permissions." -else - echo "The directory $logbook_directory does not have write permissions." -fi - -# Check disk space -disk_usage=$(df "$logbook_directory") -echo "Checking disk space in the directory $logbook_directory:" -echo "$disk_usage" - -# Change ownership to nobody:nogroup -echo "Changing ownership of $logbook_directory to nobody:nogroup..." -sudo chown -R nobody:nogroup $logbook_directory - -# Set the correct permissions (775) -echo "Setting permissions of $logbook_directory to 775..." -sudo chmod -R 775 $logbook_directory - -# Generate password file -htpasswd -cb elog_instance/elog.passwd robot testpassword - -# Configuration with restricted access -cat > elog_instance/elogd.cfg < elog_instance/elogd.cfg <<'EOF' [global] Port = 8080 -LogDir = logbooks -AllowHTML = 1 -ListAfterSubmit = 0 +Logbook dir = elog_instance/logbooks +Allow HTML = 1 +List after submit = 0 [demo] -LogDir = logbooks/demo -Authentication = required -PasswordFile = elog_instance/elog.passwd -AllowEdit = all -AllowDelete = all -Guest = 0 -AllowAnonymous = 0 -RequiredAttributes = Author +Subdir = demo +# IMPORTANT: ELOG gรจre son propre fichier d'utilisateurs (pas htpasswd) +Password file = users.pwd +# Autorisations/menu : les invitรฉs ne peuvent pas poster +Guest menu commands = List, Login, Help +Menu commands = List, New, Edit, Reply, Duplicate, Find, Config, Logout, Help + +# Exiger des attributs +Required Attributes = Author + +# Pour crรฉer le premier utilisateur via UI (temporaire, remettre ร  0 ensuite) +Self register = 1 EOF -# Start the server -echo "๐Ÿ“ก Starting the ELOG server..." -~/.local/bin/elogd -c elog_instance/elogd.cfg & -sleep 3 +# 7) Start server +echo "๐Ÿ“ก Starting ELOG (git build) ..." +pkill -f 'elogd -c' 2>/dev/null || true +~/.local/bin/elogd -c elog_instance/elogd.cfg -v & +sleep 2 -# Check version -echo "โœ… elogd version:" +# 8) Version check +echo "โœ… Running version:" ~/.local/bin/elogd -h | head -n 1 -# Check if the server is listening on port 8080 -ps aux | grep elogd - -# Test access +# 9) Quick auth check (should show login page for New/Submit) URL="http://localhost:8080/demo" - -resp=$(curl -s -L "$URL/?cmd=Submit" \ - -F "Author=test" \ - -F "Text=auth_test") - -if echo "$resp" | grep -q 'type="password"'; then - echo "๐Ÿ”’ Auth required" +if curl -s -L "$URL/?cmd=New" | grep -iq "login"; then + echo "๐Ÿ”’ Auth enforced (OK) โ€” open $URL and Register your first user." else - echo "โœ… No auth required" -fi + echo "โš ๏ธ Auth not detected โ€” verify 'Password file' and section names." +fi \ No newline at end of file