Skip to content

Commit

Permalink
Merge pull request #2186 from influxdata/la-ear716
Browse files Browse the repository at this point in the history
fix(package): set rpm user and group to create files with correct owner
  • Loading branch information
nathanielc authored Apr 9, 2019
2 parents 75949d8 + 1542dff commit 5d7471c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- [#2167](https://github.com/influxdata/kapacitor/pull/2167): Use default transport consistently.
- [#2144](https://github.com/influxdata/kapacitor/issues/2144): Fix deadlock in barrier node when delete is used.
- [#2186](https://github.com/influxdata/kapacitor/pull/2186): Make RPM create files with correct ownership on install.

## v1.5.2 [2018-12-12]

Expand Down
21 changes: 13 additions & 8 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/python2.7 -u

import sys
import argparse
import hashlib
import logging
import os
import subprocess
import time
from datetime import datetime
import re
import shutil
import subprocess
import sys
import tempfile
import hashlib
import re
import logging
import argparse
from datetime import datetime

################
#### Kapacitor Variables
Expand All @@ -21,6 +20,8 @@

# PACKAGING VARIABLES
PACKAGE_NAME = "kapacitor"
USER = "kapacitor"
GROUP = "kapacitor"
INSTALL_ROOT_DIR = "/usr/bin"
LOG_DIR = "/var/log/kapacitor"
DATA_DIR = "/var/lib/kapacitor"
Expand Down Expand Up @@ -60,6 +61,8 @@
--config-files {} \
--config-files {} \
--directories {} \
--rpm-attr 755,{},{}:{} \
--rpm-attr 755,{},{}:{} \
--description \"{}\"".format(
VENDOR,
PACKAGE_URL,
Expand All @@ -76,6 +79,8 @@
os.path.dirname(SCRIPT_DIR[1:]),
os.path.dirname(DEFAULT_CONFIG),
]),
USER, GROUP, LOG_DIR,
USER, GROUP, DATA_DIR,
DESCRIPTION)

targets = {
Expand Down
50 changes: 26 additions & 24 deletions scripts/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ if ! id kapacitor >/dev/null 2>&1; then
fi
chmod a+rX $BIN_DIR/kapacitor*

mkdir -p $LOG_DIR
chown -R -L kapacitor:kapacitor $LOG_DIR
mkdir -p $DATA_DIR
chown -R -L kapacitor:kapacitor $DATA_DIR

test -f /etc/default/kapacitor || touch /etc/default/kapacitor

# Distribution-specific logic
Expand All @@ -49,26 +44,33 @@ if [[ -f /etc/redhat-release ]]; then
install_init
# Do not enable service
fi
elif [[ -f /etc/debian_version ]]; then
# Debian/Ubuntu logic
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
install_systemd
enable_systemd
else
# Assuming SysV
install_init
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
enable_update_rcd
else
mkdir -p $LOG_DIR
chown -R -L kapacitor:kapacitor $LOG_DIR
mkdir -p $DATA_DIR
chown -R -L kapacitor:kapacitor $DATA_DIR

if [[ -f /etc/debian_version ]]; then
# Debian/Ubuntu logic
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then
install_systemd
enable_systemd
else
enable_chkconfig
# Assuming SysV
install_init
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
enable_update_rcd
else
enable_chkconfig
fi
fi
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID = "amzn" ]]; then
# Amazon Linux logic
install_init
# Do not enable service
fi
fi
elif [[ -f /etc/os-release ]]; then
source /etc/os-release
if [[ $ID = "amzn" ]]; then
# Amazon Linux logic
install_init
# Do not enable service
fi
fi

0 comments on commit 5d7471c

Please sign in to comment.