mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Move from adduser to user add and slightly fix postinst script
This commit is contained in:
parent
05a36ec05c
commit
44625faa1f
7
debian/clickhouse-server.init
vendored
7
debian/clickhouse-server.init
vendored
@ -22,13 +22,14 @@ CLICKHOUSE_DATADIR_OLD=/opt/clickhouse
|
||||
CLICKHOUSE_DATADIR=/var/lib/clickhouse
|
||||
if [ -d "/var/lock" ]; then
|
||||
LOCALSTATEDIR=/var/lock
|
||||
else
|
||||
if [ -d "/var/run" ]; then
|
||||
LOCALSTATEDIR=/var/run
|
||||
else
|
||||
LOCALSTATEDIR=/run/lock
|
||||
fi
|
||||
|
||||
if [ ! -d "$LOCALSTATEDIR" ]; then
|
||||
mkdir -p "$LOCALSTATEDIR"
|
||||
fi
|
||||
|
||||
CLICKHOUSE_BINDIR=/usr/bin
|
||||
CLICKHOUSE_CRONFILE=/etc/cron.d/clickhouse-server
|
||||
CLICKHOUSE_CONFIG=$CLICKHOUSE_CONFDIR/config.xml
|
||||
|
20
debian/clickhouse-server.postinst
vendored
20
debian/clickhouse-server.postinst
vendored
@ -13,19 +13,14 @@ 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 ||:`}
|
||||
[ -z "$OS" ] && [ -f /etc/os-release ] && . /etc/os-release && OS=$ID
|
||||
[ -z "$OS" ] && [ -f /etc/centos-release ] && OS=centos
|
||||
[ -z "$OS" ] && OS=`uname -s ||:`
|
||||
|
||||
[ -f /usr/share/debconf/confmodule ] && . /usr/share/debconf/confmodule
|
||||
[ -f /etc/default/clickhouse ] && . /etc/default/clickhouse
|
||||
|
||||
if [ "$OS" = "rhel" ] || [ "$OS" = "centos" ] || [ "$OS" = "fedora" ] || [ "$OS" = "CentOS" ] || [ "$OS" = "Fedora" ] || [ "$OS" = "ol" ]; then
|
||||
is_rh=1
|
||||
if [ ! -f "/etc/debian_version" ]; then
|
||||
not_deb_os=1
|
||||
fi
|
||||
|
||||
if [ "$1" = configure ] || [ -n "$is_rh" ]; then
|
||||
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
|
||||
@ -48,9 +43,8 @@ if [ "$1" = configure ] || [ -n "$is_rh" ]; then
|
||||
|
||||
# Make sure the administrative user exists
|
||||
if ! getent passwd ${CLICKHOUSE_USER} > /dev/null; then
|
||||
if [ -n "$is_rh" ]; then
|
||||
adduser --system --no-create-home --home /nonexistent \
|
||||
--shell /bin/false ${CLICKHOUSE_USER} > /dev/null
|
||||
if [ -n "$not_deb_os" ]; then
|
||||
useradd -r -s /bin/false --home-dir /nonexistent ${CLICKHOUSE_USER} > /dev/null
|
||||
else
|
||||
adduser --system --disabled-login --no-create-home --home /nonexistent \
|
||||
--shell /bin/false --group --gecos "ClickHouse server" ${CLICKHOUSE_USER} > /dev/null
|
||||
@ -59,12 +53,12 @@ if [ "$1" = configure ] || [ -n "$is_rh" ]; then
|
||||
|
||||
# if the user was created manually, make sure the group is there as well
|
||||
if ! getent group ${CLICKHOUSE_GROUP} > /dev/null; then
|
||||
addgroup --system ${CLICKHOUSE_GROUP} > /dev/null
|
||||
groupadd -r ${CLICKHOUSE_GROUP} > /dev/null
|
||||
fi
|
||||
|
||||
# make sure user is in the correct group
|
||||
if ! id -Gn ${CLICKHOUSE_USER} | grep -qw ${CLICKHOUSE_USER}; then
|
||||
adduser ${CLICKHOUSE_USER} ${CLICKHOUSE_GROUP} > /dev/null
|
||||
usermod -a -G ${CLICKHOUSE_GROUP} ${CLICKHOUSE_USER} > /dev/null
|
||||
fi
|
||||
|
||||
# check validity of user and group
|
||||
|
Loading…
Reference in New Issue
Block a user