32 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
set -eu
# Ensure ubt user and group exist
if ! getent group ubt >/dev/null 2>&1; then
addgroup --system ubt 2>/dev/null || addgroup ubt 2>/dev/null || true
fi
if ! getent passwd ubt >/dev/null 2>&1; then
adduser --system --ingroup ubt --home /home/ubt --shell /bin/bash ubt 2>/dev/null || \
adduser --disabled-password --gecos "" --ingroup ubt --home /home/ubt ubt 2>/dev/null || \
useradd -m -s /bin/bash -g ubt ubt 2>/dev/null || true
fi
# Ensure user directories exist with correct permissions
install -d -o ubt -g ubt -m 0755 /home/ubt
install -d -o ubt -g ubt -m 0755 /home/ubt/.local
install -d -o ubt -g ubt -m 0755 /home/ubt/.local/share
install -d -o ubt -g ubt -m 0755 /home/ubt/.local/share/drosync
install -d -o ubt -g ubt -m 0755 /home/ubt/.config
install -d -o ubt -g ubt -m 0755 /home/ubt/.config/drosync
# Initialization is performed only by `drosync auth` and `mapping add`.
# Existing token/configuration files are preserved, but no longer auto-imported.
if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload || true
if [ -f /run/drosync-install/was-running ]; then
systemctl restart drosync.service
rm -f /run/drosync-install/was-running
fi
fi