Files
slic/install_elog.sh
T
tligui_y ef2f27e54e
Run CI Tests / test (push) Successful in 1m51s
Update install_elog.sh
2025-08-14 13:10:58 +02:00

113 lines
2.8 KiB
Bash

#!/bin/bash
echo "📦 Installing ELOG..."
sudo apt update
sudo apt install -y 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 ..
# Install in ~/.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
# Create an ELOG instance
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"
# 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
[global]
port = 8080
logdir = logbooks
requirepassword = 1
allowposting = 1
allowhtml = 1
guest = 0
allowanonymous = 0
List after submit = 0
[demo]
dir = logbooks/demo
allow = robot
passwdfile = elog.passwd
Required Attributes = Author
EOF
# Start the server
echo "📡 Starting the ELOG server..."
~/.local/bin/elogd -c elog_instance/elogd.cfg &
sleep 3
# Check version
echo "✅ elogd version:"
~/.local/bin/elogd -h | head -n 1
# Check if the server is listening on port 8080
ps aux | grep elogd
netstat -tuln | grep 8080
# Test read access
echo "📬 Test access to the logbook:"
curl http://localhost:8080/demo/ || echo "No logbook 'demo' yet"
# Test posting an entry (PUT)
echo "📝 Test elog.put (via curl)..."
response=$(curl -s -o /dev/null -w "%{http_code}" -u robot:testpassword \
-F "Author=robot" \
-F "Subject=Test via script" \
-F "Category=General" \
-F "Type=Note" \
-F "Text=Message sent automatically from the script install_elog.sh" \
"http://localhost:8080/demo/?cmd=Submit")
if [ "$response" == "200" ]; then
echo "✅ Insertion successful in the demo logbook"
else
echo "❌ Insertion failed (HTTP code: $response)"
fi
echo "✅ ELOG setup completed"