summaryrefslogtreecommitdiffstats
path: root/bin/container
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2017-04-03 10:24:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2017-04-03 10:24:24 +0000
commitd013d5bcb55b4b0cd2f6b3cd1b7ea480f1c2f5a1 (patch)
tree575559903db372b4a37576838ce131a5c8dc118c /bin/container
parentAdding upstream version 20170101. (diff)
downloadopen-infrastructure-compute-tools-d013d5bcb55b4b0cd2f6b3cd1b7ea480f1c2f5a1.tar.xz
open-infrastructure-compute-tools-d013d5bcb55b4b0cd2f6b3cd1b7ea480f1c2f5a1.zip
Adding upstream version 20170401.upstream/20170401
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xbin/container103
1 files changed, 53 insertions, 50 deletions
diff --git a/bin/container b/bin/container
index a23f274..1b57193 100755
--- a/bin/container
+++ b/bin/container
@@ -33,66 +33,69 @@ then
fi
# Command
-COMMAND="${1}"
-
-if [ ! -e "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" ]
-then
- echo "'${COMMAND}': no such ${PROGRAM} command" >&2
- exit 1
-fi
+COMMANDS="${1}"
# Options
shift 1
OPTIONS="${@}"
-# Pre hooks
-for FILE in "${HOOKS}/pre-${PROGRAM}".* "${HOOKS}/${NAME}.pre-${PROGRAM}"
+for COMMAND in $(echo ${COMMANDS} | sed -e 's|,| |g')
do
- if [ -x "${FILE}" ]
+ if [ ! -e "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" ]
then
- "${FILE}"
+ echo "'${COMMAND}': no such ${PROGRAM} command" >&2
+ exit 1
fi
-done
-# Notification
-if echo "${OPTIONS}" | grep -qs "\--no-notification"
-then
- OPTIONS="$(echo "${OPTIONS}" | sed -e 's|--no-notification||')"
-else
- case "${COMMAND}" in
- create|remove|rm|restart|start|stop)
- USER="${SUDO_USER:-${USER}}"
- DATE="$(date +%Y-%m-%d\ %H:%M:%S)"
- HOST="$(hostname -f)"
-
- # logfile
- echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
-
- # irc
- if [ -e /usr/bin/irk ] && [ -e "/etc/default/${SOFTWARE}" ]
- then
- . /etc/default/${SOFTWARE}
-
- if [ -n "${IRK_TARGETS}" ]
+ # Pre hooks
+ for FILE in "${HOOKS}/pre-${PROGRAM}".* "${HOOKS}/${NAME}.pre-${PROGRAM}"
+ do
+ if [ -x "${FILE}" ]
+ then
+ "${FILE}"
+ fi
+ done
+
+ # Notification
+ if echo "${OPTIONS}" | grep -qs "\--no-notification"
+ then
+ OPTIONS="$(echo "${OPTIONS}" | sed -e 's|--no-notification||')"
+ else
+ case "${COMMAND}" in
+ create|remove|rm|restart|start|stop)
+ USER="${SUDO_USER:-${USER}}"
+ DATE="$(date +%Y-%m-%d\ %H:%M:%S)"
+ HOST="$(hostname -f)"
+
+ # logfile
+ echo "${DATE} ${HOST} ${USER} ${PROGRAM} ${COMMAND} ${OPTIONS}" >> "/var/log/${SOFTWARE}/${PROGRAM}.log"
+
+ # irc
+ if [ -e /usr/bin/irk ] && [ -e "/etc/default/${SOFTWARE}" ]
then
- for TARGET in ${IRK_TARGETS}
- do
- irk ${TARGET} "\x0300${USER}\x03@\x0312${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 ${OPTIONS}"
- done
+ . /etc/default/${SOFTWARE}
+
+ if [ -n "${IRK_TARGETS}" ]
+ then
+ for TARGET in ${IRK_TARGETS}
+ do
+ irk ${TARGET} "\x0300${USER}\x03@\x0312${HOST}:\x03 \x0303${PROGRAM}\x03 \x0307${COMMAND}\x03 ${OPTIONS}"
+ done
+ fi
fi
- fi
- ;;
- esac
-fi
-
-# Run
-exec "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" "${OPTIONS}"
-
-# Post hooks
-for FILE in "${HOOKS}/post-${PROGRAM}".* "${HOOKS}/${NAME}.post-${PROGRAM}"
-do
- if [ -x "${FILE}" ]
- then
- "${FILE}"
+ ;;
+ esac
fi
+
+ # Run
+ exec "/usr/lib/${SOFTWARE}/${PROGRAM}/${COMMAND}" "${OPTIONS}"
+
+ # Post hooks
+ for FILE in "${HOOKS}/post-${PROGRAM}".* "${HOOKS}/${NAME}.post-${PROGRAM}"
+ do
+ if [ -x "${FILE}" ]
+ then
+ "${FILE}"
+ fi
+ done
done