summaryrefslogtreecommitdiff
path: root/security/sfs/pkg-install
blob: 631e08839f2056dddcf7ec18b41ede164526488d (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh

if [ -n "${PACKAGE_BUILDING}" ]; then
	exit 0
fi

if [ "$2" != "POST-INSTALL" ]; then
	exit 0
fi

KEYFILE="$PKG_PREFIX/etc/sfs/sfs_host_key"

USER=sfs
GROUP=sfs
UID=71
GID=71
PW=/usr/sbin/pw

SFSDIR=/var/spool/sfs

echo -n "Checking for group '$GROUP'... "

if ! ${PW} groupshow $GROUP >/dev/null 2>&1; then
	echo -n "doesn't exist, adding... "
	if ${PW} groupadd $GROUP -g ${GID}; then
		echo "success."
	else
		echo "FAILED!"
		exit 1
	fi
else
	echo "exists."
fi

echo -n "Checking for user '$USER'... "

if ! ${PW} usershow $USER >/dev/null 2>&1; then
	echo -n "doesn't exist, adding... "
	if ${PW} useradd $USER -u ${UID} -c 'Self-Certifying File System' -d /nonexistent -g $GROUP -s /sbin/nologin -h -; then
		echo "success."
	else
		echo "FAILED!"
		exit 1
	fi
else
	echo "exists."
fi

echo -n "Checking for SFS directory ($SFSDIR)... "

if [ -d "$SFSDIR" ]; then
	echo "already exists."
else
	echo -n "creating... "
	if mkdir $SFSDIR; then
		echo "success."
	else
		echo "FAILED!"
		exit 1
	fi
fi

if ! chmod 750 $SFSDIR; then
	echo "chmod 750 $SFSDIR FAILED!"
	exit 1
fi

if ! chown $USER:$GROUP $SFSDIR; then
	echo "chown $USER:$GROUP $SFSDIR FAILED!"
	exit 1
fi

echo -n "Checking for SFS host key ($KEYFILE)... "

if [ -f "$KEYFILE" ]; then
	echo "already exists, not generating."
else
	echo "doesn't exist, generating."
	echo "Starting sfscd for entropy services."
	$PKG_PREFIX/sbin/sfscd
	echo -n "Sleeping ten seconds to give sfscd time to start up... "
	sleep 10
	echo "done."
	$PKG_PREFIX/bin/sfskey gen -KP -n `uname -n` $KEYFILE
	echo -n "Key generation done, killing sfscd... "
	kill -TERM `cat /var/run/sfscd.pid`
	echo "done."
fi

cat $PKG_PREFIX/share/doc/sfs/WELCOME

exit 0