Episode 19: Nextcloud AIO, OpenCloud and Seafile measured with the same test data on the same server

This commit is contained in:
Maximilian Grimm 2026-10-24 20:37:53 +02:00
parent 76a3132a17
commit 145d318452
70 changed files with 3296 additions and 0 deletions

11
filesync/server/idle.sh Normal file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# idle.sh REGEX SECONDS: Leerlauf messen (docker stats je Container im 5-s-Takt + Host-RAM), dazu Platten- und Image-Bedarf
source /root/ep19fs/lib18.sh
echo "# $(date -u +%FT%TZ) Leerlauf, kein Client verbunden, kein Browser offen"
echo "## free -m vorher"; free -m | sed -n 1,2p
stats5 "$1" "$2"
echo "## free -m nachher"; free -m | sed -n 1,2p
echo "## Container"; docker ps -a --format '{{.Names}}\t{{.Image}}\t{{.Status}}' | grep -E "$1"
echo "## Images"; docker images --format '{{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.Size}}'
echo "## docker system df"; docker system df
echo "## Platte"; df -h / | tail -1; du -sh /var/lib/docker 2>/dev/null

50
filesync/server/lib18.sh Normal file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env bash
# ep18 Lab-Helfer auf der Box. Nur lesen/messen, keine Geheimnisse im Output.
now() { date +%s.%N; }
ts() { date -u +%H:%M:%S; }
el() { python3 -c "print(f'{float(\"$2\")-float(\"$1\"):.2f}')"; }
# waitui URL [max_s]: wartet, bis die URL mit 2xx/3xx antwortet, druckt jede Änderung des Status
waitui() { local url=$1 max=${2:-300} t0=$(now) last=""; while :; do
c=$(curl -sk -o /dev/null -m 2 -w '%{http_code}' "$url");
[ "$c" != "$last" ] && echo " $(ts) +$(el $t0 $(now)) s HTTP $c" && last=$c
case $c in 2*|3*) echo "UI reachable after $(el $t0 $(now)) s"; return 0;; esac
[ $(python3 -c "print(int(float('$(now)')-float('$t0')))") -ge $max ] && echo "TIMEOUT" && return 1; sleep 0.2; done; }
# stats5 NAME_REGEX SECONDS: docker stats im 5-s-Takt, dann Mittel/Max je Container und Summe
stats5() { local re=$1 dur=${2:-300} f=$(mktemp) t0=$(date +%s); echo "# docker stats --no-stream every 5 s for $dur s, containers matching /$re/, start $(ts) UTC"
while [ $(( $(date +%s) - t0 )) -lt $dur ]; do s=$(date +%s.%N)
docker stats --no-stream --format '{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}' | awk -F'\t' -v re="$re" '$1 ~ re' | sed "s/^/$(ts)\t/" | tee -a $f
sleep $(python3 -c "print(max(0,5-($(now)-$s)))"); done
python3 - $f <<'PY'
import sys,collections
u={'B':1/2**20,'KiB':1/1024,'MiB':1,'GiB':1024,'kB':1/1024/1000*1024,'MB':1}
def mib(s):
s=s.strip()
for k in ['GiB','MiB','KiB','kB','MB','B']:
if s.endswith(k): return float(s[:-len(k)])*u[k]
d=collections.defaultdict(lambda:{'cpu':[],'mem':[]}); per=collections.defaultdict(lambda:[0,0])
for l in open(sys.argv[1]):
t,n,c,m=l.rstrip('\n').split('\t'); c=float(c.rstrip('%')); m=mib(m.split('/')[0])
d[n]['cpu'].append(c); d[n]['mem'].append(m); per[t][0]+=c; per[t][1]+=m
print(f"\n{'container':40} {'samples':>7} {'CPU% mean':>9} {'CPU% max':>9} {'RAM MiB mean':>12} {'RAM MiB max':>11}")
for n,v in sorted(d.items()):
print(f"{n:40} {len(v['cpu']):7} {sum(v['cpu'])/len(v['cpu']):9.2f} {max(v['cpu']):9.2f} {sum(v['mem'])/len(v['mem']):12.1f} {max(v['mem']):11.1f}")
c=[x[0] for x in per.values()]; m=[x[1] for x in per.values()]
print(f"{'TOTAL (sum per sample)':40} {len(c):7} {sum(c)/len(c):9.2f} {max(c):9.2f} {sum(m)/len(m):12.1f} {max(m):11.1f}")
PY
rm -f $f; }
# watchrun PROJECT N [max_s]: wartet, bis alle Container des Projekts mit RUN=N laufen; Zeit ab T0 (Env T0)
watchrun() { local p=$1 n=$2 max=${3:-180} t0=${T0:-$(now)}; while :; do
ids=$(docker ps -q --filter label=com.docker.compose.project=$p); ok=0; tot=0
for i in $ids; do tot=$((tot+1)); docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}{{.State.Running}}' $i 2>/dev/null | grep -q "^RUN=$n$" && ok=$((ok+1)); done
if [ $tot -ge 2 ] && [ $ok -eq $tot ]; then echo " RUN=$n: $ok/$tot containers running after $(el $t0 $(now)) s"; return 0; fi
[ $(python3 -c "print(int(float('$(now)')-float('$t0')))") -ge $max ] && echo " TIMEOUT RUN=$n ($ok/$tot)" && return 1; sleep 0.1; done; }
# imgsize IMAGE...: Größe laut docker image ls (containerd-Speicher zeigt Plattenbedarf und Inhalt)
imgsize() { docker image ls --format 'table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.Size}}' | head -1; for i in "$@"; do docker image ls --format '{{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.Size}}' | grep -F "$i" ; done; for i in "$@"; do echo "$i inspect .Size = $(docker image inspect -f '{{.Size}}' $i | numfmt --to=iec-i --suffix=B)"; done; }
# regdigest REPO TAG: Index-Digest auf Docker Hub (ohne buildx)
regdigest() { local t=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$1:pull" | jq -r .token)
curl -sI -H "Authorization: Bearer $t" -H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json' "https://registry-1.docker.io/v2/$1/manifests/$2" | awk 'tolower($1)=="docker-content-digest:"{print $2}' | tr -d '\r'; }

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Nextcloud All-in-One, Befehl wörtlich aus dem README (Schritt 3). Misst bis die AIO-Oberfläche antwortet.
source /root/ep19fs/lib.sh
echo "# $(date -u +%FT%TZ) docker images vorher: $(docker images -q | wc -l)"
T0=$(now); echo "T0 $(ts) UTC docker run mastercontainer"
docker run -d \
--init \
--sig-proxy=false \
--name nextcloud-aio-mastercontainer \
--restart always \
--publish 80:80 \
--publish 8080:8080 \
--publish 8443:8443 \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
ghcr.io/nextcloud-releases/all-in-one:latest >/dev/null
echo "docker run returned after $(el $T0 $(now)) s"
while :; do c=$(curl -sk -o /dev/null -m 2 -w '%{http_code}' https://localhost:8080/); case $c in 2*|3*) break;; esac; sleep 0.5; done
echo "AIO interface https://<ip>:8080 answers HTTP $c after $(el $T0 $(now)) s ($(ts) UTC)"
echo $T0 > /root/ep19fs/T0

View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# OpenCloud, offizielles Compose (opencloud-compose, Weg "Default Setup with Traefik" ohne Collabora).
# Aufruf: oc-install.sh DOMAIN (Admin-Passwort aus /root/ep19fs/secrets: OC_ADMIN_PW)
source /root/ep19fs/lib.sh; source /root/ep19fs/secrets
D=$1; cd /root
git clone -q https://github.com/opencloud-eu/opencloud-compose.git && cd opencloud-compose && git log -1 --format='compose repo commit %h %cs'
cp .env.example .env
# Änderungen laut offizieller Anleitung (docs.opencloud.eu, Default Setup with Traefik):
sed -i 's/^INSECURE=true/# INSECURE=true/' .env
sed -i "s/^OC_DOMAIN=.*/OC_DOMAIN=$D/" .env
sed -i "s/^TRAEFIK_ACME_MAIL=.*/TRAEFIK_ACME_MAIL=you@your-real-domain.tld/" .env
sed -i "s/^INITIAL_ADMIN_PASSWORD=.*/INITIAL_ADMIN_PASSWORD=$OC_ADMIN_PW/" .env
echo 'COMPOSE_FILE=docker-compose.yml:traefik/opencloud.yml' >> .env
echo "geänderte Zeilen gegenüber .env.example: $(diff .env.example .env | grep -c '^>')"
T0=$(now); echo "T0 $(ts) UTC docker compose up -d"
docker compose up -d 2>&1 | tail -3
echo "compose up returned after $(el $T0 $(now)) s"
echo $T0 > /root/ep19fs/T0
# Warten bis die Admin-Anmeldung am eingebauten IdP klappt (gleicher Aufruf wie das Anmeldeformular)
U=https://$D; last=""
while :; do
r=$(curl -s -m 5 -o /tmp/oclogon -w '%{http_code}' -X POST "$U/signin/v1/identifier/_/logon" -H 'Content-Type: application/json' -H 'Kopano-Konnect-XSRF: 1' -H "Referer: $U/signin/v1/identifier" -H "Origin: $U" \
-d "{\"params\":[\"admin\",\"$OC_ADMIN_PW\",\"1\"],\"hello\":{\"scope\":\"openid profile email\",\"client_id\":\"web\",\"redirect_uri\":\"$U/oidc-callback.html\",\"flow\":\"oidc\"}}")
[ "$r" != "$last" ] && echo " $(ts) +$(el $T0 $(now)) s logon HTTP $r" && last=$r
grep -q '"success":true' /tmp/oclogon 2>/dev/null && break; sleep 1; done
echo "Erste erfolgreiche Admin-Anmeldung nach $(el $T0 $(now)) s ($(ts) UTC)"
curl -s -o /dev/null -w "Zertifikat gültig: ssl_verify_result=%{ssl_verify_result}\n" $U/
docker compose ps --format '{{.Name}} {{.Image}} {{.Status}}'

View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# sampler.sh start NAME | stop NAME : Host-CPU% und RAM im 1-s-Takt während eines Laufs, Zusammenfassung bei stop
D=/root/ep19fs/load; mkdir -p $D
case $1 in
start) nohup python3 - "$D/$2.tsv" "$D/$2.stop" >/dev/null 2>&1 <<'PY' &
import sys,time,os
out=open(sys.argv[1],'w'); stop=sys.argv[2]
def cpu():
v=list(map(int,open('/proc/stat').readline().split()[1:])); return sum(v), v[3]+v[4]
def mem():
d={l.split(':')[0]:int(l.split()[1]) for l in open('/proc/meminfo')}; return (d['MemTotal']-d['MemAvailable'])/1024
a=cpu()
while not os.path.exists(stop):
time.sleep(1); b=cpu(); t=b[0]-a[0]; i=b[1]-a[1]; a=b
out.write(f"{time.strftime('%H:%M:%S',time.gmtime())}\t{100*(t-i)/max(t,1):.1f}\t{mem():.0f}\n"); out.flush()
PY
;;
stop) touch $D/$2.stop; sleep 1.5; python3 - "$D/$2.tsv" <<'PY'
import sys
r=[l.split('\t') for l in open(sys.argv[1]) if l.strip()]
c=[float(x[1]) for x in r]; m=[float(x[2]) for x in r]
print(f"server load: {len(r)} samples, CPU mean {sum(c)/len(c):.1f} %, CPU max {max(c):.1f} % (2 vCPU = 100 %), RAM used mean {sum(m)/len(m):.0f} MiB, max {max(m):.0f} MiB")
PY
;;
esac

