2 # -*- mode:sh; tab-width:4; sh-basic-offset:4; indent-tabs-mode:nil -*-
3 # vim: softtabstop=4 shiftwidth=4 expandtab
5 # Copyright (C) 2013 Inktank <info@inktank.com>
6 # Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
8 # Author: Loic Dachary <loic@dachary.org>
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU Library Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Library Public License for more details.
21 test -d dev
/osd
0/.
&& test -e dev
/sudo
&& SUDO
="sudo"
23 if [ -e CMakeCache.txt
]; then
24 [ -z "$CEPH_BIN" ] && CEPH_BIN
=bin
27 if [ -n "$VSTART_DEST" ]; then
28 CEPH_CONF_PATH
=$VSTART_DEST
32 conf_fn
="$CEPH_CONF_PATH/ceph.conf"
33 CEPHADM_DIR_PATH
="$CEPH_CONF_PATH/../src/cephadm"
39 local pname
="ceph-run.*$1"
40 if [ $1 == "ganesha.nfsd" ]; then
43 pg
=`pgrep -u $MYUID -f $pname`
44 [ -n "$pg" ] && kill $pg
45 $SUDO killall
-u $MYNAME $1
56 pkill
-SIGTERM -u $MYUID $p
60 # wait for processes to stop
61 if pkill
-0 -u $MYUID $p; then
67 # kill and print if some left
68 if pkill
-0 -u $MYUID $p; then
69 echo "WARNING: $p did not orderly shutdown, killing it hard!" >&2
70 pkill
-SIGKILL -u $MYUID $p
77 FSID
=$
($CEPH_BIN/ceph
-c $conf_fn fsid
)
78 sudo
$CEPHADM_DIR_PATH/cephadm rm-cluster
--fsid $FSID --force
82 #VSTART_IP_PORTS is of the format as below
83 #"[v[num]:IP:PORT/0,v[num]:IP:PORT/0][v[num]:IP:PORT/0,v[num]:IP:PORT/0]..."
84 VSTART_IP_PORTS
=$
("${CEPH_BIN}"/ceph
-c $conf_fn mon metadata
2>/dev
/null | jq
-j '.[].addrs')
86 #SRC_MNT_ARRAY is of the format as below
87 #SRC_MNT_ARRAY[0] = IP:PORT,IP:PORT,IP:PORT:/
88 #SRC_MNT_ARRAY[1] = MNT_POINT1
89 #SRC_MNT_ARRAY[2] = IP:PORT:/ #Could be mounted using single mon IP
90 #SRC_MNT_ARRAY[3] = MNT_POINT2
92 SRC_MNT_ARRAY
=($
(findmnt
-t ceph
-n --raw --output=source,target
))
93 LEN_SRC_MNT_ARRAY
=${#SRC_MNT_ARRAY[@]}
95 for (( i
=0; i
<${LEN_SRC_MNT_ARRAY}; i
=$
((i
+2)) ))
97 # The first IP:PORT among the list is checked against vstart monitor IP:PORTS
98 IP_PORT1
=$
(echo ${SRC_MNT_ARRAY[$i]} |
awk -F ':/' '{print $1}' |
awk -F ',' '{print $1}')
99 if [[ "$VSTART_IP_PORTS" == *"$IP_PORT1"* ]]
101 CEPH_MNT
=${SRC_MNT_ARRAY[$((i+1))]}
102 [ -n "$CEPH_MNT" ] && sudo umount
-f $CEPH_MNT
106 #Get fuse mounts of the cluster
107 CEPH_FUSE_MNTS
=$
("${CEPH_BIN}"/ceph
-c $conf_fn tell mds.
* client
ls 2>/dev
/null |
grep mount_point |
tr -d '",' |
awk '{print $2}')
108 [ -n "$CEPH_FUSE_MNTS" ] && sudo umount
-f $CEPH_FUSE_MNTS
111 usage
="usage: $0 [all] [mon] [mds] [osd] [rgw] [nfs] [--crimson] [--cephadm]\n"
123 while [ $# -ge 1 ]; do
166 if [ $stop_all -eq 1 ]; then
167 if "${CEPH_BIN}"/ceph
-s --connect-timeout 1 -c $conf_fn >/dev
/null
2>&1; then
168 # Umount mounted filesystems from vstart cluster
172 if "${CEPH_BIN}"/rbd device list
-c $conf_fn >/dev
/null
2>&1; then
173 "${CEPH_BIN}"/rbd device list
-c $conf_fn |
tail -n +2 |
175 # While it is currently possible to create an rbd image with
176 # whitespace chars in its name, krbd will refuse mapping such
177 # an image, so we can safely split on whitespace here. (The
178 # same goes for whitespace chars in names of the pools that
179 # contain rbd images).
180 DEV
="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')"
181 sudo
"${CEPH_BIN}"/rbd device unmap
"${DEV}" -c $conf_fn
184 if [ -n "$("${CEPH_BIN}"/rbd device list -c $conf_fn)" ]; then
185 echo "WARNING: Some rbd images are still mapped!" >&2
189 daemons
="$($CEPHADM_DIR_PATH/cephadm ls 2> /dev/null)"
190 if [ $?
-eq 0 -a "$daemons" != "[]" ]; then
195 to_kill
="$ceph_osd ceph-mon ceph-mds ceph-mgr radosgw lt-radosgw apache2 ganesha.nfsd"
197 for step
in 0 1 1 2 3 5 8; do
199 since_kill
=$
((since_kill
+ step
))
201 for p
in $to_kill; do
202 if ! maybe_kill
"$p" $step; then
206 if [ -z "$survivors" ]; then
210 if [ $since_kill -gt 0 ]; then
211 echo "WARNING: $to_kill still alive after $since_kill seconds" >&2
215 pkill
-u $MYUID -f valgrind.bin.\
*ceph-mon
216 $SUDO pkill
-u $MYUID -f valgrind.bin.\
*$ceph_osd
217 pkill
-u $MYUID -f valgrind.bin.\
*ceph-mds
218 asok_dir
=`dirname $("${CEPH_BIN}"/ceph-conf -c ${conf_fn} --show-config-value admin_socket)`
221 [ $stop_mon -eq 1 ] && do_killall ceph-mon
222 [ $stop_mds -eq 1 ] && do_killall ceph-mds
223 [ $stop_osd -eq 1 ] && do_killall
$ceph_osd
224 [ $stop_mgr -eq 1 ] && do_killall ceph-mgr
225 [ $stop_ganesha -eq 1 ] && do_killall ganesha.nfsd
226 [ $stop_rgw -eq 1 ] && do_killall radosgw lt-radosgw apache2
227 [ $stop_cephadm -eq 1 ] && do_killcephadm