#!/bin/bash

source /service/sbin/setup

if [ $1 == "init" ]; then 
    create_fuse_dev

    cat /service/keys/id_rsa.pub >> /root/.ssh/authorized_keys
    /usr/sbin/glusterd &
    /usr/sbin/sshd -D
elif [ $1 == "start" ]; then 
    /service/configuration/configure start
elif [ $1 == "restart" ]; then 
    /service/configuration/configure restart
elif [ $1 == "stop" ]; then 
    # Stop the gluster volume
    /service/configuration/configure stop

    # Stop the gluster daemon
    pkill -f glusterd

    # Now stop the ssh daemon. 
    pkill -f sshd
elif [ $1 == "clean" ]; then 
    /service/configuration/configure clean    
fi
