+11
-48
@@ -1,29 +1,27 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# --- 1) Build ELOG from git ---
|
||||
echo "📥 Cloning ELOG (Bitbucket)…"
|
||||
# Build ELOG
|
||||
rm -rf /tmp/elog-build && mkdir -p /tmp/elog-build
|
||||
cd /tmp/elog-build
|
||||
git clone --recursive https://bitbucket.org/ritt/elog
|
||||
cd elog
|
||||
make -j"$(nproc)"
|
||||
|
||||
echo "📌 Installing to ~/.local/bin …"
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
cp elogd "$HOME/.local/bin/"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
# --- 2) Prepare instance ---
|
||||
echo "📁 Preparing instance …"
|
||||
# Prepare instance
|
||||
INSTANCE_DIR="$HOME/elog_instance"
|
||||
LOGBOOK_DIR="$INSTANCE_DIR/logbooks/demo"
|
||||
mkdir -p "$LOGBOOK_DIR"
|
||||
chmod -R 775 "$INSTANCE_DIR"
|
||||
YEAR_DIR="$LOGBOOK_DIR/$(date +%Y)"
|
||||
mkdir -p "$YEAR_DIR"
|
||||
chmod -R 777 "$INSTANCE_DIR"
|
||||
|
||||
# --- 3) Global passwords ---
|
||||
#PASSWORD="me1T.2jUUqQNa1wNuey9zNBOmOa4eILOaPb.ZSZjpn4"
|
||||
# Generate SHA256-crypt hash for testpassword
|
||||
HASH=$(python3 -c "import crypt; print(crypt.crypt('testpassword', crypt.mksalt(crypt.METHOD_SHA256, rounds=5000)))")
|
||||
|
||||
# --- 4) Write config ---
|
||||
cat > "$INSTANCE_DIR/elogd.cfg" <<EOF
|
||||
[global]
|
||||
Port = 8080
|
||||
@@ -36,54 +34,19 @@ Group = $(id -gn)
|
||||
|
||||
[demo]
|
||||
Subdir = demo
|
||||
|
||||
Preset Author = robot
|
||||
|
||||
# Auth for write/admin only
|
||||
Write password=testpassword
|
||||
Admin password=testpassword
|
||||
Write password=$HASH
|
||||
Admin password=$HASH
|
||||
|
||||
# Guests can read freely
|
||||
Guest menu commands = List, Find, Last 10, Help
|
||||
Menu commands = List, New, Edit, Reply, Duplicate, Find, Config, Logout, Help
|
||||
|
||||
Required Attributes = Author
|
||||
EOF
|
||||
|
||||
# --- 5) Start server ---
|
||||
echo "📡 Starting ELOG …"
|
||||
# Start ELOG
|
||||
pkill -f 'elogd -c' 2>/dev/null || true
|
||||
~/.local/bin/elogd -c "$INSTANCE_DIR/elogd.cfg" -v &
|
||||
sleep 2
|
||||
~/.local/bin/elogd -h | head -n 1
|
||||
|
||||
# --- 6) Test in CI ---
|
||||
URL="http://localhost:8080/demo"
|
||||
|
||||
echo "🧪 Testing public read (should work without auth)…"
|
||||
curl -s -L "$URL/?cmd=Last%2010" | head -n 5
|
||||
|
||||
echo "🧪 Testing write (should require auth)…"
|
||||
# Try without auth (should fail)
|
||||
if curl -s -L -F "Author=CI Bot" -F "Text=NoAuthTest" "$URL/?cmd=Submit" | grep -qi "login"; then
|
||||
echo "✅ Write without auth blocked"
|
||||
else
|
||||
echo "❌ Write without auth unexpectedly allowed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Try with auth
|
||||
curl -s -L -u "ci:testpassword" \
|
||||
-F "Author=CI Bot" \
|
||||
-F "Text=CI post OK" \
|
||||
"$URL/?cmd=Submit"
|
||||
|
||||
# Verify post appears in Last 10 without needing auth
|
||||
if curl -s -L "$URL/?cmd=Last%2010" | grep -q "CI post OK"; then
|
||||
echo "✅ CI post succeeded and is visible"
|
||||
else
|
||||
echo "❌ CI post not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "ELOG is running with public read + auth-required write/admin (password: testpassword)"
|
||||
|
||||
Reference in New Issue
Block a user