From c5639e4e276a8d5f6457ce9f63b3e77a230a669c Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Mon, 14 Dec 2015 09:41:10 +0000 Subject: [PATCH] stop.sh: make more portable Signed-off-by: Mykola Golub (cherry picked from commit 27f2d806f905df1a51b11bd79f1af4c26471407a) --- src/stop.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/stop.sh b/src/stop.sh index 8e45f4116d34e..e315f6023f2ce 100755 --- a/src/stop.sh +++ b/src/stop.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # Copyright (C) 2013 Inktank # Copyright (C) 2013 Cloudwatt @@ -62,18 +62,21 @@ while [ $# -ge 1 ]; do done if [ $stop_all -eq 1 ]; then - while read DEV; do - # While it is currently possible to create an rbd image with - # whitespace chars in its name, krbd will refuse mapping such - # an image, so we can safely split on whitespace here. (The - # same goes for whitespace chars in names of the pools that - # contain rbd images). - DEV="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')" - sudo "${CEPH_BIN}"/rbd unmap "${DEV}" - done < <("${CEPH_BIN}"/rbd showmapped | tail -n +2) + if "${CEPH_BIN}"/rbd showmapped >/dev/null 2>&1; then + "${CEPH_BIN}"/rbd showmapped | tail -n +2 | + while read DEV; do + # While it is currently possible to create an rbd image with + # whitespace chars in its name, krbd will refuse mapping such + # an image, so we can safely split on whitespace here. (The + # same goes for whitespace chars in names of the pools that + # contain rbd images). + DEV="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')" + sudo "${CEPH_BIN}"/rbd unmap "${DEV}" + done - if [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then - echo "WARNING: Some rbd images are still mapped!" >&2 + if [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then + echo "WARNING: Some rbd images are still mapped!" >&2 + fi fi for p in ceph-mon ceph-mds ceph-osd radosgw lt-radosgw apache2 ; do -- 2.39.5