aboutsummaryrefslogtreecommitdiff
path: root/net/boinc-client/files/pkg-install.in
blob: 3144a686791e7c760c7005a4876c6f149bb71812 (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD:$
#

PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin

user=%%BOINC_CLIENT_USER%%
group=%%BOINC_CLIENT_GROUP%%
home="%%BOINC_CLIENT_HOME%%"
shell=/bin/sh

case $2 in
PRE-INSTALL)
	if ! pw usershow ${user} 2>/dev/null 1>&2; then
		if ! pw useradd ${user} -g ${group} -c "BOINC client user" \
		    -d "${home}" -s ${shell}; then
			echo "Failed to create user \"${user}\"." >&2
			exit 1
		else
			echo "User \"${user}\" created successfully:"
		fi
	else
		echo "Using existent user \"${user}\":"
	fi
	pw usershow ${user}
	mkdir -m u=rwx,go= -p "${home}"
	if [ ! -e "${home}/skins" -a ! -L "${home}/skins" ]; then
		ln -s "%%PREFIX%%/share/boinc/skins" "${home}/skins"
	fi
	if [ ! -e "${home}/ca-bundle.crt" -a ! -L "${home}/ca-bundle.crt" ]; then
		ln -s "%%LOCALBASE%%/share/certs/ca-root-nss.crt" "${home}/ca-bundle.crt"
	fi
	echo "Adjusting file ownership in \"${home}\" to ${user}:${group}"
	chown -hR ${user}:${group} "${home}"
	;;
esac

exit 0