Update install_elog.sh
Run CI Tests / test (push) Successful in 2m41s

This commit is contained in:
2025-08-26 10:43:00 +02:00
parent 15da53a1fc
commit ca4a1caa7a
+100 -9
View File
@@ -1,16 +1,107 @@
#!/bin/bash #!/bin/bash
set -e set -e
echo "[INFO] Starting fake org.freedesktop.Notifications service..." PREFIX="/usr/local"
INSTANCE_DIR="$PREFIX/elog"
PASSWORD="testpassword"
python3 start-notification-service.py & # =======================
SERVICE_PID=$! # 1. Install dependencies
# =======================
sudo apt update
sudo apt install -y make gcc git curl openssl whois python3-full python3-venv
sleep 1 # =======================
# 2. Download ELOG
# =======================
rm -rf /tmp/elog-src
mkdir -p /tmp/elog-src
cd /tmp/elog-src
git clone --recursive https://bitbucket.org/ritt/elog
cd elog
make -j"$(nproc)"
gdbus introspect \ sudo mkdir -p "$PREFIX/sbin" "$INSTANCE_DIR/logbooks/demo"
--session \ sudo cp elogd "$PREFIX/sbin/"
--dest org.freedesktop.Notifications \
--object-path /org/freedesktop/Notifications
wait $SERVICE_PID # =======================
# 4. Create users.xml with password
# =======================
sudo tee "$INSTANCE_DIR/users.xml" > /dev/null <<EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- created by MXML on $(date) -->
<list>
<user>
<name>robot</name>
<password encoding="SHA256">me1T.2jUUqQNa1wNuey9zNBOmOa4eILOaPb.ZSZjpn4</password>
<full_name>Robot User</full_name>
<last_logout>0</last_logout>
<last_activity>0</last_activity>
<email>robot@example.com</email>
</user>
</list>
EOF
sudo chmod 644 "$INSTANCE_DIR/users.xml"
# =======================
# 5. Create configuration elogd.cfg
# =======================
sudo tee "$INSTANCE_DIR/elogd.cfg" > /dev/null <<EOF
[global]
Port = 8080
Logbook dir = $INSTANCE_DIR/logbooks
Resource dir = $INSTANCE_DIR
Allow HTML = 1
Password file = $INSTANCE_DIR/users.xml
Admin user = robot
Self register = 0
Encrypt passwords = 0
[demo]
Subdir = demo
Preset Author = robot
Login user = robot
Required Attributes = Author
EOF
# =======================
# 6. Script init simple
# =======================
sudo tee /etc/init.d/elogd > /dev/null <<'EOF'
#!/bin/sh
case "$1" in
start)
echo "Starting elogd..."
/usr/local/sbin/elogd -D -c /usr/local/elog/elogd.cfg > /dev/null 2>&1 &
echo $! > /var/run/elogd.pid
;;
stop)
echo "Stopping elogd..."
kill $(cat /var/run/elogd.pid)
rm -f /var/run/elogd.pid
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
EOF
sudo chmod +x /etc/init.d/elogd
# =======================
# 7. Fix permissions
# =======================
sudo chmod -R 777 "$INSTANCE_DIR/logbooks"
# =======================
# 8. Launch ELOG
# =======================
sudo service elogd restart
sleep 3