mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
48 lines
2.3 KiB
Bash
48 lines
2.3 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
# set -x
|
|
|
|
PROGRAM=clickhouse-server
|
|
CLICKHOUSE_USER=${CLICKHOUSE_USER:=clickhouse}
|
|
CLICKHOUSE_GROUP=${CLICKHOUSE_GROUP:=${CLICKHOUSE_USER}}
|
|
# Please note that we don't support paths with whitespaces. This is rather ignorant.
|
|
CLICKHOUSE_CONFDIR=${CLICKHOUSE_CONFDIR:=/etc/clickhouse-server}
|
|
CLICKHOUSE_DATADIR=${CLICKHOUSE_DATADIR:=/var/lib/clickhouse}
|
|
CLICKHOUSE_LOGDIR=${CLICKHOUSE_LOGDIR:=/var/log/clickhouse-server}
|
|
CLICKHOUSE_BINDIR=${CLICKHOUSE_BINDIR:=/usr/bin}
|
|
CLICKHOUSE_GENERIC_PROGRAM=${CLICKHOUSE_GENERIC_PROGRAM:=clickhouse}
|
|
EXTRACT_FROM_CONFIG=${CLICKHOUSE_GENERIC_PROGRAM}-extract-from-config
|
|
CLICKHOUSE_CONFIG=$CLICKHOUSE_CONFDIR/config.xml
|
|
CLICKHOUSE_PIDDIR=/var/run/$PROGRAM
|
|
|
|
[ -f /usr/share/debconf/confmodule ] && . /usr/share/debconf/confmodule
|
|
[ -f /etc/default/clickhouse ] && . /etc/default/clickhouse
|
|
|
|
if [ ! -f "/etc/debian_version" ]; then
|
|
not_deb_os=1
|
|
fi
|
|
|
|
if [ "$1" = configure ] || [ -n "$not_deb_os" ]; then
|
|
if [ -x "/bin/systemctl" ] && [ -f /etc/systemd/system/clickhouse-server.service ] && [ -d /run/systemd/system ]; then
|
|
# if old rc.d service present - remove it
|
|
if [ -x "/etc/init.d/clickhouse-server" ] && [ -x "/usr/sbin/update-rc.d" ]; then
|
|
/usr/sbin/update-rc.d clickhouse-server remove
|
|
echo "ClickHouse init script has migrated to systemd. Please manually stop old server and restart the service: sudo killall clickhouse-server && sleep 5 && sudo service clickhouse-server restart"
|
|
fi
|
|
|
|
/bin/systemctl daemon-reload
|
|
/bin/systemctl enable clickhouse-server
|
|
else
|
|
# If you downgrading to version older than 1.1.54336 run: systemctl disable clickhouse-server
|
|
if [ -x "/etc/init.d/clickhouse-server" ]; then
|
|
if [ -x "/usr/sbin/update-rc.d" ]; then
|
|
/usr/sbin/update-rc.d clickhouse-server defaults 19 19 >/dev/null || exit $?
|
|
else
|
|
echo # TODO [ "$OS" = "rhel" ] || [ "$OS" = "centos" ] || [ "$OS" = "fedora" ]
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
${CLICKHOUSE_GENERIC_PROGRAM} install --user "${CLICKHOUSE_USER}" --group "${CLICKHOUSE_GROUP}" --pid-path "${CLICKHOUSE_PIDDIR}" --config-path "${CLICKHOUSE_CONFDIR}" --binary-path "${CLICKHOUSE_BINDIR}" --log-path "${CLICKHOUSE_LOGDIR}" --data-path "${CLICKHOUSE_DATADIR}"
|
|
fi
|