blob: 9eec80ea70f9db32824a5eb5ad6aac8ab11ef187 (
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
|
#!/bin/sh
# $FreeBSD$
PATH=/bin:/usr/bin:/usr/sbin
USER="%%REDIS_USER%%"
USER_ID="%%REDIS_UID%%"
GROUP="%%REDIS_GROUP%%"
GROUP_ID="%%REDIS_GID%%"
RUNTIME_DIRS="%%REDIS_LOGDIR%% %%REDIS_DBDIR%% %%REDIS_RUNDIR%%"
case $2 in
PRE-INSTALL)
if [ `id -u` -ne 0 ]; then
echo; echo "You must be root to run this step!"; echo; echo
exit 1
fi
RES=`pw groupshow -n ${GROUP} 2>/dev/null`
if [ $? -eq 0 ]; then
echo "You already have a group \"${GROUP}\", so we will use it."
else
RES=`pw groupshow -g ${GROUP_ID} 2>/dev/null`
if [ $? -ne 0 ]; then
_GID="-g ${GROUP_ID}"
else
_GID=''
fi
if pw groupadd -n ${GROUP} ${_GID}; then
echo "Added group \"${GROUP}\"."
else
echo "Adding group \"${GROUP}\" failed..."
exit 1
fi
fi
RES=`id -u ${USER} 2>/dev/null`
if [ $? -ne 0 ]; then
RES=`id -un ${USER_ID} 2>/dev/null`
if [ $? -ne 0 ]; then
_UID="-u ${USER_ID}"
else
_UID=''
fi
if pw useradd -n ${USER} ${_UID} -g ${GROUP} \
-w no -s /usr/sbin/nologin; then
echo "Added user \"${USER}\"."
else
echo "Adding user \"${USER}\" failed..."
exit 1
fi
fi
;;
POST-INSTALL)
for DIR in ${RUNTIME_DIRS}; do
mkdir -p ${DIR}
chown -R ${USER}:${GROUP} ${DIR}
chmod -R 755 ${DIR}
done
;;
DEINSTALL)
if [ -z ${UPGRADE_PORT} ] ; then
echo
echo "If you do not intend to reinstall \"%%PORTNAME%%\" you should manually"
echo "remove user '${USER}' (uid='${USER_ID}') and group '${GROUP}' (gid='${USER_ID}')."
echo
echo "Also you may want to remove the no longer required directoris:"
echo ${RUNTIME_DIRS}
echo
fi
esac
|