<commit_before>#!/bin/bash

# detect userid:groupid of contents of data folder
DATA_DIR="${DATA_DIR:-/data}"
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"

# Autodetect UID and GID of host user based on ownership of files in the volume
USID=$(stat --format="%u" "$DATA_DIR")
GRID=$(stat --format="%g" "$DATA_DIR")
COMMAND="$@"

# run django as the host user's uid:gid so that any files touched have the same permissions as outside the container
# e.g. ./manage.py runserver

chown "$USID":"$GRID" "$DATA_DIR"

if [[ "$USID" != 0 && "$GRID" != 0 ]]; then
    usermod -u $USID $ARCHIVEBOX_USER
    groupmod -g $GRID $ARCHIVEBOX_USER
    chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
fi
gosu $ARCHIVEBOX_USER bash -c "$COMMAND"
<commit_msg>shellcheck fixes<commit_after>#!/usr/bin/env bash

# detect userid:groupid of contents of data folder
DATA_DIR="${DATA_DIR:-/data}"
ARCHIVEBOX_USER="${ARCHIVEBOX_USER:-archivebox}"

# Autodetect UID and GID of host user based on ownership of files in the volume
USID=$(stat --format="%u" "$DATA_DIR")
GRID=$(stat --format="%g" "$DATA_DIR")
COMMAND="$*"

# run django as the host user's uid:gid so that any files touched have the same permissions as outside the container
# e.g. ./manage.py runserver

chown "$USID":"$GRID" "$DATA_DIR"

if [[ "$USID" != 0 && "$GRID" != 0 ]]; then
    usermod -u "$USID" "$ARCHIVEBOX_USER"
    groupmod -g "$GRID" "$ARCHIVEBOX_USER"
    chown -R "$USID":"$GRID" "/home/$ARCHIVEBOX_USER"
fi
gosu "$ARCHIVEBOX_USER" bash -c "$COMMAND"

{'fraction_non_alphanumeric': 0.16368455931080186, 'fraction_numerical': 0.0026507620941020544, 'mean_word_length': 4.8076923076923075, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3694469', 'n_tokens_mistral': 549, 'n_tokens_neox': 534, 'n_words': 166}