|
|
|
@ -87,16 +87,31 @@ case "${ACTION}" in
|
|
|
|
|
;;
|
|
|
|
|
"start" | "stop" | "restart")
|
|
|
|
|
APP_NAME="node-red"
|
|
|
|
|
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.ID}}')
|
|
|
|
|
CONTAINER_IDS=$(docker ps -a | grep "$APP_NAME" | awk '{print $1}')
|
|
|
|
|
|
|
|
|
|
# Echo action message
|
|
|
|
|
if [ "$ACTION" == "start" ]; then
|
|
|
|
|
echo "Starting $APP_NAME container(s)"
|
|
|
|
|
elif [ "$ACTION" == "stop" ]; then
|
|
|
|
|
echo "Stopping $APP_NAME container(s)"
|
|
|
|
|
elif [ "$ACTION" == "restart" ]; then
|
|
|
|
|
echo "Restarting $APP_NAME container(s)"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for ID in $CONTAINER_IDS; do
|
|
|
|
|
docker "${ACTION}" "${ID}"
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
"status")
|
|
|
|
|
APP_NAME="node-red"
|
|
|
|
|
CONTAINER_NAMES=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
|
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Status}}'
|
|
|
|
|
;;
|
|
|
|
|
APP_NAME="node-red"
|
|
|
|
|
CONTAINER_NAME=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
|
CONTAINER_STATUS=$(docker ps --all --filter "name=${CONTAINER_NAME}" --format '{{.Status}}' | awk '/^Up/ { print "up " substr($0, 4) } !/^Up/ && /.+/ { print "down" }')
|
|
|
|
|
if [ -z "$CONTAINER_NAME" ]; then
|
|
|
|
|
echo "${APP_NAME} is not installed"
|
|
|
|
|
else
|
|
|
|
|
echo "${CONTAINER_STATUS}"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
"port")
|
|
|
|
|
APP_NAME="node-red"
|
|
|
|
|
CONTAINER_NAMES=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
|