From 16652aaf02b9a2a0b07c621a3b55fe99606d1b4c Mon Sep 17 00:00:00 2001 From: Lorenzo Affetti Date: Mon, 15 Apr 2019 11:14:38 +0200 Subject: [PATCH] fix(package): make rpm verify pass after installation --- etc/build.py | 6 ++++++ etc/scripts/post-install.sh | 18 +++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/etc/build.py b/etc/build.py index 38215b96cc..9fbfbcf912 100755 --- a/etc/build.py +++ b/etc/build.py @@ -18,6 +18,8 @@ # Packaging variables PACKAGE_NAME = "chronograf" +USER = "chronograf" +GROUP = "chronograf" INSTALL_ROOT_DIR = "/usr/bin" LOG_DIR = "/var/log/chronograf" DATA_DIR = "/var/lib/chronograf" @@ -61,6 +63,8 @@ --maintainer {} \ --directories {} \ --directories {} \ +--rpm-attr 755,{},{}:{} \ +--rpm-attr 755,{},{}:{} \ --description \"{}\"".format( VENDOR, PACKAGE_URL, @@ -70,6 +74,8 @@ MAINTAINER, LOG_DIR, DATA_DIR, + USER, GROUP, LOG_DIR, + USER, GROUP, DATA_DIR, DESCRIPTION) for f in CONFIGURATION_FILES: diff --git a/etc/scripts/post-install.sh b/etc/scripts/post-install.sh index 0d570c53b8..99e64349b8 100644 --- a/etc/scripts/post-install.sh +++ b/etc/scripts/post-install.sh @@ -33,13 +33,6 @@ if [[ $? -ne 0 ]]; then useradd --system -U -M chronograf -s /bin/false -d $DATA_DIR fi -test -d $LOG_DIR || mkdir -p $DATA_DIR -test -d $DATA_DIR || mkdir -p $DATA_DIR -chown -R -L chronograf:chronograf $LOG_DIR -chown -R -L chronograf:chronograf $DATA_DIR -chmod 755 $LOG_DIR -chmod 755 $DATA_DIR - # Remove legacy symlink, if it exists if [[ -L /etc/init.d/chronograf ]]; then rm -f /etc/init.d/chronograf @@ -63,6 +56,17 @@ if [[ -f /etc/redhat-release ]]; then fi elif [[ -f /etc/debian_version ]]; then # Debian/Ubuntu logic + + # Ownership for RH-based platforms is set in build.py via the `rmp-attr` option. + # We perform ownership change only for Debian-based systems. + # Moving these lines out of this if statement would make `rmp -V` fail after installation. + test -d $LOG_DIR || mkdir -p $DATA_DIR + test -d $DATA_DIR || mkdir -p $DATA_DIR + chown -R -L chronograf:chronograf $LOG_DIR + chown -R -L chronograf:chronograf $DATA_DIR + chmod 755 $LOG_DIR + chmod 755 $DATA_DIR + which systemctl &>/dev/null if [[ $? -eq 0 ]]; then install_systemd