summaryrefslogtreecommitdiff
path: root/manualPorts/bareos-filedaemon/post-install
blob: 8fb8ecec47ed7105068a7b1f6b492eb612d31fe8 (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
47
48
#!/bin/sh

# based on tor/pre-install

GROUP=bareos
USER=bareos
USER_COMMENT="BAREOS Daemon"
USER_HOME=/
USER_SHELL=/bin/false

if [ ! $(id -u) = 0 ]; then
	echo "ERROR: you need to be root to run this!"
	exit 1
fi

if [ $GROUP ];	then
	if ! getent group $GROUP > /dev/null; then
		/usr/sbin/groupadd $GROUP
		if [ $? -eq 0 ]; then
			echo "Group: $GROUP added."
		fi
	else
		echo "Group: $GROUP already exists! Skipping."
	fi
fi
	
if ! getent passwd $USER > /dev/null; then
	/usr/sbin/useradd -g $GROUP -c "$USER_COMMENT" -d $USER_HOME -s $USER_SHELL -m $USER
	if [ $? -eq 0 ]; then
		echo "User: $USER added."
		/usr/bin/passwd -l $USER > /dev/null
		if [ $? -eq 0 ]; then
			echo "Locked: $USER account."
		fi
		else
			echo "ERROR: unable to lock $USER account."
			/usr/sbin/userdel $USER
	fi
	else
		echo "User: $USER already exists! Skipping."
fi

# now the bareos-specific stuff

/usr/lib/bareos/scripts/bareos-config initialize_local_hostname
/usr/lib/bareos/scripts/bareos-config initialize_passwords

chown -R bareos:bareos /etc/bareos