#!/bin/bash

RUN_DIR=/var/vcap/sys/run/cephfs
PIDFILE=${RUN_DIR}/pid


case $1 in

  start)
        
    mkdir -p $RUN_DIR
    chown -R vcap:vcap $RUN_DIR
    status=$(ceph health | grep HEALTH_OK)
    while [ "$status" != "HEALTH_OK" ]; do
      sleep 2
      status=$(ceph health | grep HEALTH_OK)
    done

    echo `pgrep -f ceph-mon` > $PIDFILE

    # chown cephfs to vcap
    mkdir /home/vcap/cephfs
    chown vcap:vcap /home/vcap/cephfs
    ceph-fuse -m 10.0.0.106:6789 -c /etc/ceph/ceph.client.admin.keyring -r / /home/vcap/cephfs
    chown -R vcap:vcap /home/vcap/cephfs
    umount /home/vcap/cephfs
    rm -rf /home/vcap/cephfs

    ;;

  stop)
    
    kill -9 $(pgrep -f 'ceph-mds')
    kill -9 $(pgrep -f 'ceph-osd -i 0')
    kill -9 $(pgrep -f 'ceph-osd -i 1')
    kill -9 $(pgrep -f 'ceph-osd -i 2')
    kill -9 `cat $PIDFILE`
    rm -f $PIDFILE

    ;;

  *)
    echo "Usage: ctl {start|stop}" ;;

esac

#!/bin/bash

RUN_DIR=/var/vcap/sys/run/cephfs
PIDFILE=${RUN_DIR}/pid


case $1 in

  start)
        
    mkdir -p $RUN_DIR
    chown -R vcap:vcap $RUN_DIR
    status=$(ceph health | grep HEALTH_OK)
    while [ "$status" != "HEALTH_OK" ]; do
      sleep 2
      status=$(ceph health | grep HEALTH_OK)
    done

    echo `pgrep -f ceph-mon` > $PIDFILE

    # chown cephfs to vcap
    mkdir /home/vcap/cephfs
    chown vcap:vcap /home/vcap/cephfs
    ipaddr=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1  -d'/')
    ceph-fuse -m ${ipaddr}:6789 -c /etc/ceph/ceph.client.admin.keyring -r / /home/vcap/cephfs
    chown -R vcap:vcap /home/vcap/cephfs
    umount /home/vcap/cephfs
    rm -rf /home/vcap/cephfs

    ;;

  stop)
    
    kill -9 $(pgrep -f 'ceph-mds')
    kill -9 $(pgrep -f 'ceph-osd -i 0')
    kill -9 $(pgrep -f 'ceph-osd -i 1')
    kill -9 $(pgrep -f 'ceph-osd -i 2')
    kill -9 `cat $PIDFILE`
    rm -f $PIDFILE

    ;;

  *)
    echo "Usage: ctl {start|stop}" ;;

esac

Remove hardcoded ceph monitor ip from from cephfs job.
Remove hardcoded ceph monitor ip from from cephfs job.

[#119662951](http://www.pivotaltracker.com/story/show/119662951)

Signed-off-by: Nagapramod Mandagere <459b9f2da98a4f81cc141b18707e9a2669e5cf9c@us.ibm.com>
