Skip to content

Commit

Permalink
netdata/packaging/ci: netdata#5935 - Make timeout usage more cross-di…
Browse files Browse the repository at this point in the history
…stro compliant
  • Loading branch information
Paul Emm. Katsoulakis committed Apr 30, 2019
1 parent cf5c6da commit bf292ea
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion collectors/charts.d.plugin/charts.d.plugin.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ debug() {
[ $debug -eq 1 ] && log DEBUG "${@}"
}

os_version() {
OS_VERSION="unknown"
OS_FILE="/etc/os-release"
info "Detecting OS version"

[ -f ${OS_FILE} ] && OS_VERSION=$(cat ${OS_FILE} | grep '^ID=' | sed -e 's/ID=//g')

info "Detected OS version: ${OS_VERSION}"
echo ${OS_VERSION}
}

# -----------------------------------------------------------------------------
# check a few commands

Expand Down Expand Up @@ -281,7 +292,14 @@ run() {
if [ "z${1}" = "z-t" -a "${2}" != "0" ]; then
t="${2}"
shift 2
timeout ${t} "${@}" 2>"${TMP_DIR}/run.${pid}"
case "$(os_version)" in
"alpine")
timeout -t ${t} "${@}" 2>"${TMP_DIR}/run.${pid}"
;;
*)
timeout ${t} "${@}" 2>"${TMP_DIR}/run.${pid}"
;;
esac
ret=$?
else
"${@}" 2>"${TMP_DIR}/run.${pid}"
Expand Down

0 comments on commit bf292ea

Please sign in to comment.