diff --git a/Containers/mastercontainer/session-deduplicator.sh b/Containers/mastercontainer/session-deduplicator.sh index 4326090a..796ccb54 100644 --- a/Containers/mastercontainer/session-deduplicator.sh +++ b/Containers/mastercontainer/session-deduplicator.sh @@ -2,15 +2,18 @@ while true; do while [ "$(find "/mnt/docker-aio-config/session/" -mindepth 1 -exec grep "aio_authenticated|[a-z]:1" {} \; | wc -l)" -gt 1 ]; do + # First delete all session files that are not authenticated 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 + if [ -f "$SESSION_FILE" ] && ! grep -q "aio_authenticated|[a-z]:1" "$SESSION_FILE"; then rm "$SESSION_FILE" fi done + + # Second clean up all sessions that are authenticated echo "Deleting duplicate sessions" unset OLDEST_FILE set -x