-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathpreinst
executable file
·61 lines (51 loc) · 1.55 KB
/
preinst
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
#!/bin/bash -e
#
# This script is executed in the pre-installation phase
#
# On Debian,
# $1=install : indicates an new install
# $1=upgrade : indicates an upgrade
#
# Sets the default values for Okapi variables
OKAPI_USER="okapi"
OKAPI_GROUP="okapi"
DATA_DIR="/var/lib/okapi"
# Source the default env file
OKAPI_ENV_FILE="/etc/default/okapi"
if [ -f "$OKAPI_ENV_FILE" ]; then
. "$OKAPI_ENV_FILE"
fi
case "$1" in
install|upgrade)
# Create okapi group if not existing
if ! getent group "$OKAPI_GROUP" > /dev/null 2>&1 ; then
echo -n "Creating $OKAPI_GROUP group..."
addgroup --quiet --system "$OKAPI_GROUP"
echo " OK"
fi
# Create okapi user if not existing
if ! id "$OKAPI_USER" > /dev/null 2>&1 ; then
echo -n "Creating $OKAPI_USER user..."
adduser --quiet \
--system \
--home "$DATA_DIR" \
--ingroup "$OKAPI_GROUP" \
--disabled-password \
--shell /bin/false \
"$OKAPI_USER"
echo " OK"
fi
# Create DATA_DIR on reinstall because package removal removes DATA_DIR but not OKAPI_USER
if [ ! -e "$DATA_DIR" ] ; then
mkdir -m 750 "$DATA_DIR"
chown "${OKAPI_USER}.${OKAPI_GROUP}" "$DATA_DIR"
fi
;;
abort-deconfigure|abort-upgrade|abort-remove)
;;
*)
echo "pre install script called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0