提交 6d9ba524 编写于 作者: P proller

Debian init and cron fixes

上级 37f90345
...@@ -6,6 +6,7 @@ CLICKHOUSE_GROUP=${CLICKHOUSE_USER} ...@@ -6,6 +6,7 @@ CLICKHOUSE_GROUP=${CLICKHOUSE_USER}
CLICKHOUSE_DATADIR=/var/lib/clickhouse CLICKHOUSE_DATADIR=/var/lib/clickhouse
CLICKHOUSE_LOGDIR=/var/log/clickhouse-server CLICKHOUSE_LOGDIR=/var/log/clickhouse-server
test -f /etc/default/clickhouse && . /etc/default/clickhouse
if [ "$1" = configure ]; then if [ "$1" = configure ]; then
if [ -x "/bin/systemctl" ] && [ -f /etc/systemd/system/clickhouse-server.service ] && [ -d /run/systemd/system ]; then if [ -x "/bin/systemctl" ] && [ -f /etc/systemd/system/clickhouse-server.service ] && [ -d /run/systemd/system ]; then
......
#*/10 * * * * root (which service > /dev/null && (service clickhouse-server condstart || true)) || /etc/init.d/clickhouse-server condstart 1>/dev/null 2>&1 #*/10 * * * * root (which service > /dev/null 2>&1 && (service clickhouse-server condstart || true)) || /etc/init.d/clickhouse-server condstart > /dev/null 2>&1
...@@ -14,6 +14,7 @@ CLICKHOUSE_GROUP=${CLICKHOUSE_USER} ...@@ -14,6 +14,7 @@ CLICKHOUSE_GROUP=${CLICKHOUSE_USER}
SHELL=/bin/bash SHELL=/bin/bash
PROGRAM=clickhouse-server PROGRAM=clickhouse-server
GENERIC_PROGRAM=clickhouse GENERIC_PROGRAM=clickhouse
EXTRACT_FROM_CONFIG=${GENERIC_PROGRAM}-extract-from-config
SYSCONFDIR=/etc/$PROGRAM SYSCONFDIR=/etc/$PROGRAM
CLICKHOUSE_LOGDIR=/var/log/clickhouse-server CLICKHOUSE_LOGDIR=/var/log/clickhouse-server
CLICKHOUSE_LOGDIR_USER=root CLICKHOUSE_LOGDIR_USER=root
...@@ -87,8 +88,8 @@ die() ...@@ -87,8 +88,8 @@ die()
# Check that configuration file is Ok. # Check that configuration file is Ok.
check_config() check_config()
{ {
if [ -x "$BINDIR/$GENERIC_PROGRAM" ]; then if [ -x "$BINDIR/$EXTRACT_FROM_CONFIG" ]; then
su -s $SHELL ${CLICKHOUSE_USER} -c "$BINDIR/$GENERIC_PROGRAM extract-from-config --config-file=\"$CLICKHOUSE_CONFIG\" --key=path" >/dev/null || die "Configuration file ${CLICKHOUSE_CONFIG} doesn't parse successfully. Won't restart server. You may use forcerestart if you are sure."; su -s $SHELL ${CLICKHOUSE_USER} -c "$BINDIR/$EXTRACT_FROM_CONFIG --config-file=\"$CLICKHOUSE_CONFIG\" --key=path" >/dev/null || die "Configuration file ${CLICKHOUSE_CONFIG} doesn't parse successfully. Won't restart server. You may use forcerestart if you are sure.";
fi fi
} }
...@@ -99,8 +100,8 @@ initdb() ...@@ -99,8 +100,8 @@ initdb()
su -s /bin/sh ${CLICKHOUSE_USER} -c "test -w ${SYSCONFDIR}" || chown ${CLICKHOUSE_USER}:${CLICKHOUSE_GROUP} ${SYSCONFDIR} su -s /bin/sh ${CLICKHOUSE_USER} -c "test -w ${SYSCONFDIR}" || chown ${CLICKHOUSE_USER}:${CLICKHOUSE_GROUP} ${SYSCONFDIR}
fi fi
if [ -x "$BINDIR/$GENERIC_PROGRAM" ]; then if [ -x "$BINDIR/$EXTRACT_FROM_CONFIG" ]; then
CLICKHOUSE_DATADIR_FROM_CONFIG=$(su -s $SHELL ${CLICKHOUSE_USER} -c "$BINDIR/$GENERIC_PROGRAM extract-from-config --config-file=\"$CLICKHOUSE_CONFIG\" --key=path") CLICKHOUSE_DATADIR_FROM_CONFIG=$(su -s $SHELL ${CLICKHOUSE_USER} -c "$BINDIR/$EXTRACT_FROM_CONFIG --config-file=\"$CLICKHOUSE_CONFIG\" --key=path")
if [ "(" "$?" -ne "0" ")" -o "(" -z "${CLICKHOUSE_DATADIR_FROM_CONFIG}" ")" ]; then if [ "(" "$?" -ne "0" ")" -o "(" -z "${CLICKHOUSE_DATADIR_FROM_CONFIG}" ")" ]; then
die "Cannot obtain value of path from config file: ${CLICKHOUSE_CONFIG}"; die "Cannot obtain value of path from config file: ${CLICKHOUSE_CONFIG}";
fi fi
...@@ -231,22 +232,34 @@ forcerestart() ...@@ -231,22 +232,34 @@ forcerestart()
start start
} }
use_cron()
{
# 1. running systemd
if [ -x "/bin/systemctl" ] && [ -f /etc/systemd/system/clickhouse-server.service ] && [ -d /run/systemd/system ]; then
return 1
fi
# 2. disabled by config
if [ -z "$CLICKHOUSE_CRONFILE" ]; then
return 2
fi
return 0
}
enable_cron() enable_cron()
{ {
[ ! -z "$CLICKHOUSE_CRONFILE" ] && sed -i 's/^#*//' "$CLICKHOUSE_CRONFILE" use_cron && sed -i 's/^#*//' "$CLICKHOUSE_CRONFILE"
} }
disable_cron() disable_cron()
{ {
[ ! -z "$CLICKHOUSE_CRONFILE" ] && sed -i 's/^#*/#/' "$CLICKHOUSE_CRONFILE" use_cron && sed -i 's/^#*/#/' "$CLICKHOUSE_CRONFILE"
} }
is_cron_disabled() is_cron_disabled()
{ {
[ -z "$CLICKHOUSE_CRONFILE" ] && return 0 use_cron || return 0
# Assumes that either no lines are commented or all lines are commented. # Assumes that either no lines are commented or all lines are commented.
# Also please note, that currently cron file for ClickHouse has only one line (but some time ago there was more). # Also please note, that currently cron file for ClickHouse has only one line (but some time ago there was more).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册