Force chown for log files before starting rabbitmq
For some reason log files /var/log/rabbitmq/startup_log and /var/log/rabbitmq/shutdown_log becomes owned be root, preventing rabbitmq-server for murano (launched from 'rabbitmq' user) from writing to them. Change-Id: Ifa3d3484e3f22fe97cdb747c2c58f2d408246f32 Closes-bug: #1360264
This commit is contained in:
parent
bddba1e854
commit
7dc0036f51
@ -22,7 +22,7 @@ DESC="Murano RabbitMQ Server"
|
||||
USER="rabbitmq"
|
||||
ROTATE_SUFFIX=".old"
|
||||
|
||||
export RABBITMQ_LOG_BASE="/var/log/rabbitmq-murano"
|
||||
export RABBITMQ_LOG_DIR="/var/log/rabbitmq"
|
||||
export RABBITMQ_PID_FILE="/var/run/rabbitmq-murano/pid"
|
||||
export RABBITMQ_CONFIG_FILE="/etc/rabbitmq/rabbitmq-murano"
|
||||
export RABBITMQ_MNESIA_BASE="/var/lib/rabbitmq/mnesia-murano"
|
||||
@ -45,134 +45,138 @@ RETVAL="0"
|
||||
[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}
|
||||
|
||||
check_dir () {
|
||||
mkdir -p "${1}"
|
||||
chown -R "${USER}:${USER}" "${1}"
|
||||
chmod "755" "${1}"
|
||||
mkdir -p "${1}"
|
||||
chown -R "${USER}:${USER}" "${1}"
|
||||
chmod "755" "${1}"
|
||||
}
|
||||
|
||||
ensure_dirs () {
|
||||
PID_DIR=`dirname ${RABBITMQ_PID_FILE}`
|
||||
check_dir "${PID_DIR}"
|
||||
check_dir "${RABBITMQ_LOG_BASE}"
|
||||
check_dir "${RABBITMQ_MNESIA_BASE}"
|
||||
PID_DIR=`dirname ${RABBITMQ_PID_FILE}`
|
||||
check_dir "${PID_DIR}"
|
||||
check_dir "${RABBITMQ_LOG_DIR}"
|
||||
check_dir "${RABBITMQ_LOG_BASE}"
|
||||
check_dir "${RABBITMQ_MNESIA_BASE}"
|
||||
}
|
||||
|
||||
remove_pid () {
|
||||
rm -f "${RABBITMQ_PID_FILE}"
|
||||
rm -f "${RABBITMQ_PID_FILE}"
|
||||
}
|
||||
|
||||
start_rabbitmq () {
|
||||
status_rabbitmq quiet
|
||||
status_rabbitmq quiet
|
||||
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
echo "Murano RabbitMQ is currently running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
echo "Murano RabbitMQ is currently running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
|
||||
ensure_dirs
|
||||
${START_PROG} "${DAEMON}" 1> "${RABBITMQ_LOG_BASE}/startup_log" 2> "${RABBITMQ_LOG_BASE}/startup_err" 0<&- &
|
||||
${CONTROL} wait "${RABBITMQ_PID_FILE}" 1> "/dev/null" 2>&1
|
||||
ensure_dirs
|
||||
${START_PROG} "${DAEMON}" 1> "${RABBITMQ_LOG_BASE}/startup_log" 2> "${RABBITMQ_LOG_BASE}/startup_err" 0<&- &
|
||||
${CONTROL} wait "${RABBITMQ_PID_FILE}" 1> "/dev/null" 2>&1
|
||||
RETVAL="${?}"
|
||||
|
||||
RETVAL="${?}"
|
||||
if [ "${RETVAL}" -gt "0" ]; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ start FAILED!"
|
||||
RETVAL="1"
|
||||
else
|
||||
echo "Murano RabbitMQ start SUCCESS!"
|
||||
if [ -n "${LOCK_FILE}" ]; then
|
||||
touch "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
fi
|
||||
if [ "${RETVAL}" -gt "0" ]; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ start FAILED!"
|
||||
RETVAL="1"
|
||||
else
|
||||
echo "Murano RabbitMQ start SUCCESS!"
|
||||
if [ -n "${LOCK_FILE}" ]; then
|
||||
touch "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_rabbitmq () {
|
||||
status_rabbitmq quiet
|
||||
status_rabbitmq quiet
|
||||
|
||||
if [ "${RETVAL}" != 0 ]; then
|
||||
echo "RabbitMQ is not running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
if [ "${RETVAL}" != 0 ]; then
|
||||
echo "RabbitMQ is not running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
|
||||
${CONTROL} stop "${RABBITMQ_PID_FILE}" > "${RABBITMQ_LOG_BASE}/shutdown_log" 2> "${RABBITMQ_LOG_BASE}/shutdown_err"
|
||||
${CONTROL} stop "${RABBITMQ_PID_FILE}" > "${RABBITMQ_LOG_BASE}/shutdown_log" 2> "${RABBITMQ_LOG_BASE}/shutdown_err"
|
||||
RETVAL="${?}"
|
||||
|
||||
RETVAL="${?}"
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ stop SUCCESS!"
|
||||
if [ -n "{$LOCK_FILE}" ] ; then
|
||||
rm -f "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
else
|
||||
echo "Murano RabbitMQ stop FAILED!"
|
||||
RETVAL="1"
|
||||
fi
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ stop SUCCESS!"
|
||||
if [ -n "{$LOCK_FILE}" ] ; then
|
||||
rm -f "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
else
|
||||
echo "Murano RabbitMQ stop FAILED!"
|
||||
RETVAL="1"
|
||||
fi
|
||||
}
|
||||
|
||||
status_rabbitmq () {
|
||||
if [ "${1}" != "quiet" ] ; then
|
||||
${CONTROL} status 2>&1
|
||||
else
|
||||
${CONTROL} status > /dev/null 2>&1
|
||||
fi
|
||||
if [ "${?}" != "0" ]; then
|
||||
RETVAL="3"
|
||||
fi
|
||||
if [ "${1}" != "quiet" ] ; then
|
||||
${CONTROL} status 2>&1
|
||||
else
|
||||
${CONTROL} status > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ "${?}" != "0" ]; then
|
||||
RETVAL="3"
|
||||
fi
|
||||
}
|
||||
|
||||
rotate_logs_rabbitmq () {
|
||||
${CONTROL} rotate_logs "${ROTATE_SUFFIX}"
|
||||
if [ $? != 0 ]; then
|
||||
RETVAL="1"
|
||||
fi
|
||||
${CONTROL} rotate_logs "${ROTATE_SUFFIX}"
|
||||
if [ $? != 0 ]; then
|
||||
RETVAL="1"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_running_rabbitmq () {
|
||||
status_rabbitmq quiet
|
||||
if [ "${RETVAL}" != "0" ]; then
|
||||
echo "RabbitMQ is not runnning!"
|
||||
exit 0
|
||||
fi
|
||||
restart_rabbitmq
|
||||
status_rabbitmq quiet
|
||||
|
||||
if [ "${RETVAL}" != "0" ]; then
|
||||
echo "RabbitMQ is not runnning!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
restart_rabbitmq
|
||||
}
|
||||
|
||||
restart_rabbitmq () {
|
||||
stop_rabbitmq
|
||||
start_rabbitmq
|
||||
stop_rabbitmq
|
||||
start_rabbitmq
|
||||
}
|
||||
|
||||
case "${1}" in
|
||||
start)
|
||||
echo "Starting $DESC"
|
||||
start_rabbitmq
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping $DESC"
|
||||
stop_rabbitmq
|
||||
;;
|
||||
status)
|
||||
status_rabbitmq
|
||||
;;
|
||||
rotate-logs)
|
||||
echo "Rotating log files for $DESC"
|
||||
rotate_logs_rabbitmq
|
||||
;;
|
||||
force-reload|reload|restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_rabbitmq
|
||||
;;
|
||||
try-restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_running_rabbitmq
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
start)
|
||||
echo "Starting $DESC"
|
||||
start_rabbitmq
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping $DESC"
|
||||
stop_rabbitmq
|
||||
;;
|
||||
status)
|
||||
status_rabbitmq
|
||||
;;
|
||||
rotate-logs)
|
||||
echo "Rotating log files for $DESC"
|
||||
rotate_logs_rabbitmq
|
||||
;;
|
||||
force-reload|reload|restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_rabbitmq
|
||||
;;
|
||||
try-restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_running_rabbitmq
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit "${RETVAL}"
|
||||
exit "${RETVAL}"
|
||||
|
@ -24,7 +24,7 @@ DESC="Murano RabbitMQ Server"
|
||||
USER="rabbitmq"
|
||||
ROTATE_SUFFIX=".old"
|
||||
|
||||
export RABBITMQ_LOG_BASE="/var/log/rabbitmq-murano"
|
||||
export RABBITMQ_LOG_DIR="/var/log/rabbitmq"
|
||||
export RABBITMQ_PID_FILE="/var/run/rabbitmq-murano/pid"
|
||||
export RABBITMQ_CONFIG_FILE="/etc/rabbitmq/rabbitmq-murano"
|
||||
export RABBITMQ_MNESIA_BASE="/var/lib/rabbitmq/mnesia-murano"
|
||||
@ -49,20 +49,21 @@ RETVAL="0"
|
||||
[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}
|
||||
|
||||
check_dir () {
|
||||
mkdir -p "${1}"
|
||||
chown -R "${USER}:${USER}" "${1}"
|
||||
chmod "755" "${1}"
|
||||
mkdir -p "${1}"
|
||||
chown -R "${USER}:${USER}" "${1}"
|
||||
chmod "755" "${1}"
|
||||
}
|
||||
|
||||
ensure_dirs () {
|
||||
PID_DIR=`dirname ${RABBITMQ_PID_FILE}`
|
||||
check_dir "${PID_DIR}"
|
||||
check_dir "${RABBITMQ_LOG_BASE}"
|
||||
check_dir "${RABBITMQ_MNESIA_BASE}"
|
||||
PID_DIR=`dirname ${RABBITMQ_PID_FILE}`
|
||||
check_dir "${PID_DIR}"
|
||||
check_dir "${RABBITMQ_LOG_DIR}"
|
||||
check_dir "${RABBITMQ_LOG_BASE}"
|
||||
check_dir "${RABBITMQ_MNESIA_BASE}"
|
||||
}
|
||||
|
||||
remove_pid () {
|
||||
rm -f "${RABBITMQ_PID_FILE}"
|
||||
rm -f "${RABBITMQ_PID_FILE}"
|
||||
}
|
||||
#####
|
||||
|
||||
@ -109,117 +110,122 @@ c_start_rabbitmq () {
|
||||
#####
|
||||
|
||||
start_rabbitmq () {
|
||||
status_rabbitmq quiet
|
||||
status_rabbitmq quiet
|
||||
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
echo "Murano RabbitMQ is currently running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
echo "Murano RabbitMQ is currently running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
|
||||
ensure_dirs
|
||||
start-stop-daemon --quiet --chuid rabbitmq --start --exec "${DAEMON}" --pidfile "${RABBITMQ_PID_FILE}" --background
|
||||
${CONTROL} wait "${RABBITMQ_PID_FILE}" 1> "/dev/null" 2>&1
|
||||
ensure_dirs
|
||||
start-stop-daemon --quiet --chuid rabbitmq \
|
||||
--start --exec "${DAEMON}" \
|
||||
--pidfile "${RABBITMQ_PID_FILE}" --background
|
||||
${CONTROL} wait "${RABBITMQ_PID_FILE}" 1> "/dev/null" 2>&1
|
||||
RETVAL="${?}"
|
||||
|
||||
RETVAL="${?}"
|
||||
if [ "${RETVAL}" -gt "0" ]; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ start FAILED!"
|
||||
RETVAL="1"
|
||||
else
|
||||
echo "Murano RabbitMQ start SUCCESS!"
|
||||
if [ -n "${LOCK_FILE}" ]; then
|
||||
touch "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
fi
|
||||
if [ "${RETVAL}" -gt "0" ]; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ start FAILED!"
|
||||
RETVAL="1"
|
||||
else
|
||||
echo "Murano RabbitMQ start SUCCESS!"
|
||||
if [ -n "${LOCK_FILE}" ]; then
|
||||
touch "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
fi
|
||||
}
|
||||
|
||||
stop_rabbitmq () {
|
||||
status_rabbitmq quiet
|
||||
status_rabbitmq quiet
|
||||
|
||||
if [ "${RETVAL}" != 0 ]; then
|
||||
echo "RabbitMQ is not running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
if [ "${RETVAL}" != 0 ]; then
|
||||
echo "RabbitMQ is not running!"
|
||||
RETVAL="0"
|
||||
return
|
||||
fi
|
||||
|
||||
${CONTROL} stop "${RABBITMQ_PID_FILE}" > "${RABBITMQ_LOG_BASE}/shutdown_log" 2> "${RABBITMQ_LOG_BASE}/shutdown_err"
|
||||
${CONTROL} stop "${RABBITMQ_PID_FILE}" > "${RABBITMQ_LOG_BASE}/shutdown_log" 2> "${RABBITMQ_LOG_BASE}/shutdown_err"
|
||||
RETVAL="${?}"
|
||||
|
||||
RETVAL="${?}"
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ stop SUCCESS!"
|
||||
if [ -n "{$LOCK_FILE}" ] ; then
|
||||
rm -f "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
else
|
||||
echo "Murano RabbitMQ stop FAILED!"
|
||||
RETVAL="1"
|
||||
fi
|
||||
if [ "${RETVAL}" = "0" ] ; then
|
||||
remove_pid
|
||||
echo "Murano RabbitMQ stop SUCCESS!"
|
||||
if [ -n "{$LOCK_FILE}" ] ; then
|
||||
rm -f "${LOCK_FILE}"
|
||||
fi
|
||||
RETVAL="0"
|
||||
else
|
||||
echo "Murano RabbitMQ stop FAILED!"
|
||||
RETVAL="1"
|
||||
fi
|
||||
}
|
||||
|
||||
status_rabbitmq () {
|
||||
if [ "${1}" != "quiet" ] ; then
|
||||
${CONTROL} status 2>&1
|
||||
else
|
||||
${CONTROL} status > /dev/null 2>&1
|
||||
fi
|
||||
if [ "${?}" != "0" ]; then
|
||||
RETVAL="3"
|
||||
fi
|
||||
if [ "${1}" != "quiet" ] ; then
|
||||
${CONTROL} status 2>&1
|
||||
else
|
||||
${CONTROL} status > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ "${?}" != "0" ]; then
|
||||
RETVAL="3"
|
||||
fi
|
||||
}
|
||||
|
||||
rotate_logs_rabbitmq () {
|
||||
${CONTROL} rotate_logs "${ROTATE_SUFFIX}"
|
||||
if [ $? != 0 ]; then
|
||||
RETVAL="1"
|
||||
fi
|
||||
${CONTROL} rotate_logs "${ROTATE_SUFFIX}"
|
||||
if [ $? != 0 ]; then
|
||||
RETVAL="1"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_running_rabbitmq () {
|
||||
status_rabbitmq quiet
|
||||
if [ "${RETVAL}" != "0" ]; then
|
||||
echo "RabbitMQ is not runnning!"
|
||||
exit 0
|
||||
fi
|
||||
restart_rabbitmq
|
||||
status_rabbitmq quiet
|
||||
|
||||
if [ "${RETVAL}" != "0" ]; then
|
||||
echo "RabbitMQ is not runnning!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
restart_rabbitmq
|
||||
}
|
||||
|
||||
restart_rabbitmq () {
|
||||
stop_rabbitmq
|
||||
start_rabbitmq
|
||||
stop_rabbitmq
|
||||
start_rabbitmq
|
||||
}
|
||||
|
||||
case "${1}" in
|
||||
start)
|
||||
echo "Starting $DESC"
|
||||
start_rabbitmq
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping $DESC"
|
||||
stop_rabbitmq
|
||||
;;
|
||||
status)
|
||||
status_rabbitmq
|
||||
;;
|
||||
rotate-logs)
|
||||
echo "Rotating log files for $DESC"
|
||||
rotate_logs_rabbitmq
|
||||
;;
|
||||
force-reload|reload|restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_rabbitmq
|
||||
;;
|
||||
try-restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_running_rabbitmq
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
start)
|
||||
echo "Starting $DESC"
|
||||
start_rabbitmq
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping $DESC"
|
||||
stop_rabbitmq
|
||||
;;
|
||||
status)
|
||||
status_rabbitmq
|
||||
;;
|
||||
rotate-logs)
|
||||
echo "Rotating log files for $DESC"
|
||||
rotate_logs_rabbitmq
|
||||
;;
|
||||
force-reload|reload|restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_rabbitmq
|
||||
;;
|
||||
try-restart)
|
||||
echo "Restarting $DESC"
|
||||
restart_running_rabbitmq
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit "${RETVAL}"
|
||||
|
Loading…
Reference in New Issue
Block a user