summaryrefslogtreecommitdiff
path: root/www/c-icap/files/pkg-install.in
blob: cfae02ee8292cf8fe062455b83301f5ba918f742 (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
#!/bin/sh
# $FreeBSD$

DEST_DIR=${PKG_DESTDIR:-}

CICAP_USER=cicap
CICAP_GROUP=cicap

LOG_DIR=$DEST_DIR%%LOG_DIR%%
TMP_DIR=$DEST_DIR%%TMP_DIR%%
RUN_DIR=$DEST_DIR%%RUN_DIR%%

if [ "$2" = "PRE-INSTALL" ]; then
	if ! pw groupshow "$CICAP_GROUP" 2>/dev/null 1>&2; then
		if pw groupadd $CICAP_GROUP; then
			echo "=> Added group \"$CICAP_GROUP\"."
		else
			echo "=> Adding group \"$CICAP_GROUP\" failed..."
			exit 1
		fi
	fi

	if ! pw usershow "$CICAP_USER" 2>/dev/null 1>&2; then
		if pw useradd $CICAP_USER -g $CICAP_GROUP -h - \
			-s "/sbin/nologin" -d "/nonexistent" \
			-c "c-icap daemon"; \
		then
			echo "=> Added user \"$CICAP_USER\"."
		else
			echo "=> Adding user \"$CICAP_USER\" failed..."
			exit 1
		fi
	fi
elif [ "$2" = "POST-INSTALL" ]; then
	if [ ! -d "$LOG_DIR" ]; then 
		mkdir -p "$LOG_DIR" || exit 1
		touch "$LOG_DIR/access.log" "$LOG_DIR/server.log" || exit 1
		chown -R "$CICAP_USER:$CICAP_GROUP" "$LOG_DIR" || exit 1
	fi

	if [ ! -d "$TMP_DIR" ]; then
		mkdir -p "$TMP_DIR" || exit 1
		chown "$CICAP_USER:$CICAP_GROUP" "$TMP_DIR" || exit 1
	fi

	if [ ! -d "$RUN_DIR" ]; then
		mkdir -p "$RUN_DIR" || exit 1
		chown "$CICAP_USER:$CICAP_GROUP" "$RUN_DIR" || exit 1
	fi
fi

exit 0