This commit is contained in:
Ludwig Lehnert
2026-07-31 14:50:54 +00:00
parent d6e264e655
commit b0fba5846f
25 changed files with 3452 additions and 7 deletions
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -Eeuo pipefail
: "${AD_DOMAIN:?missing AD_DOMAIN}"
: "${AD_USER_PASSWORD:?missing AD_USER_PASSWORD}"
: "${FILESERVER_HOST:?missing FILESERVER_HOST}"
interval=${DEV_ACTIVITY_INTERVAL_SECONDS:-4}
log() {
printf '[preview-client] %s\n' "$*"
}
smb() {
local user=$1
local share=$2
local commands=$3
smbclient "//${FILESERVER_HOST}/${share}" \
-m SMB3 -U "${AD_DOMAIN}\\${user}%${AD_USER_PASSWORD}" \
-c "$commands"
}
ready=0
for _ in $(seq 1 120); do
if smb alice Data 'ls' >/dev/null 2>&1; then
ready=1
break
fi
sleep 1
done
if [[ $ready != 1 ]]; then
printf '[preview-client] ERROR: SMB server did not become ready\n' >&2
exit 1
fi
printf 'Generated by the preview SMB client.\n' > /tmp/live-note.txt
smb alice Data 'cd Finance; mkdir Reports; cd Reports; put /tmp/live-note.txt live-note.txt; ls' >/dev/null
smb carol Data 'cd Engineering; mkdir Designs; cd Designs; put /tmp/live-note.txt architecture.txt; ls' >/dev/null
smb alice Private 'cd alice; put /tmp/live-note.txt notes.txt; ls' >/dev/null
touch /run/preview-client-ready
log 'Initial SMB reads and writes complete; generating live activity'
counter=0
while true; do
counter=$((counter + 1))
printf 'Preview activity event %d at %s\n' "$counter" "$(date -u +%FT%TZ)" > /tmp/live-note.txt
smb alice Data 'cd Finance; cd Reports; put /tmp/live-note.txt live-note.txt; get live-note.txt /tmp/readback.txt; ls' >/dev/null 2>&1 || true
smb bob Data 'cd Finance; ls' >/dev/null 2>&1 || true
smb carol Data 'cd Engineering; cd Designs; get architecture.txt /tmp/architecture.txt; ls' >/dev/null 2>&1 || true
smb eve Data 'cd Projects; ls' >/dev/null 2>&1 || true
smb alice Private 'cd alice; ls; get notes.txt /tmp/private-note.txt' >/dev/null 2>&1 || true
sleep "$interval"
done