Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions debian/clickhouse-client.postinst
Expand Up @@ -4,3 +4,5 @@ set -e
CLICKHOUSE_USER=${CLICKHOUSE_USER=clickhouse}

mkdir -p /etc/clickhouse-client/conf.d

#DEBHELPER#
1 change: 0 additions & 1 deletion debian/clickhouse-server-base.postinst

This file was deleted.

1 change: 0 additions & 1 deletion debian/clickhouse-server-base.preinst

This file was deleted.

1 change: 0 additions & 1 deletion debian/clickhouse-server-base.prerm

This file was deleted.

1 change: 0 additions & 1 deletion debian/clickhouse-server-base.service

This file was deleted.

1 change: 0 additions & 1 deletion debian/clickhouse-server-metrika.links

This file was deleted.

16 changes: 16 additions & 0 deletions debian/clickhouse-server.config
@@ -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
16 changes: 15 additions & 1 deletion debian/clickhouse-server.postinst
Expand Up @@ -11,9 +11,10 @@ CLICKHOUSE_GENERIC_PROGRAM=${CLICKHOUSE_GENERIC_PROGRAM:=clickhouse}
EXTRACT_FROM_CONFIG=${CLICKHOUSE_GENERIC_PROGRAM}-extract-from-config
CLICKHOUSE_CONFIG=$CLICKHOUSE_CONFDIR/config.xml


OS=${OS=`lsb_release -is 2>/dev/null || uname -s ||:`}

. /usr/share/debconf/confmodule

test -f /etc/default/clickhouse && . /etc/default/clickhouse

if [ "$1" = configure ]; then
Expand Down Expand Up @@ -84,6 +85,8 @@ Please fix this and reinstall this package." >&2
fi

if [ -d ${CLICKHOUSE_CONFDIR} ]; then
mkdir -p ${CLICKHOUSE_CONFDIR}/users.d
mkdir -p ${CLICKHOUSE_CONFDIR}/config.d
rm -fv ${CLICKHOUSE_CONFDIR}/*-preprocessed.xml ||:
fi

Expand Down Expand Up @@ -119,4 +122,15 @@ Please fix this and reinstall this package." >&2
if [ -d "${CLICKHOUSE_DATADIR_FROM_CONFIG}/build" ]; then
rm -f ${CLICKHOUSE_DATADIR_FROM_CONFIG}/build/*.cpp ${CLICKHOUSE_DATADIR_FROM_CONFIG}/build/*.so ||:
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
proller marked this conversation as resolved.
Show resolved Hide resolved
fi

# everything went well, so now let's reset the password
db_set clickhouse-server/default-password ""
# ... done with debconf here
db_stop
fi
2 changes: 2 additions & 0 deletions debian/clickhouse-server.preinst
Expand Up @@ -4,3 +4,5 @@ if [ "$1" = "upgrade" ]; then
# Return etc/cron.d/clickhouse-server to original state
service clickhouse-server disable_cron ||:
fi

#DEBHELPER#
3 changes: 3 additions & 0 deletions debian/clickhouse-server.templates
@@ -0,0 +1,3 @@
Template: clickhouse-server/default-password
Type: password
Description: Password for default user.
16 changes: 0 additions & 16 deletions debian/control
Expand Up @@ -63,19 +63,3 @@ Priority: optional
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, clickhouse-client, bash, expect, python, python-lxml, python-termcolor, python-requests, curl, perl, sudo, openssl, netcat-openbsd, telnet, brotli
Description: ClickHouse tests



# TODO: Remove:

Package: clickhouse-server-base
Architecture: any
Priority: optional
Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, tzdata
Description: DEPRECATED PACKAGE (use clickhouse-common-static): Server binary for clickhouse

Package: clickhouse-server-common
Architecture: all
Priority: optional
Depends: ${shlibs:Depends}, ${misc:Depends}, clickhouse-server-base (= ${binary:Version})
Description: DEPRECATED PACKAGE (use clickhouse-server): Common configuration files for clickhouse-server-base package
6 changes: 3 additions & 3 deletions debian/rules
Expand Up @@ -123,9 +123,9 @@ override_dh_install:
touch $(DESTDIR)/etc/clickhouse-server/metrika/users.xml

# todo: remove after removing clickhouse-server-base package:
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.cron.d $(DESTDIR)/etc/cron.d/clickhouse-server
#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.cron.d $(DESTDIR)/etc/cron.d/clickhouse-server

dh_install --list-missing --sourcedir=$(DESTDIR)

Expand Down