icinga-redis-tools.postinst 617 Bytes
Newer Older
Noah Hilverling's avatar
Noah Hilverling committed
1 2 3 4
#!/bin/sh

set -eu

5
USER="icinga-redis"
Noah Hilverling's avatar
Noah Hilverling committed
6 7 8 9 10 11 12 13 14

Setup_dir () {
	DIR="${1}"
	MODE="${2}"
	GROUP="${3}"

	mkdir -p ${DIR}

	case "${DIR}" in
15
	/var/log/icinga-redis)
Noah Hilverling's avatar
Noah Hilverling committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
		MODE="02750"
		GROUP="adm"
		;;
	*)
		MODE="750"
		GROUP="${USER}"
		;;
	esac

	if ! dpkg-statoverride --list ${DIR} >/dev/null 2>&1
	then
		chown ${USER}:${GROUP} ${DIR}
		chmod ${MODE} ${DIR}
	fi
}

if [ "$1" = "configure" ]
then
	adduser \
		--system \
36
		--home /var/lib/icinga-redis \
Noah Hilverling's avatar
Noah Hilverling committed
37 38 39 40
		--quiet \
		--group \
		${USER} || true

41 42
	Setup_dir /var/log/icinga-redis ${USER}:adm 2750
	Setup_dir /var/lib/icinga-redis ${USER}:${USER} 750
Noah Hilverling's avatar
Noah Hilverling committed
43 44 45 46 47
fi

#DEBHELPER#

exit 0