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

fix(package): set rpm user and group to create files with correct owner #2186

Merged
merged 1 commit into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved lines here to preserve previous behavior in non REHL distros.


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