Skip to content

Commit

Permalink
fix: create /var/lib/kafka-streams directory on RPM installation (#6126)
Browse files Browse the repository at this point in the history
  • Loading branch information
spena committed Sep 14, 2020
1 parent 6c9486b commit 31ed3d3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
45 changes: 24 additions & 21 deletions debian/confluent-ksqldb.postinst
Expand Up @@ -10,33 +10,36 @@ case "$1" in
(getent group $_group 2>&1 >/dev/null) || addgroup --quiet --system $_group
adduser --system --disabled-password --disabled-login --home /var/empty \
--no-create-home --quiet --force-badname --ingroup $_group $_user

# Set explicit kafka-streams directory if not set
ksqldb_config=/etc/ksqldb/ksql-server.properties
if [ -f $ksqldb_config ]; then
if ! grep '^state.dir=' $ksqldb_config >/dev/null 2>&1; then
echo "state.dir=/var/lib/kafka-streams" >> $ksqldb_config
fi
fi

_permwarn=
for dir in /var/log/confluent ; do
if [ $dir = /var/log/confluent ]; then
# Confluent log directory should be writable by group
for dir in /var/log/confluent /var/lib/kafka-streams ; do
# Confluent log and kafka-streams directories should be writable by group
_perm="chown ${_user}:${_group} $dir && chmod u+wx,g+wx,o= $dir"
else
# Other dirs are only readable by group
_perm="chown ${_user}:${_group} $dir && chmod u+wx,g+r,o= $dir"
fi

if [ ! -d $dir ]; then
echo "Creating directory $dir with owner $_user:$_group"
mkdir -p $dir
eval $_perm
else
echo "Notice: Not creating existing directory $dir, ensure proper permissions for user $_user group $_group"
_permwarn="${_permwarn}${_perm}\n"
fi

if [ ! -d $dir ]; then
echo "Creating directory $dir with owner $_user:$_group"
mkdir -p $dir
eval $_perm
else
echo "Notice: Not creating existing directory $dir, ensure proper permissions for user $_user group $_group"
_permwarn="${_permwarn}${_perm}\n"
fi
done

if [ -n "$_permwarn" ]; then
echo "Notice: If you are planning to use the provided systemd service units for"
echo "Notice: confluent-ksql, make sure that read-write permissions"
echo "Notice: for user $_user and group $_group are set up according to the"
echo "Notice: following commands:"
/bin/echo -e "$_permwarn"
echo "Notice: If you are planning to use the provided systemd service units for"
echo "Notice: confluent-ksql, make sure that read-write permissions"
echo "Notice: for user $_user and group $_group are set up according to the"
echo "Notice: following commands:"
/bin/echo -e "$_permwarn"
fi
;;
esac
Expand Down
20 changes: 12 additions & 8 deletions debian/confluent-ksqldb.spec.in
Expand Up @@ -27,16 +27,19 @@ _group=confluent
getent group $_group 2>&1 >/dev/null || groupadd -r $_group
getent passwd $_user 2>&1 >/dev/null || \
useradd -r -g $_group --home-dir /tmp --no-create-home -s /sbin/nologin -c "Confluent KSQL" $_user

# Set explicit kafka-streams directory if not set
ksqldb_config=/etc/ksqldb/ksql-server.properties
if [ -f $ksqldb_config ]; then
if ! grep '^state.dir=' $ksqldb_config >/dev/null 2>&1; then
echo "state.dir=/var/lib/kafka-streams" >> $ksqldb_config
fi
fi

_permwarn=
for dir in /var/log/confluent ; do
if [ $dir = /var/log/confluent ]; then
# Confluent log directory should be writable by group
_perm="chown ${_user}:${_group} $dir && chmod u+wx,g+wx,o= $dir"
else
# Other dirs are only readable by group
_perm="chown ${_user}:${_group} $dir && chmod u+wx,g+r,o= $dir"
fi
for dir in /var/log/confluent /var/lib/kafka-streams ; do
# Confluent log and kafka-streams directories should be writable by group
_perm="chown ${_user}:${_group} $dir && chmod u+wx,g+wx,o= $dir"

if [ ! -d $dir ]; then
echo "Creating directory $dir with owner $_user:$_group"
Expand Down Expand Up @@ -79,6 +82,7 @@ fi
%{__rm} %{buildroot}/confluent-ksqldb.spec

%{__mkdir_p} %{buildroot}/var/log/confluent
%{__mkdir_p} %{buildroot}/var/lib/kafka-streams


%files
Expand Down

0 comments on commit 31ed3d3

Please sign in to comment.