2009-03-10 20:22:37 +00:00
|
|
|
#!/bin/sh
|
2009-01-29 23:02:34 +00:00
|
|
|
|
2009-02-28 00:17:40 +00:00
|
|
|
CCONF="$BINDIR/cconf"
|
|
|
|
|
2009-03-11 23:21:50 +00:00
|
|
|
conf=$ETCDIR"/ceph.conf"
|
2009-02-28 00:17:40 +00:00
|
|
|
hostname=`hostname | cut -d . -f 1`
|
|
|
|
|
|
|
|
|
2009-03-11 23:21:50 +00:00
|
|
|
verify_conf() {
|
|
|
|
# make sure ceph.conf exists
|
|
|
|
if [ ! -e $conf ]; then
|
|
|
|
echo "$0: ceph conf $conf not found"
|
|
|
|
usage_exit
|
|
|
|
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?
|
2009-03-12 20:59:05 +00:00
|
|
|
host=`$CCONF -c $conf -i $id -t $type host`
|
2009-03-01 00:06:27 +00:00
|
|
|
ssh=""
|
|
|
|
dir=$PWD
|
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-06-25 17:22:33 +00:00
|
|
|
get_conf sshuser "" "user"
|
|
|
|
if [ -z "$sshuser" ]; then
|
|
|
|
ssh="ssh $host"
|
|
|
|
else
|
|
|
|
ssh="ssh $sshuser@$host"
|
|
|
|
fi
|
|
|
|
get_conf dir "$dir" "ssh path"
|
2009-03-01 00:06:27 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
host=$hostname
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n "=== $name === "
|
|
|
|
|
|
|
|
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-03-24 19:55:01 +00:00
|
|
|
bash -c "$1" || { echo "failed: '$1'" ; exit 1; }
|
2009-03-01 00:06:27 +00:00
|
|
|
else
|
2009-06-25 17:22:33 +00:00
|
|
|
[ $verbose -eq 1 ] && echo "--- $ssh $2 \"cd $dir ; ulimit -c unlimited ; $1\""
|
2009-04-23 22:55:03 +00:00
|
|
|
$ssh $2 "cd $dir ; ulimit -c unlimited ; $1" || { echo "failed: '$ssh $1'" ; exit 1; }
|
2009-03-01 00:06:27 +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=""
|
|
|
|
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'
|
|
|
|
bit=`$CCONF -c $conf -l $type | egrep -v "^$type$"`
|
2009-02-28 00:17:40 +00:00
|
|
|
case $f in
|
|
|
|
mon | osd | mds)
|
|
|
|
what="$what $bit"
|
|
|
|
;;
|
|
|
|
*)
|
2009-05-30 00:07:29 +00:00
|
|
|
if echo " " $bit " " | grep -v -q " $f "; then
|
|
|
|
echo "$0: $type '$f' not found ($conf defines "$bit")"
|
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_val() {
|
2009-02-27 23:46:10 +00:00
|
|
|
[ "$2" != "" ] && export $1=$2 || export $1=`$CCONF -c $conf "$3" "$4" "$5"`
|
2009-01-29 23:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_val_bool() {
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
export $1=$2
|
|
|
|
else
|
|
|
|
tmp=`$CCONF "$3" "$4" "$5"`
|
|
|
|
export $1=$5
|
|
|
|
|
2009-03-18 19:57:58 +00:00
|
|
|
[ "$tmp" = "0" ] && export $1=0
|
|
|
|
[ "$tmp" = "false" ] && export $1=0
|
|
|
|
[ "$tmp" = "1" ] && export $1=1
|
|
|
|
[ "$tmp" = "true" ] && export $1=1
|
2009-01-29 23:02:34 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_conf() {
|
|
|
|
var=$1
|
|
|
|
def=$2
|
|
|
|
key=$3
|
|
|
|
shift; shift; shift
|
|
|
|
|
2009-03-18 19:57:58 +00:00
|
|
|
[ $verbose -eq 1 ] && echo "$CCONF -c $conf -i $id -t $type $tmp \"$key\" \"$def\""
|
2009-03-11 22:23:46 +00:00
|
|
|
eval "$var=\"`$CCONF -c $conf -i $id -t $type $tmp \"$key\" \"$def\"`\""
|
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
|
|
|
}
|
|
|
|
|