+54
-80
@@ -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 <<EOF
|
||||
# 6) Create config with auth
|
||||
cat > 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
|
||||
Reference in New Issue
Block a user