Files
TTSDream/lan-ups/desktop/deploy/linux/postinst
T

24 lines
830 B
Bash

#!/bin/sh
set -eu
[ "${1:-}" = configure ] || exit 0
data=/etc/LanUps
token=$data/agent.token
group=lanups-operators
install -d -m 0755 -o root -g root "$data"
getent group "$group" >/dev/null || groupadd --system "$group"
if [ ! -f "$token" ]; then LANUPS_AGENT_TOKEN="$token" /opt/lanups/agent/LanUps.Agent --provision; fi
chown root:"$group" "$token"
chmod 0640 "$token"
operator=${SUDO_USER:-}
if [ -z "$operator" ] || [ "$operator" = root ]; then operator=$(getent passwd 1000 | cut -d: -f1); fi
if [ -n "$operator" ] && [ "$(id -u "$operator")" -ge 1000 ]; then usermod -a -G "$group" "$operator"; fi
if command -v systemctl >/dev/null; then
systemctl enable lanups-agent.service
if [ -d /run/systemd/system ]; then
systemctl daemon-reload
deb-systemd-invoke restart lanups-agent.service
fi
fi