Commit 4b79ab33 authored by Volodymyr Melnyk's avatar Volodymyr Melnyk

...

parent a348cbd2
......@@ -28,7 +28,11 @@ function _log {
;;
esac
shift
echo "[$(date +%F\ %T)]" $* | tee -a "${_log_file}" >&3
local log_dir="$(dirname "${_log_file}")"
if [[ ! -z "${log_dir}" && -d "${log_dir}" && -w "${log_dir}" ]]; then
echo "[$(date +%F\ %T)]" $* >>"${_log_file}"
fi
echo $* >&3
}
function _warn {
......@@ -43,25 +47,25 @@ function _die {
function _lock_file_get_pid {
local lock_file="${1}"
if [[ -z "${lock_file}" ]]; then
_warn "Lock file isn't defined" >/dev/null 2>&1
_warn "Lock file isn't defined"
return 1
fi
if [[ ! -f "${lock_file}" ]]; then
_warn "Lock file ${lock_file} isn't present" >/dev/null 2>&1
# _warn "Lock file ${lock_file} isn't present" >/dev/null 2>&1
return 2
fi
local pid=$(cat "${lock_file}")
if [[ -z "${pid}" ]]; then
_warn "Can't read lock file ${lock_file}" >/dev/null 2>&1
_warn "Can't read lock file ${lock_file}"
return 2
fi
local pcmd=$(ps -o cmd= "${pid}")
if [[ -z "${pcmd}" ]]; then
_warn "Can't find process ${pid}, lock file ${lock_file} is stale" >/dev/null 2>&1
_warn "Can't find process ${pid}, lock file ${lock_file} is stale"
return 3
fi
if [[ "${pcmd}" != *"${_my_name}"* ]]; then
_warn "${pid} is running, but it doesn't look like ${_my_name}" >/dev/null 2>&1
_warn "${pid} is running, but it doesn't look like ${_my_name}"
return 4
fi
echo "${pid}"
......
......@@ -18,7 +18,7 @@ case "${centos_release}" in
syvinit_script='/etc/init.d/save_io_stats'
if [[ ! -f "${syvinit_script}" ]]; then
_log 1 "Installing System V init script"
cat "${_share_dir}/sysvinit/save_io_stats" >"${syvinit_script}"
install -o root -g wheel -m 0755 "${_share_dir}/sysvinit/save_io_stats" "${syvinit_script}"
fi
break
;;
......@@ -26,7 +26,7 @@ case "${centos_release}" in
systemd_service_config='/etc/systemd/system/save_io_stats.service'
if [[ ! -f "${systemd_service_config}" ]]; then
_log 1 "Installing systemd service configuration file"
cat "${_share_dir}/systemd/save_io_stats.service" >"${systemd_service_config}"
install -o root -g wheel -m 0755 "${_share_dir}/systemd/save_io_stats.service" "${systemd_service_config}"
fi
break
;;
......@@ -34,22 +34,17 @@ case "${centos_release}" in
_die "Can't install on this distro"
;;
esac
systemd_service_config='/etc/systemd/system/save_io_stats.service'
if [[ ! -f "${systemd_service_config}" ]]; then
_log 1 "Installing systemd service configuration file"
cat "${_share_dir}/systemd/save_io_stats.service" >"${systemd_service_config}"
fi
sudoers_config='/etc/sudoers.d/save_io_stats'
if [[ ! -f "${sudoers_config}" ]]; then
_log 1 "Installing sudoers configuration snippet"
cat "${_share_dir}/sudoers/save_io_stats" >"${sudoers_config}"
install -o root -g wheel -m 0644 "${_share_dir}/sudoers/save_io_stats" "${sudoers_config}"
fi
logrotate_config='/etc/logrotate.d/snmp_stats'
if [[ ! -f "${logrotate_config}" ]]; then
_log 1 "Installing logrotate configuration snippet"
cat "${_share_dir}/logrotate/snmp_stats" >"${logrotate_config}"
install -o root -g wheel -m 0644 "${_share_dir}/logrotate/snmp_stats" "${logrotate_config}"
fi
io_stats_lock_dir="${_lock_dir}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment