| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/bin/sh
- set -e
- case "$1" in
- configure)
- # ── Create dedicated system user ──────────────────────────────────
- if ! getent passwd squidstats > /dev/null 2>&1; then
- adduser \
- --system \
- --group \
- --no-create-home \
- --home /var/lib/squidstats \
- --shell /usr/sbin/nologin \
- --gecos "SquidStats web application" \
- squidstats
- fi
- # Add to the proxy group so the service can read squid access logs
- if getent group proxy > /dev/null 2>&1; then
- usermod -aG proxy squidstats 2>/dev/null || true
- fi
- # ── Runtime directories ───────────────────────────────────────────
- install -d -m 0750 -o squidstats -g squidstats /var/log/squidstats
- install -d -m 0750 -o squidstats -g squidstats /var/lib/squidstats
- # ── Configuration file ────────────────────────────────────────────
- # On first install the example config is the real config; protect it
- if [ -f /etc/squidstats/squidstats.env ]; then
- chown root:squidstats /etc/squidstats/squidstats.env
- chmod 0640 /etc/squidstats/squidstats.env
- fi
- # ── Create Python virtualenv on the target system ────────────────
- if [ ! -d /opt/SquidStats/venv ]; then
- python3 -m venv /opt/SquidStats/venv
- /opt/SquidStats/venv/bin/python3 -m pip install --upgrade pip setuptools wheel
- /opt/SquidStats/venv/bin/pip install --no-cache-dir -r /opt/SquidStats/app/requirements.txt
- fi
- # ── Application directory ownership ──────────────────────────────
- # The app code is owned by root; only the venv needs to be readable
- chown -R root:squidstats /opt/SquidStats/
- chmod -R o-rwx /opt/SquidStats/
- # Allow the service user to write to the data directory
- chown -R squidstats:squidstats /var/lib/squidstats/
- ;;
- esac
- #DEBHELPER#
- exit 0
|