View file

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Seafile CE 13.0, offizielles Compose laut manual.seafile.com/latest (= 13.0).
# Aufruf: sf-install.sh DOMAIN. Nur die als "required" markierten Felder werden gesetzt.
source /root/ep19fs/lib.sh; source /root/ep19fs/secrets
D=$1; mkdir -p /opt/seafile && cd /opt/seafile
wget -q -O .env https://manual.seafile.com/13.0/repo/docker/ce/env
wget -q https://manual.seafile.com/13.0/repo/docker/ce/seafile-server.yml
wget -q https://manual.seafile.com/13.0/repo/docker/seadoc.yml
wget -q https://manual.seafile.com/13.0/repo/docker/caddy.yml
cp .env env.orig
sed -i "s/^SEAFILE_SERVER_HOSTNAME=.*/SEAFILE_SERVER_HOSTNAME=$D/" .env
sed -i "s/^SEAFILE_SERVER_PROTOCOL=.*/SEAFILE_SERVER_PROTOCOL=https/" .env
sed -i "s/^JWT_PRIVATE_KEY=.*/JWT_PRIVATE_KEY=$SF_JWT/" .env
echo "geänderte Zeilen gegenüber der offiziellen .env: $(diff env.orig .env | grep -c '^>')"
grep -E '^(INIT_SEAFILE_ADMIN_EMAIL|INIT_SEAFILE_ADMIN_PASSWORD|SEAFILE_MYSQL_DB_PASSWORD|INIT_SEAFILE_MYSQL_ROOT_PASSWORD|ENABLE_NOTIFICATION_SERVER|ENABLE_SEADOC|SEAFILE_IMAGE)=' .env
T0=$(now); echo "T0 $(ts) UTC docker compose up -d"
docker compose up -d 2>&1 | tail -3
echo "compose up returned after $(el $T0 $(now)) s"
echo $T0 > /root/ep19fs/T0
# Warten bis die Anmeldung mit den Werten aus der offiziellen .env klappt (INIT_SEAFILE_ADMIN_EMAIL/PASSWORD, unverändert)
U=https://$D; last=""
AE=$(grep ^INIT_SEAFILE_ADMIN_EMAIL= .env | cut -d= -f2); AP=$(grep ^INIT_SEAFILE_ADMIN_PASSWORD= .env | cut -d= -f2)
while :; do
r=$(curl -s -m 5 -o /tmp/sflogon -w '%{http_code}' -d "username=$AE" -d "password=$AP" "$U/api2/auth-token/")
[ "$r" != "$last" ] && echo " $(ts) +$(el $T0 $(now)) s POST /api2/auth-token/ HTTP $r" && last=$r
grep -q '"token"' /tmp/sflogon 2>/dev/null && break; sleep 1; done
echo "Erste erfolgreiche Admin-Anmeldung mit me@example.com / asecret nach $(el $T0 $(now)) s ($(ts) UTC)"
curl -s -o /dev/null -w "Zertifikat gültig: ssl_verify_result=%{ssl_verify_result}\n" $U/
docker compose ps --format '{{.Name}} {{.Image}} {{.Status}}'