diff options
Diffstat (limited to 'src/init-ceph')
-rwxr-xr-x | src/init-ceph | 120 |
1 files changed, 68 insertions, 52 deletions
diff --git a/src/init-ceph b/src/init-ceph index 0441752ea39..7dc76981abd 100755 --- a/src/init-ceph +++ b/src/init-ceph @@ -1,7 +1,17 @@ #!/bin/sh # Start/stop ceph daemons -# if we start up as ./ceph-daemons, assume everything else is in the +### BEGIN INIT INFO +# Provides: ceph +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Required-Start: $local_fs $named $network $time +# Required-Stop: $local_fs $named $network $time +# Short-Description: Start Ceph distributed file system daemons at boot time +# Description: Enable Ceph distributed file system services. +### END INIT INFO + +# if we start up as ./init-ceph, assume everything else is in the # current directory too. if [ `dirname $0` = "." ] && [ $PWD != "/etc/init.d" ]; then BINDIR=. @@ -15,7 +25,7 @@ fi usage_exit() { echo "usage: $0 [options] {start|stop|restart} [mon|osd|mds]..." - printf "\t-c conffile.conf\n" + printf "\t-c ceph.conf\n" printf "\t--valgrind\trun via valgrind\n" exit } @@ -28,7 +38,9 @@ stop_daemon() { daemon=$2 pidfile=$3 signal=$4 - echo -n "Stopping ceph $name on $host..." + action=$5 + [[ $action == "" ]] && action="Stopping" + echo -n "$action ceph $name on $host..." do_cmd "while [ 1 ]; do [ -e $pidfile ] || break pid=\`cat $pidfile\` @@ -49,7 +61,7 @@ options= version=0 dovalgrind=0 -docrun=1 +docrun=0 allhosts=0 debug=0 monaddr= @@ -85,9 +97,9 @@ case $1 in dobtrfs=1 ;; --nobtrfs) - dobtrfs=1 + dobtrfs=0 ;; - --conf_file | -c) + --conf | -c) [ "$2" == "" ] && usage_exit options="$options $1" shift @@ -102,17 +114,7 @@ options="$options $1" shift done -# build mon_addr_arg with all mon addrs -n=0 -mon_addr_arg="" -while [ 1 ]; do - name="mon$n" - get_conf mon_addr "" "mon addr" $name "mon" "global" - [ "$mon_addr" == "" ] && break - mon_addr_arg="$mon_addr_arg -m $mon_addr" - n=$(($n + 1)) -done - +verify_conf command=$1 shift @@ -121,68 +123,78 @@ get_name_list "$@" for name in $what; do type=`echo $name | cut -c 1-3` # e.g. 'mon', if $item is 'mon1' - num=`echo $name | cut -c 4-` - sections="$name $type global" + id=`echo $name | cut -c 4- | sed 's/\\.//'` + num=$id check_host || continue - get_conf pid_file "/var/run/ceph/$name.pid" "pid file" $sections - get_conf conf_file "$runtime_conf" "conf file" $sections - - # extract name-specific options from $conf - if [[ $name =~ "mon" ]]; then - get_conf mon_data "" "mon data" $sections - module_opt="$mon_data" - module_bin="$BINDIR/cmon" - fi - - if [[ $name =~ "mds" ]]; then - module_opt="$mon_addr_arg" - module_bin="$BINDIR/cmds" + cmd="$BINDIR/c$type -i $id" + + # conf file + if [[ $host == $hostname ]]; then + cmd="$cmd -c $conf" + else + if [[ ! $pushed_to =~ " $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 - get_conf osd_data "" "osd data" $sections - get_conf osd_journal "" "osd journal" $sections - [ "$osd_journal" != "" ] && osd_journal_cmd="-j $osd_journal" || osd_journal_cmd="" - module_opt="$mon_addr_arg $osd_data $osd_journal_cmd" - module_bin="$BINDIR/cosd" - - get_conf btrfs_path "$osd_data" "btrfs path" $sections # mount point defaults so osd path - get_conf btrfs_devs "" "btrfs devs" $sections + 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" first_dev=`echo $btrfs_devs | cut '-d ' -f 1` fi - module_opt="-p $pid_file -c $conf_file $module_opt" + get_conf pid_file "" "pid file" case "$command" in start) # build final command wrap="" - runflags="-d" runmode="" - get_conf_bool crun "$docrun" "restart on core dump" $sections + get_conf_bool crun "$docrun" "restart on core dump" [[ $crun -eq 1 ]] && wrap="$BINDIR/crun" - get_conf_bool valgrind "$dovalgrind" "valgrind" $sections + get_conf_bool valgrind "$dovalgrind" "valgrind" [[ $valgrind -eq 1 ]] && wrap="$wrap valgrind" - [[ $wrap != "" ]] && runflags="-f" && runmode="&" + [[ $wrap != "" ]] && runmode="-f &" - cmd="$wrap $module_bin $runflags $module_opt $runmode" + cmd="$wrap $cmd $runmode" echo Starting ceph $name on $host... - [ $dobtrfs -eq 1 ] && do_cmd "btrfsctl -a ; mount -t btrfs $first_dev $btrfs_path" - do_cmd "$cmd" + if [ $dobtrfs -eq 1 ]; then + get_conf pre_mount "true" "pre mount command" + [[ $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 + get_conf pre_start "" "pre start command" + get_conf post_start "" "post start command" + [[ $pre_start != "" ]] && do_cmd $pre_start + do_cmd "$cmd" + [[ $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 stop_daemon $name c$type $pid_file + [[ $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 stop_daemon $name c$type $pid_file -9 + [[ $post_forcestop != "" ]] && do_cmd $post_forcestop ;; killall) @@ -190,20 +202,24 @@ for name in $what; do do_cmd "killall -9 c$type" ;; + force-reload | reload) + stop_daemon $name c$type $pid_file -1 "Reloading" + ;; + restart) $0 $options stop $name $0 $options start $name ;; cleanlogs) - get_conf log_dir "/var/log/ceph" "log dir" $sections - get_conf log_sym_dir "/var/log/ceph" "log sym dir" $sections + get_conf log_dir "/var/log/ceph" "log dir" + get_conf log_sym_dir "/var/log/ceph" "log sym dir" do_cmd "for f in $log_sym_dir/$name*; do rm -f \`readlink \$f\` ; rm -f \$f ; done" ;; cleanalllogs) - get_conf log_dir "/var/log/ceph" "log dir" $sections - get_conf log_sym_dir "/var/log/ceph" "log sym dir" $sections + get_conf log_dir "/var/log/ceph" "log dir" + get_conf log_sym_dir "/var/log/ceph" "log sym dir" do_cmd "rm -f $log_dir/* $log_sym_dir/*" ;; |