summaryrefslogtreecommitdiffstats
path: root/debian/cephadm.postinst
blob: 2ff4cf46080a5965e21da981319f7e1b85cb104e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

set -e

CEPHADM_HOME=/var/lib/cephadm

if [ "${1}" = "configure" ] || [ "${1}" = "reconfigure" ] ; then
	if ! getent group cephadm > /dev/null 2>&1 ; then
		addgroup --quiet --system cephadm ${ADDGROUP_PARAM}
	fi

	if ! getent passwd cephadm ; then
		echo -n "Adding system user cephadm..."
		adduser --system \
			--home /var/lib/cephadm \
			--no-create-home \
			--quiet \
			--disabled-password \
			--gecos 'cephadm user for mgr/cephadm' \
			--shell /bin/bash \
			--ingroup cephadm \
			cephadm 2>/dev/null || true
		echo "done"
	fi

	if [ ! -d ${CEPHADM_HOME} ] ; then
		mkdir -p ${CEPHADM_HOME}
	fi
	chown cephadm:cephadm ${CEPHADM_HOME}
	chmod 0755 ${CEPHADM_HOME}

	if ! [ -d ${CEPHADM_HOME}/.ssh ] ; then
		mkdir ${CEPHADM_HOME}/.ssh
		chown --reference ${CEPHADM_HOME} ${CEPHADM_HOME}/.ssh
		chmod 0700 ${CEPHADM_HOME}/.ssh
	fi
	if ! [ -e ${CEPHADM_HOME}/.ssh/authorized_keys ] ; then
		touch ${CEPHADM_HOME}/.ssh/authorized_keys
		chown --reference ${CEPHADM_HOME} ${CEPHADM_HOME}/.ssh/authorized_keys
		chmod 0600 ${CEPHADM_HOME}/.ssh/authorized_keys
	fi
fi

#DEBHELPER#

exit 0