forked from saahn/kafka-deb-packaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinst
68 lines (55 loc) · 1.71 KB
/
postinst
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
#!/bin/sh
# postinst script for kafka
# based on script for sensu: https://github.com/sensu/sensu-build/blob/master/pkg_scripts/deb/postinst
set -e
# summary of how this script can be called and ordering:
# http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
# http://www.proulx.com/~bob/debian/hints/DpkgScriptOrder
create_kafka_user_group() {
# create kafka group
if ! getent group kafka >/dev/null; then
groupadd -r kafka
fi
# create kafka user
if ! getent passwd kafka >/dev/null; then
useradd -r -g kafka -d /usr/lib/kafka \
-s /bin/false -c "Kafka service user" kafka
fi
}
create_zookeeper_user_group() {
# create kafka group
if ! getent group zookeeper >/dev/null; then
groupadd -r zookeeper
fi
# create kafka user
if ! getent passwd zookeeper >/dev/null; then
useradd -r -g zookeeper -d /usr/lib/kafka \
-s /bin/false -c "Zookeeper service user" zookeeper
fi
}
chown_kafka_dirs() {
chown kafka:kafka /etc/kafka
chown kafka:kafka /var/log/kafka
chown -R kafka:kafka /var/run/kafka
chown -R kafka:kafka /usr/lib/kafka
}
chown_zookeeper_scripts() {
chown zookeeper:zookeeper /usr/lib/kafka/bin/zookeeper-server-start.sh
chown zookeeper:zookeeper /usr/lib/kafka/bin/zookeeper-server-stop.sh
chown zookeeper:zookeeper /usr/lib/kafka/bin/zookeeper-shell.sh
}
case "$1" in
configure)
create_kafka_user_group
chown_kafka_dirs
create_zookeeper_user_group
chown_zookeeper_scripts
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0