mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
initscripts: remove bash-isms so they work with dash
(Ubuntu uses dash for /bin/sh.)
This commit is contained in:
parent
c79c579c0d
commit
1bf9ce5ef7
@ -20,11 +20,11 @@ check_host() {
|
||||
host=`$CCONF -c $conf -i $id -t $type host`
|
||||
ssh=""
|
||||
dir=$PWD
|
||||
if [[ $host != "" ]]; then
|
||||
if [ -n "$host" ]; then
|
||||
#echo host for $name is $host, i am $hostname
|
||||
if [[ $host != $hostname ]]; then
|
||||
if [ "$host" != "$hostname" ]; then
|
||||
# skip, unless we're starting remote daemons too
|
||||
if [[ $allhosts -eq 0 ]]; then
|
||||
if [ $allhosts -eq 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -42,8 +42,8 @@ check_host() {
|
||||
}
|
||||
|
||||
do_cmd() {
|
||||
[[ $verbose = 1 ]] && echo "--- $host:$dir# $1"
|
||||
if [[ $ssh = "" ]]; then
|
||||
[ $verbose -eq 1 ] && echo "--- $host:$dir# $1"
|
||||
if [ -z "$ssh" ]; then
|
||||
ulimit -c unlimited
|
||||
bash -c "$1" || (echo failed. ; exit 1)
|
||||
else
|
||||
@ -54,7 +54,7 @@ do_cmd() {
|
||||
get_name_list() {
|
||||
orig=$1
|
||||
|
||||
if [[ $orig = "" ]]; then
|
||||
if [ -z "$orig" ]; then
|
||||
# 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$' ; \
|
||||
@ -88,10 +88,10 @@ get_val_bool() {
|
||||
tmp=`$CCONF "$3" "$4" "$5"`
|
||||
export $1=$5
|
||||
|
||||
[ "$tmp" == "0" ] && export $1=0
|
||||
[ "$tmp" == "false" ] && export $1=0
|
||||
[ "$tmp" == "1" ] && export $1=1
|
||||
[ "$tmp" == "true" ] && export $1=1
|
||||
[ "$tmp" = "0" ] && export $1=0
|
||||
[ "$tmp" = "false" ] && export $1=0
|
||||
[ "$tmp" = "1" ] && export $1=1
|
||||
[ "$tmp" = "true" ] && export $1=1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ get_conf() {
|
||||
key=$3
|
||||
shift; shift; shift
|
||||
|
||||
[[ $verbose == 1 ]] && echo "$CCONF -c $conf -i $id -t $type $tmp \"$key\" \"$def\""
|
||||
[ $verbose -eq 1 ] && echo "$CCONF -c $conf -i $id -t $type $tmp \"$key\" \"$def\""
|
||||
eval "$var=\"`$CCONF -c $conf -i $id -t $type $tmp \"$key\" \"$def\"`\""
|
||||
}
|
||||
|
||||
@ -109,9 +109,9 @@ get_conf_bool() {
|
||||
get_conf "$@"
|
||||
|
||||
eval "val=$"$1
|
||||
[ "$val" == "0" ] && export $1=0
|
||||
[ "$val" == "false" ] && export $1=0
|
||||
[ "$val" == "1" ] && export $1=1
|
||||
[ "$val" == "true" ] && export $1=1
|
||||
[ "$val" = "0" ] && export $1=0
|
||||
[ "$val" = "false" ] && export $1=0
|
||||
[ "$val" = "1" ] && export $1=1
|
||||
[ "$val" = "true" ] && export $1=1
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ stop_daemon() {
|
||||
pidfile=$3
|
||||
signal=$4
|
||||
action=$5
|
||||
[[ $action == "" ]] && action="Stopping"
|
||||
[ -z "$action" ] && action="Stopping"
|
||||
echo -n "$action ceph $name on $host..."
|
||||
do_cmd "while [ 1 ]; do
|
||||
[ -e $pidfile ] || break
|
||||
@ -66,8 +66,9 @@ allhosts=0
|
||||
debug=0
|
||||
monaddr=
|
||||
dobtrfs=1
|
||||
verbose=0
|
||||
|
||||
while [[ $1 =~ '-' ]]; do # FIXME: why not '^-'?
|
||||
while echo $1 | grep -q '^-'; do # FIXME: why not '^-'?
|
||||
case $1 in
|
||||
-v | --verbose)
|
||||
verbose=1
|
||||
@ -131,17 +132,17 @@ for name in $what; do
|
||||
cmd="$BINDIR/c$type -i $id"
|
||||
|
||||
# conf file
|
||||
if [[ $host == $hostname ]]; then
|
||||
if [ "$host" = "$hostname" ]; then
|
||||
cmd="$cmd -c $conf"
|
||||
else
|
||||
if [[ ! $pushed_to =~ " $host " ]]; then
|
||||
if echo $pushed_to | grep -q " $host "; then
|
||||
scp -q $conf $host:/tmp/ceph.conf.$$
|
||||
pushed_to="$pushed_to $host "
|
||||
fi
|
||||
cmd="$cmd -c /tmp/ceph.conf.$$"
|
||||
fi
|
||||
|
||||
if [[ $name =~ "osd" ]]; then
|
||||
if echo $name | grep -q ^osd; then
|
||||
get_conf osd_data "" "osd data"
|
||||
get_conf btrfs_path "$osd_data" "btrfs path" # mount point defaults so osd data
|
||||
get_conf btrfs_devs "" "btrfs devs"
|
||||
@ -157,44 +158,44 @@ for name in $what; do
|
||||
runmode=""
|
||||
|
||||
get_conf_bool crun "$docrun" "restart on core dump"
|
||||
[[ $crun -eq 1 ]] && wrap="$BINDIR/crun"
|
||||
[ "$crun" -eq 1 ] && wrap="$BINDIR/crun"
|
||||
|
||||
get_conf_bool valgrind "$dovalgrind" "valgrind"
|
||||
[[ $valgrind -eq 1 ]] && wrap="$wrap valgrind"
|
||||
[ "$valgrind" -eq 1 ] && wrap="$wrap valgrind"
|
||||
|
||||
[[ $wrap != "" ]] && runmode="-f &"
|
||||
[ -n "$wrap" ] && runmode="-f &"
|
||||
|
||||
cmd="$wrap $cmd $runmode"
|
||||
|
||||
echo Starting ceph $name on $host...
|
||||
if [ $dobtrfs -eq 1 ]; then
|
||||
if [ $dobtrfs -eq 1 ] && [ -n "$btrfs_devs" ]; then
|
||||
get_conf pre_mount "true" "pre mount command"
|
||||
[[ $pre_mount != "" ]] && do_cmd $pre_mount
|
||||
[ -n "$pre_mount" ] && do_cmd $pre_mount
|
||||
do_cmd "mount -t btrfs $first_dev $btrfs_path"
|
||||
fi
|
||||
get_conf pre_start_eval "" "pre start eval"
|
||||
[[ $pre_start_eval != "" ]] && $pre_start_eval
|
||||
[ -n "$pre_start_eval" ] && $pre_start_eval
|
||||
get_conf pre_start "" "pre start command"
|
||||
get_conf post_start "" "post start command"
|
||||
[[ $pre_start != "" ]] && do_cmd $pre_start
|
||||
[ -n "$pre_start" ] && do_cmd $pre_start
|
||||
do_cmd "$cmd"
|
||||
[[ $post_start != "" ]] && do_cmd $post_start
|
||||
[ -n "$post_start" ] && do_cmd $post_start
|
||||
;;
|
||||
|
||||
stop)
|
||||
get_conf pre_stop "" "pre stop command"
|
||||
get_conf post_stop "" "post stop command"
|
||||
[[ $pre_stop != "" ]] && do_cmd $pre_stop
|
||||
[ -n "$pre_stop" ] && do_cmd $pre_stop
|
||||
stop_daemon $name c$type $pid_file
|
||||
[[ $post_stop != "" ]] && do_cmd $post_stop
|
||||
[ -n "$post_stop" ] && do_cmd $post_stop
|
||||
;;
|
||||
|
||||
forcestop)
|
||||
get_conf pre_forcestop "" "pre forcestop command"
|
||||
get_conf post_forcestop "" "post forcestop command"
|
||||
[[ $pre_forcestop != "" ]] && do_cmd $pre_forcestop
|
||||
[ -n "$pre_forcestop" ] && do_cmd $pre_forcestop
|
||||
stop_daemon $name c$type $pid_file -9
|
||||
[[ $post_forcestop != "" ]] && do_cmd $post_forcestop
|
||||
[ -n "$post_forcestop" ] && do_cmd $post_forcestop
|
||||
;;
|
||||
|
||||
killall)
|
||||
|
28
src/mkcephfs
28
src/mkcephfs
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh
|
||||
|
||||
# if we start up with "./", assume everything else is in the current
|
||||
# directory too.
|
||||
@ -43,22 +43,22 @@ case $1 in
|
||||
mkbtrfs=1
|
||||
;;
|
||||
--conf | -c)
|
||||
[ "$2" == "" ] && usage_exit
|
||||
[ "$2" = "" ] && usage_exit
|
||||
shift
|
||||
conf=$1
|
||||
;;
|
||||
--numosd)
|
||||
[ "$2" == "" ] && usage_exit
|
||||
[ "$2" = "" ] && usage_exit
|
||||
shift
|
||||
numosd=$1
|
||||
;;
|
||||
--crushmapsrc)
|
||||
[ "$2" == "" ] && usage_exit
|
||||
[ "$2" = "" ] && usage_exit
|
||||
shift
|
||||
usecrushmapsrc=$1
|
||||
;;
|
||||
--crushmap)
|
||||
[ "$2" == "" ] && usage_exit
|
||||
[ "$2" = "" ] && usage_exit
|
||||
shift
|
||||
usecrushmap=$1
|
||||
;;
|
||||
@ -75,7 +75,7 @@ verify_conf
|
||||
get_name_list "$@"
|
||||
|
||||
# create the monmap if we're doing mon0
|
||||
if [[ $what =~ "mon0" ]]; then
|
||||
if echo $what | grep -q mon0 ; then
|
||||
# first, make a list of monitors
|
||||
mons=`$CCONF -c $conf -l mon | egrep -v '^mon$' | sort`
|
||||
args=""
|
||||
@ -94,7 +94,7 @@ if [[ $what =~ "mon0" ]]; then
|
||||
|
||||
# build osdmap
|
||||
osdmap="/tmp/osdmap.$$"
|
||||
if [[ $numosd = "" ]]; then
|
||||
if [ -z "$numosd" ]; then
|
||||
maxosd=`$CCONF -c $conf -l osd | egrep -v '^osd$' | tail -1 | cut -c 4-`
|
||||
numosd=$(($maxosd + 1))
|
||||
echo max osd in $conf is $maxosd, num osd is $numosd
|
||||
@ -103,13 +103,13 @@ if [[ $what =~ "mon0" ]]; then
|
||||
|
||||
# import crush map?
|
||||
get_conf crushmapsrc "$usecrushmapsrc" "crush map src" mon0 mon global
|
||||
if [[ $crushmapsrc != "" ]]; then
|
||||
if [ -n "$crushmapsrc" ]; then
|
||||
echo Compiling crush map from $crushmapsrc to $crushmap
|
||||
crushmap="/tmp/crushmap.$$"
|
||||
$BINDIR/crushtool -c $crushmapsrc -o $crushmap
|
||||
fi
|
||||
get_conf crushmap "$usecrushmap" "crush map" mon0 mon global
|
||||
if [[ $crushmap != "" ]]; then
|
||||
if [ -n "$crushmap" ]; then
|
||||
echo Importing crush map from $crushmap
|
||||
$BINDIR/osdmaptool --clobber --import-crush $crushmap $osdmap
|
||||
fi
|
||||
@ -123,18 +123,18 @@ for name in $what; do
|
||||
|
||||
check_host || continue
|
||||
|
||||
if [[ $ssh != "" ]] && [[ ! $pushed_to =~ " $host " ]]; then
|
||||
if [ -n "$ssh" ] && ( echo $pushed_to | grep -q " $host " ); then
|
||||
scp -q $osdmap $host:$osdmap
|
||||
scp -q $monmap $host:$monmap
|
||||
pushed_to="$pushed_to $host "
|
||||
fi
|
||||
|
||||
if [[ $type = "mon" ]]; then
|
||||
if [ "$type" = "mon" ]; then
|
||||
get_conf mon_data "" "mon data"
|
||||
do_cmd "$BINDIR/mkmonfs $clobber --mon-data $mon_data -i $num --monmap $monmap --osdmap $osdmap"
|
||||
fi
|
||||
|
||||
if [[ $type = "osd" ]]; then
|
||||
if [ "$type" = "osd" ]; then
|
||||
get_conf osd_data "" "osd data"
|
||||
get_conf btrfs_path "$osd_data" "btrfs path" # mount point defaults so osd data
|
||||
get_conf btrfs_devs "" "btrfs devs"
|
||||
@ -144,11 +144,11 @@ for name in $what; do
|
||||
do_cmd "umount $btrfs_path ; for f in $btrfs_devs ; do umount \$f ; done ; mkfs.btrfs $btrfs_devs ; modprobe btrfs ; btrfsctl -a ; mount -t btrfs $first_dev $btrfs_path"
|
||||
fi
|
||||
|
||||
[[ $ssh != "" ]] && scp $monmap $host:$monmap
|
||||
[ -n "$ssh" ] && scp $monmap $host:$monmap
|
||||
do_cmd "$BINDIR/cosd -c $conf --monmap $monmap -i $num --mkfs --osd-data $osd_data"
|
||||
fi
|
||||
|
||||
if [[ $type = "mds" ]]; then
|
||||
if [ "$type" = "mds" ]; then
|
||||
# do nothing
|
||||
echo
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user