]> git.proxmox.com Git - ceph.git/blame - ceph/src/stop.sh
update sources to v12.1.2
[ceph.git] / ceph / src / stop.sh
CommitLineData
7c673cae
FG
1#!/bin/sh
2#
3# Copyright (C) 2013 Inktank <info@inktank.com>
4# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
5#
6# Author: Loic Dachary <loic@dachary.org>
7#
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)
11# any later version.
12#
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.
17#
18
19test -d dev/osd0/. && test -e dev/sudo && SUDO="sudo"
20
21if [ -e CMakeCache.txt ]; then
7c673cae
FG
22 [ -z "$CEPH_BIN" ] && CEPH_BIN=bin
23fi
24
25MYUID=$(id -u)
26MYNAME=$(id -nu)
27
28do_killall() {
29 pg=`pgrep -u $MYUID -f ceph-run.*$1`
30 [ -n "$pg" ] && kill $pg
31 $SUDO killall -u $MYNAME $1
32}
33
34usage="usage: $0 [all] [mon] [mds] [osd] [rgw]\n"
35
36stop_all=1
37stop_mon=0
38stop_mds=0
39stop_osd=0
40stop_mgr=0
41stop_rgw=0
42
43while [ $# -ge 1 ]; do
44 case $1 in
45 all )
46 stop_all=1
47 ;;
48 mon | ceph-mon )
49 stop_mon=1
50 stop_all=0
51 ;;
52 mgr | ceph-mgr )
53 stop_mgr=1
54 stop_all=0
55 ;;
56 mds | ceph-mds )
57 stop_mds=1
58 stop_all=0
59 ;;
60 osd | ceph-osd )
61 stop_osd=1
62 stop_all=0
63 ;;
64 rgw | ceph-rgw )
65 stop_rgw=1
66 stop_all=0
67 ;;
68 * )
69 printf "$usage"
70 exit
71 esac
72 shift
73done
74
75if [ $stop_all -eq 1 ]; then
76 if "${CEPH_BIN}"/rbd showmapped >/dev/null 2>&1; then
77 "${CEPH_BIN}"/rbd showmapped | tail -n +2 |
78 while read DEV; do
79 # While it is currently possible to create an rbd image with
80 # whitespace chars in its name, krbd will refuse mapping such
81 # an image, so we can safely split on whitespace here. (The
82 # same goes for whitespace chars in names of the pools that
83 # contain rbd images).
84 DEV="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')"
85 sudo "${CEPH_BIN}"/rbd unmap "${DEV}"
86 done
87
88 if [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then
89 echo "WARNING: Some rbd images are still mapped!" >&2
90 fi
91 fi
92
93 for p in ceph-mon ceph-mds ceph-osd ceph-mgr radosgw lt-radosgw apache2 ; do
94 for try in 0 1 1 1 1 ; do
95 if ! pkill -u $MYUID $p ; then
96 break
97 fi
98 sleep $try
99 done
100 done
101
102 pkill -u $MYUID -f valgrind.bin.\*ceph-mon
103 $SUDO pkill -u $MYUID -f valgrind.bin.\*ceph-osd
104 pkill -u $MYUID -f valgrind.bin.\*ceph-mds
c07f9fc5
FG
105 asok_dir=`dirname $("${CEPH_BIN}"/ceph-conf --show-config-value admin_socket)`
106 rm -rf "${asok_dir}"
7c673cae
FG
107else
108 [ $stop_mon -eq 1 ] && do_killall ceph-mon
109 [ $stop_mds -eq 1 ] && do_killall ceph-mds
110 [ $stop_osd -eq 1 ] && do_killall ceph-osd
111 [ $stop_mgr -eq 1 ] && do_killall ceph-mgr
112 [ $stop_rgw -eq 1 ] && do_killall radosgw lt-radosgw apache2
113fi