Debian: Asking password for default user on package install (#4725)

This commit is contained in:
proller 2019-03-20 22:57:50 +03:00 committed by GitHub
parent 412737bacf
commit 9f1c89729a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 42 additions and 9 deletions

View File

@ -4,3 +4,5 @@ set -e
CLICKHOUSE_USER=${CLICKHOUSE_USER=clickhouse} CLICKHOUSE_USER=${CLICKHOUSE_USER=clickhouse}
mkdir -p /etc/clickhouse-client/conf.d mkdir -p /etc/clickhouse-client/conf.d
#DEBHELPER#

View File

@ -1 +0,0 @@
clickhouse-server.postinst

View File

@ -1 +0,0 @@
clickhouse-server.preinst

View File

@ -1 +0,0 @@
clickhouse-server.prerm

View File

@ -1 +0,0 @@
clickhouse-server.service

View File

@ -1 +0,0 @@
usr/bin/clickhouse usr/bin/clickhouse-server

16
debian/clickhouse-server.config vendored Normal file
View File

@ -0,0 +1,16 @@
#!/bin/sh -e
. /usr/share/debconf/confmodule
db_fget clickhouse-server/default-password seen || true
password_seen="$RET"
if [ "$1" = "reconfigure" ]; then
password_seen=false
fi
if [ "$password_seen" != "true" ]; then
db_input high clickhouse-server/default-password || true
db_go || true
fi
db_go || true

View File

@ -11,9 +11,10 @@ CLICKHOUSE_GENERIC_PROGRAM=${CLICKHOUSE_GENERIC_PROGRAM:=clickhouse}
EXTRACT_FROM_CONFIG=${CLICKHOUSE_GENERIC_PROGRAM}-extract-from-config EXTRACT_FROM_CONFIG=${CLICKHOUSE_GENERIC_PROGRAM}-extract-from-config
CLICKHOUSE_CONFIG=$CLICKHOUSE_CONFDIR/config.xml CLICKHOUSE_CONFIG=$CLICKHOUSE_CONFDIR/config.xml
OS=${OS=`lsb_release -is 2>/dev/null || uname -s ||:`} OS=${OS=`lsb_release -is 2>/dev/null || uname -s ||:`}
. /usr/share/debconf/confmodule
test -f /etc/default/clickhouse && . /etc/default/clickhouse test -f /etc/default/clickhouse && . /etc/default/clickhouse
if [ "$1" = configure ]; then if [ "$1" = configure ]; then
@ -84,6 +85,8 @@ Please fix this and reinstall this package." >&2
fi fi
if [ -d ${CLICKHOUSE_CONFDIR} ]; then if [ -d ${CLICKHOUSE_CONFDIR} ]; then
mkdir -p ${CLICKHOUSE_CONFDIR}/users.d
mkdir -p ${CLICKHOUSE_CONFDIR}/config.d
rm -fv ${CLICKHOUSE_CONFDIR}/*-preprocessed.xml ||: rm -fv ${CLICKHOUSE_CONFDIR}/*-preprocessed.xml ||:
fi fi
@ -119,4 +122,15 @@ Please fix this and reinstall this package." >&2
if [ -d "${CLICKHOUSE_DATADIR_FROM_CONFIG}/build" ]; then if [ -d "${CLICKHOUSE_DATADIR_FROM_CONFIG}/build" ]; then
rm -f ${CLICKHOUSE_DATADIR_FROM_CONFIG}/build/*.cpp ${CLICKHOUSE_DATADIR_FROM_CONFIG}/build/*.so ||: rm -f ${CLICKHOUSE_DATADIR_FROM_CONFIG}/build/*.cpp ${CLICKHOUSE_DATADIR_FROM_CONFIG}/build/*.so ||:
fi fi
db_get clickhouse-server/default-password
defaultpassword="$RET"
if [ -n "$defaultpassword" ]; then
echo "<yandex><users><default><password>$defaultpassword</password></default></users></yandex>" > ${CLICKHOUSE_CONFDIR}/users.d/default-password.xml
fi
# everything went well, so now let's reset the password
db_set clickhouse-server/default-password ""
# ... done with debconf here
db_stop
fi fi

View File

@ -4,3 +4,5 @@ if [ "$1" = "upgrade" ]; then
# Return etc/cron.d/clickhouse-server to original state # Return etc/cron.d/clickhouse-server to original state
service clickhouse-server disable_cron ||: service clickhouse-server disable_cron ||:
fi fi
#DEBHELPER#

3
debian/clickhouse-server.templates vendored Normal file
View File

@ -0,0 +1,3 @@
Template: clickhouse-server/default-password
Type: password
Description: Password for default user.

6
debian/rules vendored
View File

@ -123,9 +123,9 @@ override_dh_install:
touch $(DESTDIR)/etc/clickhouse-server/metrika/users.xml touch $(DESTDIR)/etc/clickhouse-server/metrika/users.xml
# todo: remove after removing clickhouse-server-base package: # todo: remove after removing clickhouse-server-base package:
mkdir -p $(DESTDIR)/etc/init.d $(DESTDIR)/etc/cron.d #mkdir -p $(DESTDIR)/etc/init.d $(DESTDIR)/etc/cron.d
cp debian/clickhouse-server.init $(DESTDIR)/etc/init.d/clickhouse-server #cp debian/clickhouse-server.init $(DESTDIR)/etc/init.d/clickhouse-server
cp debian/clickhouse-server.cron.d $(DESTDIR)/etc/cron.d/clickhouse-server #cp debian/clickhouse-server.cron.d $(DESTDIR)/etc/cron.d/clickhouse-server
dh_install --list-missing --sourcedir=$(DESTDIR) dh_install --list-missing --sourcedir=$(DESTDIR)