#!/bin/sh
#
# by ymc-geko
# set owner:group on a directory (recursive)
#


dirToAdjust=$1
theUser=$2
theGroup=$3
ymcCommand=$4

USAGE="usage: $0 directory user group {start|stop|status}";

usage()
{
  echo $USAGE >&2
}

if [ $# != 4 ]; then
  usage
  exit 1
fi

set_ownership()
{
  if [ -d "$dirToAdjust" ]; then
    chown --preserve-root $theUser:$theGroup $dirToAdjust || exit 0
  fi
  exit 0
}


case $ymcCommand in
  start)        set_ownership;;
  stop)         exit 0;;
  status)       echo "not supported" && exit 0;;
  *)            usage
                exit 1
                ;;
esac
