3 # Copyright (C) 2013 Inktank <info@inktank.com>
4 # Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
6 # Author: Loic Dachary <loic@dachary.org>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU Library Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Library Public License for more details.
19 test -d dev
/osd
0/.
&& test -e dev
/sudo
&& SUDO
="sudo"
21 if [ -e CMakeCache.txt
]; then
22 [ -z "$CEPH_BIN" ] && CEPH_BIN
=bin
25 if [ -n "$VSTART_DEST" ]; then
26 CEPH_CONF_PATH
=$VSTART_DEST
30 conf_fn
="$CEPH_CONF_PATH/ceph.conf"
36 local pname
="ceph-run.*$1"
37 if [ $1 == "ganesha.nfsd" ]; then
40 pg
=`pgrep -u $MYUID -f $pname`
41 [ -n "$pg" ] && kill $pg
42 $SUDO killall
-u $MYNAME $1
46 #VSTART_IP_PORTS is of the format as below
47 #"[v[num]:IP:PORT/0,v[num]:IP:PORT/0][v[num]:IP:PORT/0,v[num]:IP:PORT/0]..."
48 VSTART_IP_PORTS
=$
("${CEPH_BIN}"/ceph
-c $conf_fn mon metadata
2>/dev
/null | jq
-j '.[].addrs')
50 #SRC_MNT_ARRAY is of the format as below
51 #SRC_MNT_ARRAY[0] = IP:PORT,IP:PORT,IP:PORT:/
52 #SRC_MNT_ARRAY[1] = MNT_POINT1
53 #SRC_MNT_ARRAY[2] = IP:PORT:/ #Could be mounted using single mon IP
54 #SRC_MNT_ARRAY[3] = MNT_POINT2
56 SRC_MNT_ARRAY
=($
(findmnt
-t ceph
-n --raw --output=source,target
))
57 LEN_SRC_MNT_ARRAY
=${#SRC_MNT_ARRAY[@]}
59 for (( i
=0; i
<${LEN_SRC_MNT_ARRAY}; i
=$
((i
+2)) ))
61 # The first IP:PORT among the list is checked against vstart monitor IP:PORTS
62 IP_PORT1
=$
(echo ${SRC_MNT_ARRAY[$i]} |
awk -F ':/' '{print $1}' |
awk -F ',' '{print $1}')
63 if [[ "$VSTART_IP_PORTS" == *"$IP_PORT1"* ]]
65 CEPH_MNT
=${SRC_MNT_ARRAY[$((i+1))]}
66 [ -n "$CEPH_MNT" ] && sudo umount
-f $CEPH_MNT
70 #Get fuse mounts of the cluster
71 CEPH_FUSE_MNTS
=$
("${CEPH_BIN}"/ceph
-c $conf_fn tell mds.
* client
ls 2>/dev
/null |
grep mount_point |
tr -d '",' |
awk '{print $2}')
72 [ -n "$CEPH_FUSE_MNTS" ] && sudo umount
-f $CEPH_FUSE_MNTS
75 usage
="usage: $0 [all] [mon] [mds] [osd] [rgw] [ganesha] [--crimson]\n"
86 while [ $# -ge 1 ]; do
111 ganesha | ganesha.nfsd
)
125 if [ $stop_all -eq 1 ]; then
126 if "${CEPH_BIN}"/ceph
-s --connect-timeout 1 -c $conf_fn >/dev
/null
2>&1; then
127 # Umount mounted filesystems from vstart cluster
131 if "${CEPH_BIN}"/rbd device list
-c $conf_fn >/dev
/null
2>&1; then
132 "${CEPH_BIN}"/rbd device list
-c $conf_fn |
tail -n +2 |
134 # While it is currently possible to create an rbd image with
135 # whitespace chars in its name, krbd will refuse mapping such
136 # an image, so we can safely split on whitespace here. (The
137 # same goes for whitespace chars in names of the pools that
138 # contain rbd images).
139 DEV
="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')"
140 sudo
"${CEPH_BIN}"/rbd device unmap
"${DEV}" -c $conf_fn
143 if [ -n "$("${CEPH_BIN}"/rbd device list -c $conf_fn)" ]; then
144 echo "WARNING: Some rbd images are still mapped!" >&2
148 for p
in ceph-mon ceph-mds
$ceph_osd ceph-mgr radosgw lt-radosgw apache2 ganesha.nfsd
; do
149 for try
in 0 1 1 1 1 ; do
150 if ! pkill
-u $MYUID $p ; then
157 pkill
-u $MYUID -f valgrind.bin.\
*ceph-mon
158 $SUDO pkill
-u $MYUID -f valgrind.bin.\
*$ceph_osd
159 pkill
-u $MYUID -f valgrind.bin.\
*ceph-mds
160 asok_dir
=`dirname $("${CEPH_BIN}"/ceph-conf -c ${conf_fn} --show-config-value admin_socket)`
163 [ $stop_mon -eq 1 ] && do_killall ceph-mon
164 [ $stop_mds -eq 1 ] && do_killall ceph-mds
165 [ $stop_osd -eq 1 ] && do_killall
$ceph_osd
166 [ $stop_mgr -eq 1 ] && do_killall ceph-mgr
167 [ $stop_ganesha -eq 1 ] && do_killall ganesha.nfsd
168 [ $stop_rgw -eq 1 ] && do_killall radosgw lt-radosgw apache2