2009-03-10 20:22:37 +00:00
|
|
|
#!/bin/sh
|
2009-01-29 23:02:34 +00:00
|
|
|
|
2011-09-21 23:28:43 +00:00
|
|
|
CCONF="$BINDIR/ceph-conf"
|
2009-02-28 00:17:40 +00:00
|
|
|
|
2010-03-02 23:41:23 +00:00
|
|
|
default_conf=$ETCDIR"/ceph.conf"
|
|
|
|
conf=$default_conf
|
|
|
|
|
2009-02-28 00:17:40 +00:00
|
|
|
hostname=`hostname | cut -d . -f 1`
|
|
|
|
|
2009-07-13 17:30:43 +00:00
|
|
|
figure_dirs() {
|
|
|
|
if echo $bindir | grep -q \@; then
|
|
|
|
echo "using current dir"
|
|
|
|
BINDIR=.
|
|
|
|
LIBDIR=.
|
|
|
|
ETCDIR=.
|
|
|
|
else
|
|
|
|
echo "all good"
|
|
|
|
|
|
|
|
fi
|
|
|
|
}
|
2009-02-28 00:17:40 +00:00
|
|
|
|
2009-03-11 23:21:50 +00:00
|
|
|
verify_conf() {
|
2010-04-20 22:25:00 +00:00
|
|
|
# fetch conf?
|
|
|
|
if [ -x "$ETCDIR/fetch_config" ] && [ "$conf" = "$default_conf" ]; then
|
|
|
|
conf="/tmp/fetched.ceph.conf.$$"
|
|
|
|
echo "[$ETCDIR/fetch_config $conf]"
|
|
|
|
if $ETCDIR/fetch_config $conf && [ -e $conf ]; then true ; else
|
|
|
|
echo "$0: failed to fetch config with '$ETCDIR/fetch_config $conf'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# yay!
|
|
|
|
else
|
|
|
|
# make sure ceph.conf exists
|
|
|
|
if [ ! -e $conf ]; then
|
|
|
|
if [ "$conf" = "$default_conf" ]; then
|
|
|
|
echo "$0: ceph conf $conf not found; system is not configured."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo "$0: ceph conf $conf not found!"
|
|
|
|
usage_exit
|
2010-03-02 23:41:23 +00:00
|
|
|
fi
|
2009-03-11 23:21:50 +00:00
|
|
|
fi
|
|
|
|
}
|
2009-03-02 17:51:13 +00:00
|
|
|
|
|
|
|
|
2009-03-01 00:06:27 +00:00
|
|
|
check_host() {
|
|
|
|
# what host is this daemon assigned to?
|
2011-03-10 23:12:22 +00:00
|
|
|
host=`$CCONF -c $conf -n $type.$id host`
|
2010-10-06 23:32:43 +00:00
|
|
|
[ "$host" = "localhost" ] && host=""
|
2009-03-01 00:06:27 +00:00
|
|
|
ssh=""
|
2009-06-25 21:03:44 +00:00
|
|
|
rootssh=""
|
2011-03-10 23:12:22 +00:00
|
|
|
sshdir=$PWD
|
2009-07-10 17:43:38 +00:00
|
|
|
get_conf user "" "user"
|
2009-03-18 19:57:58 +00:00
|
|
|
if [ -n "$host" ]; then
|
2009-03-01 00:06:27 +00:00
|
|
|
#echo host for $name is $host, i am $hostname
|
2009-03-18 19:57:58 +00:00
|
|
|
if [ "$host" != "$hostname" ]; then
|
2009-03-01 00:06:27 +00:00
|
|
|
# skip, unless we're starting remote daemons too
|
2009-03-18 19:57:58 +00:00
|
|
|
if [ $allhosts -eq 0 ]; then
|
2009-03-01 00:06:27 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we'll need to ssh into that host
|
2009-07-10 17:43:38 +00:00
|
|
|
if [ -z "$user" ]; then
|
2009-06-25 17:22:33 +00:00
|
|
|
ssh="ssh $host"
|
|
|
|
else
|
2009-07-10 17:43:38 +00:00
|
|
|
ssh="ssh $user@$host"
|
2009-06-25 17:22:33 +00:00
|
|
|
fi
|
2009-06-25 21:03:44 +00:00
|
|
|
rootssh="ssh root@$host"
|
2011-03-10 23:12:22 +00:00
|
|
|
get_conf sshdir "$sshdir" "ssh path"
|
2009-03-01 00:06:27 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
host=$hostname
|
|
|
|
fi
|
|
|
|
|
2010-07-22 21:27:08 +00:00
|
|
|
echo "=== $type.$id === "
|
2009-03-01 00:06:27 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
do_cmd() {
|
2009-03-18 19:57:58 +00:00
|
|
|
if [ -z "$ssh" ]; then
|
2009-04-23 22:55:03 +00:00
|
|
|
[ $verbose -eq 1 ] && echo "--- $host# $1"
|
2009-03-01 00:06:27 +00:00
|
|
|
ulimit -c unlimited
|
2009-07-10 17:43:38 +00:00
|
|
|
whoami=`whoami`
|
|
|
|
if [ "$whoami" = "$user" ] || [ -z "$user" ]; then
|
2010-02-12 22:20:02 +00:00
|
|
|
bash -c "$1" || { [ -z "$3" ] && echo "failed: '$1'" && exit 1; }
|
2009-07-10 17:43:38 +00:00
|
|
|
else
|
2010-02-12 22:20:02 +00:00
|
|
|
sudo su $user -c "$1" || { [ -z "$3" ] && echo "failed: '$1'" && exit 1; }
|
2009-07-10 17:43:38 +00:00
|
|
|
fi
|
2009-03-01 00:06:27 +00:00
|
|
|
else
|
2011-03-12 00:22:19 +00:00
|
|
|
[ $verbose -eq 1 ] && echo "--- $ssh $2 \"cd $sshdir ; ulimit -c unlimited ; $1\""
|
|
|
|
$ssh $2 "cd $sshdir ; ulimit -c unlimited ; $1" || { [ -z "$3" ] && echo "failed: '$ssh $1'" && exit 1; }
|
2009-03-01 00:06:27 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-06-25 21:03:44 +00:00
|
|
|
do_root_cmd() {
|
|
|
|
if [ -z "$ssh" ]; then
|
|
|
|
[ $verbose -eq 1 ] && echo "--- $host# $1"
|
|
|
|
ulimit -c unlimited
|
2011-09-19 16:47:11 +00:00
|
|
|
whoami=`whoami`
|
|
|
|
if [ "$whoami" = "root" ]; then
|
|
|
|
bash -c "$1" || { echo "failed: '$1'" ; exit 1; }
|
|
|
|
else
|
|
|
|
sudo bash -c "$1" || { echo "failed: '$1'" ; exit 1; }
|
|
|
|
fi
|
2009-06-25 21:03:44 +00:00
|
|
|
else
|
2011-03-12 00:22:19 +00:00
|
|
|
[ $verbose -eq 1 ] && echo "--- $rootssh $2 \"cd $sshdir ; ulimit -c unlimited ; $1\""
|
|
|
|
$rootssh $2 "cd $sshdir ; ulimit -c unlimited ; $1" || { echo "failed: '$rootssh $1'" ; exit 1; }
|
2009-06-25 21:03:44 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-02-28 00:17:40 +00:00
|
|
|
get_name_list() {
|
|
|
|
orig=$1
|
|
|
|
|
2009-03-18 19:57:58 +00:00
|
|
|
if [ -z "$orig" ]; then
|
2009-02-28 00:17:40 +00:00
|
|
|
# extract list of monitors, mdss, osds defined in startup.conf
|
|
|
|
what=`$CCONF -c $conf -l mon | egrep -v '^mon$' ; \
|
|
|
|
$CCONF -c $conf -l mds | egrep -v '^mds$' ; \
|
|
|
|
$CCONF -c $conf -l osd | egrep -v '^osd$'`
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
what=""
|
2011-03-10 23:12:22 +00:00
|
|
|
for f in $orig; do
|
2009-05-18 19:01:21 +00:00
|
|
|
type=`echo $f | cut -c 1-3` # e.g. 'mon', if $item is 'mon1'
|
2010-07-22 21:26:49 +00:00
|
|
|
id=`echo $f | cut -c 4- | sed 's/\\.//'`
|
2011-04-15 21:03:20 +00:00
|
|
|
all=`$CCONF -c $conf -l $type | egrep -v "^$type$" || true`
|
2009-02-28 00:17:40 +00:00
|
|
|
case $f in
|
|
|
|
mon | osd | mds)
|
2010-07-22 21:26:49 +00:00
|
|
|
what="$what $all"
|
2009-02-28 00:17:40 +00:00
|
|
|
;;
|
|
|
|
*)
|
2010-07-23 23:05:20 +00:00
|
|
|
if echo " " $all " " | egrep -v -q "( $type$id | $type.$id )"; then
|
2010-07-22 21:26:49 +00:00
|
|
|
echo "$0: $type.$id not found ($conf defines \"$all\")"
|
2009-05-18 19:01:21 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2009-02-28 00:17:40 +00:00
|
|
|
what="$what $f"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2009-01-29 23:02:34 +00:00
|
|
|
get_conf() {
|
|
|
|
var=$1
|
|
|
|
def=$2
|
|
|
|
key=$3
|
|
|
|
shift; shift; shift
|
|
|
|
|
2011-03-10 23:12:22 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
[ "$verbose" -eq 1 ] && echo "$CCONF -c $conf -n $type.$id \"$key\""
|
|
|
|
eval "$var=\"`$CCONF -c $conf -n $type.$id \"$key\" || eval echo -n \"$def\"`\""
|
|
|
|
else
|
|
|
|
[ "$verbose" -eq 1 ] && echo "$CCONF -c $conf -s $1 \"$key\""
|
|
|
|
eval "$var=\"`$CCONF -c $conf -s $1 \"$key\" || eval echo -n \"$def\"`\""
|
|
|
|
fi
|
2009-01-29 23:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_conf_bool() {
|
|
|
|
get_conf "$@"
|
|
|
|
|
|
|
|
eval "val=$"$1
|
2009-03-18 19:57:58 +00:00
|
|
|
[ "$val" = "0" ] && export $1=0
|
|
|
|
[ "$val" = "false" ] && export $1=0
|
|
|
|
[ "$val" = "1" ] && export $1=1
|
|
|
|
[ "$val" = "true" ] && export $1=1
|
2009-01-29 23:02:34 +00:00
|
|
|
}
|
|
|
|
|