Merge pull request #463 from nextcloud/enh/459/only-one-session

make sure that only one session is active at a time
This commit is contained in:
Simon L 2022-04-06 15:27:41 +02:00 committed by GitHub
commit 94f0a799fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 0 deletions

View file

@ -86,10 +86,12 @@ RUN mkdir /var/log/supervisord; \
COPY Caddyfile / COPY Caddyfile /
COPY start.sh /usr/bin/ COPY start.sh /usr/bin/
COPY backup-time-file-watcher.sh / COPY backup-time-file-watcher.sh /
COPY session-deduplicator.sh /
COPY cron.sh / COPY cron.sh /
COPY supervisord.conf / COPY supervisord.conf /
RUN chmod +x /usr/bin/start.sh; \ RUN chmod +x /usr/bin/start.sh; \
chmod +x /cron.sh; \ chmod +x /cron.sh; \
chmod +x /session-deduplicator.sh; \
chmod +x /backup-time-file-watcher.sh chmod +x /backup-time-file-watcher.sh
USER root USER root

View file

@ -0,0 +1,23 @@
#!/bin/bash
while true; do
while "$(find "/mnt/docker-aio-config/session/" -mindepth 1 -exec grep "aio_authenticated|[a-z]:1" {} \; | wc -l)" -gt 1; do
unset SESSION_FILES
SESSION_FILES="$(find "/mnt/docker-aio-config/session/" -mindepth 1)"
unset SESSION_FILES_ARRAY
mapfile -t SESSION_FILES_ARRAY <<< "$SESSION_FILES"
for SESSION_FILE in "${SESSION_FILES_ARRAY[@]}"; do
if ! grep -q "aio_authenticated|[a-z]:1" "$SESSION_FILE"; then
rm "$SESSION_FILE"
fi
done
echo "Deleting duplicate sessions"
unset OLDEST_FILE
set -x
# shellcheck disable=SC2012
OLDEST_FILE="$(ls -t "/mnt/docker-aio-config/session/" | tail -1)"
rm "/mnt/docker-aio-config/session/$OLDEST_FILE"
set +x
done
sleep 5
done

View file

@ -35,3 +35,10 @@ stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0 stderr_logfile_maxbytes=0
command=/backup-time-file-watcher.sh command=/backup-time-file-watcher.sh
[program:session-deduplicator]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=/session-deduplicator.sh