<commit_before>#!/bin/bash
set -euo pipefail
source /opt/hades/bin/functions.sh
load_config
mkdir -p /var/lib/hades

readonly -A users=(
	['agent']="$HADES_AGENT_USER"
	['auth-dhcp']="$HADES_AUTH_DNSMASQ_USER"
	['auth-dns']="$HADES_UNBOUND_USER"
	['auth-vrrp']='root'
	['database']="$HADES_POSTGRESQL_USER"
	['radius']="$HADES_RADIUS_USER"
	['radius-vrrp']='root'
	['unauth-dns']="$HADES_UNAUTH_DNSMASQ_USER"
	['unauth-http']="$HADES_PORTAL_USER"
	['unauth-portal']="$HADES_PORTAL_USER"
	['unauth-vrrp']='root'
)
readonly -A groups=(
	['agent']="$HADES_AGENT_GROUP"
	['auth-dhcp']="$HADES_AUTH_DNSMASQ_GROUP"
	['auth-dns']="$HADES_UNBOUND_GROUP"
	['auth-vrrp']='root'
	['database']="$HADES_POSTGRESQL_GROUP"
	['radius']="$HADES_RADIUS_GROUP"
	['radius-vrrp']='root'
	['unauth-dns']="$HADES_UNAUTH_DNSMASQ_GROUP"
	['unauth-http']="$HADES_PORTAL_GROUP"
	['unauth-portal']="$HADES_PORTAL_GROUP"
	['unauth-vrrp']='root'
)
addgroup --quiet --system "$HADES_SYSTEM_GROUP"
for service in "${!users[@]}"; do
	user="${users[$service]}"
	group="${groups[$service]}"
	if ! getent group "$group" &>/dev/null; then
		addgroup --quiet --system "$group"
	fi
	if ! getent passwd "$user" &>/dev/null; then
		adduser --quiet --system --home "/var/lib/hades/$service" --no-create-home --ingroup "$group" --disabled-password "$user"
	fi
	adduser --quiet "$user" "$HADES_SYSTEM_GROUP"
	install --directory --owner="$user" --group="$group" --mode=0755 "/var/lib/hades/$service"
done
<commit_msg>Check system group and directory creation<commit_after>#!/bin/bash
set -euo pipefail
source /opt/hades/bin/functions.sh
load_config

readonly -A users=(
	['agent']="$HADES_AGENT_USER"
	['auth-dhcp']="$HADES_AUTH_DNSMASQ_USER"
	['auth-dns']="$HADES_UNBOUND_USER"
	['auth-vrrp']='root'
	['database']="$HADES_POSTGRESQL_USER"
	['radius']="$HADES_RADIUS_USER"
	['radius-vrrp']='root'
	['unauth-dns']="$HADES_UNAUTH_DNSMASQ_USER"
	['unauth-http']="$HADES_PORTAL_USER"
	['unauth-portal']="$HADES_PORTAL_USER"
	['unauth-vrrp']='root'
)
readonly -A groups=(
	['agent']="$HADES_AGENT_GROUP"
	['auth-dhcp']="$HADES_AUTH_DNSMASQ_GROUP"
	['auth-dns']="$HADES_UNBOUND_GROUP"
	['auth-vrrp']='root'
	['database']="$HADES_POSTGRESQL_GROUP"
	['radius']="$HADES_RADIUS_GROUP"
	['radius-vrrp']='root'
	['unauth-dns']="$HADES_UNAUTH_DNSMASQ_GROUP"
	['unauth-http']="$HADES_PORTAL_GROUP"
	['unauth-portal']="$HADES_PORTAL_GROUP"
	['unauth-vrrp']='root'
)

if [[ ! -d /var/lib/hades ]]; then
	mkdir -p /var/lib/hades
fi

if ! getent group "$HADES_SYSTEM_GROUP" &>/dev/null; then
	addgroup --quiet --system "$HADES_SYSTEM_GROUP"
fi

for service in "${!users[@]}"; do
	user="${users[$service]}"
	group="${groups[$service]}"
	directory="/var/lib/hades/$service"
	if ! getent group "$group" &>/dev/null; then
		addgroup --quiet --system "$group"
	fi
	if ! getent passwd "$user" &>/dev/null; then
		adduser --quiet --system --home "$directory" --no-create-home --ingroup "$group" --disabled-password "$user"
	fi
	if [[ ! -d "$directory" ]]; then
		install --directory --owner="$user" --group="$group" --mode=0755 "$directory"
	fi
	adduser --quiet "$user" "$HADES_SYSTEM_GROUP"
done

{'fraction_non_alphanumeric': 0.22090792838874682, 'fraction_numerical': 0.0025575447570332483, 'mean_word_length': 6.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '2919559', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1331, 'n_words': 199}