2016-02-07 20:02:44 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2017-01-09 13:42:29 +00:00
|
|
|
if [ "$1" = configure ]; then
|
|
|
|
|
|
|
|
if [ -x "/etc/init.d/clickhouse-server" ]; then
|
|
|
|
update-rc.d clickhouse-server defaults 19 19 >/dev/null || exit $?
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure the administrative user exists
|
|
|
|
if ! getent passwd metrika > /dev/null; then
|
|
|
|
adduser --system --disabled-login --no-create-home --home /nonexistent \
|
|
|
|
--shell /bin/false --group --gecos "Clickhouse server" metrika > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
# if the user was created manually, make sure the group is there as well
|
|
|
|
if ! getent group metrika > /dev/null; then
|
|
|
|
addgroup --system metrika > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
# make sure user is in the correct group
|
|
|
|
if ! id -Gn metrika | grep -qw metrika; then
|
|
|
|
adduser metrika metrika > /dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check validity of user and group
|
|
|
|
if [ "`id -u metrika`" -eq 0 ]; then
|
|
|
|
echo "The metrika system user must not have uid 0 (root).
|
|
|
|
Please fix this and reinstall this package." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "`id -g metrika`" -eq 0 ]; then
|
|
|
|
echo "The metrika system user must not have root as primary group.
|
|
|
|
Please fix this and reinstall this package." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-02-07 20:02:44 +00:00
|
|
|
|
2017-01-09 13:42:29 +00:00
|
|
|
if [ ! -d "/opt/clickhouse" ]; then
|
|
|
|
# ensure home directory ownership
|
|
|
|
mkdir -p /opt/clickhouse
|
|
|
|
#su -s /bin/sh metrika -c "test -O /opt/clickhouse && test -G /opt/clickhouse" || \
|
|
|
|
chown metrika:metrika /opt/clickhouse
|
|
|
|
chmod 0700 /opt/clickhouse
|
|
|
|
fi
|
2016-02-07 20:02:44 +00:00
|
|
|
|
2016-11-14 21:58:17 +00:00
|
|
|
# Clean old dynamic compilation results
|
2016-02-07 20:02:44 +00:00
|
|
|
if [ -d "/opt/clickhouse/build" ]; then
|
|
|
|
rm -f /opt/clickhouse/build/*.cpp /opt/clickhouse/build/*.so ||:
|
|
|
|
fi
|
2017-01-09 13:42:29 +00:00
|
|
|
|
2016-02-07 20:02:44 +00:00
|
|
|
fi
|
|
|
|
|
2017-01-09 13:42:29 +00:00
|
|
|
|
2016-02-07 20:02:44 +00:00
|
|
|
exit 0
|