#!/bin/bash - 
#===============================================================================
#
#          FILE:  ctasd-setfile
# 
#         USAGE:  ./ctasd-setfile
# 
#   DESCRIPTION:  This is to set Permission for all ctasd config files
# 
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Jithesh B (jithesh@glowtouch.com), 
#  ORGANIZATION: Glowtouch
#       CREATED: 01/02/2012 02:58:16 PM PST
#      REVISION:  ---
#===============================================================================
#
# Its a code to update file permission
# Usage gtchown <file with full path> <set or unset>
# to set : 1
# to unset: 0
# eg. gtchown /home/test.php 1
#
if [ -z $1 ]; then
    echo "....1..."
    echo "Error:: Usage problem..."
    echo "Usage: Usage gtchown <file with full path> <set or unset>"
    echo "........"
    exit
fi
if [ -z $2 ]; then
    echo "....2..."
    echo "Error:: Usage problem..."
    echo "Usage: Usage gtchown <file with full path> <set or unset>"
    echo "........"
    exit
fi

GTCHOWN="$(which chown)"
GTCHMOD="$(which chmod)"
PATHFILE=$1

[ -e "$1" ] || exit 0

if [ $2 = 1 ]; then
    FOLDE=`$GTCHMOD -Rf 777 /etc/ctasd`
    MSSG=`$GTCHOWN -R psaadm:psaadm $PATHFILE`
    #echo "Set permission fot psa" $PATHFILE
elif [ $2 = 0 ]; then
    MSSG=`$GTCHOWN -R root:root $PATHFILE`
    FOLDE=`$GTCHMOD -Rf 600 /etc/ctasd`
    chmod 755 /etc/ctasd
    chmod 644 /etc/ctasd/senderid_*
    #echo "Set permission fot root" $PATHFILE
else
    echo "Error:: Usage problem..."
    echo "Sttus missing pass 1 for set and 0 for unset"
fi
# End

