2014-04-03 14:11:49 +00:00
|
|
|
#!/bin/bash
|
2013-12-16 15:27:34 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2013 Inktank <info@inktank.com>
|
|
|
|
# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
|
|
|
|
#
|
|
|
|
# Author: Loic Dachary <loic@dachary.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Library Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Library Public License for more details.
|
|
|
|
#
|
2008-12-12 22:51:40 +00:00
|
|
|
|
2009-04-13 17:19:47 +00:00
|
|
|
test -d dev/osd0/. && test -e dev/sudo && SUDO="sudo"
|
|
|
|
|
2014-04-01 06:18:23 +00:00
|
|
|
[ -z "$CEPH_BIN" ] && CEPH_BIN=.
|
|
|
|
|
2008-12-12 22:51:40 +00:00
|
|
|
do_killall() {
|
2014-04-01 06:18:23 +00:00
|
|
|
pg=`pgrep -f ceph-run.*$1`
|
|
|
|
[ -n "$pg" ] && kill $pg
|
|
|
|
$SUDO killall $1
|
2008-12-12 22:51:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usage="usage: $0 [all] [mon] [mds] [osd]\n"
|
|
|
|
|
2011-05-06 18:10:16 +00:00
|
|
|
stop_all=1
|
|
|
|
stop_mon=0
|
|
|
|
stop_mds=0
|
|
|
|
stop_osd=0
|
2012-09-01 21:39:28 +00:00
|
|
|
stop_rgw=0
|
2008-12-12 22:51:40 +00:00
|
|
|
|
|
|
|
while [ $# -ge 1 ]; do
|
|
|
|
case $1 in
|
2014-04-01 06:18:23 +00:00
|
|
|
all )
|
|
|
|
stop_all=1
|
|
|
|
;;
|
|
|
|
mon | ceph-mon )
|
|
|
|
stop_mon=1
|
|
|
|
stop_all=0
|
|
|
|
;;
|
|
|
|
mds | ceph-mds )
|
|
|
|
stop_mds=1
|
|
|
|
stop_all=0
|
|
|
|
;;
|
|
|
|
osd | ceph-osd )
|
|
|
|
stop_osd=1
|
|
|
|
stop_all=0
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
printf "$usage"
|
|
|
|
exit
|
2011-05-06 18:07:05 +00:00
|
|
|
esac
|
|
|
|
shift
|
2008-12-12 22:51:40 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ $stop_all -eq 1 ]; then
|
2014-04-01 06:18:23 +00:00
|
|
|
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 [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then
|
|
|
|
echo "WARNING: Some rbd images are still mapped!" >&2
|
|
|
|
fi
|
|
|
|
|
2014-04-01 06:18:23 +00:00
|
|
|
for p in ceph-mon ceph-mds ceph-osd radosgw lt-radosgw apache2 ; do
|
|
|
|
for try in 0 1 1 1 1 ; do
|
|
|
|
if ! pkill $p ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep $try
|
2013-12-16 15:27:34 +00:00
|
|
|
done
|
2014-04-01 06:18:23 +00:00
|
|
|
done
|
2014-04-01 06:18:23 +00:00
|
|
|
|
2014-04-01 06:18:23 +00:00
|
|
|
pkill -f valgrind.bin.\*ceph-mon
|
|
|
|
$SUDO pkill -f valgrind.bin.\*ceph-osd
|
|
|
|
pkill -f valgrind.bin.\*ceph-mds
|
2008-12-12 22:51:40 +00:00
|
|
|
else
|
2014-04-01 06:18:23 +00:00
|
|
|
[ $stop_mon -eq 1 ] && do_killall ceph-mon
|
|
|
|
[ $stop_mds -eq 1 ] && do_killall ceph-mds
|
|
|
|
[ $stop_osd -eq 1 ] && do_killall ceph-osd
|
|
|
|
[ $stop_rgw -eq 1 ] && do_killall radosgw lt-radosgw apache2
|
2008-12-12 22:51:40 +00:00
|
|
|
fi
|