Dear all,
i am doing an SVN backup script. Almost done.
My problem is :
Script should run by user : svn
There is a chance to run the script by root itself.. so i coded like following
#This script path and name
if [ `dirname $0` == "." ] ; then
thisScript=`pwd`"/$0"
else
thisScript=$0
fi
echo -e "$thisScript"
if [ $USERNAME == "svn" ] ; then
FUN_CHECKPRIVILEGES
if [ $PRIVILEGE == "true" ] ; then
FUN_BACKUP
else
FUN_LOG "!!!---------Backup cannot be done.-----------!!!"
FUN_LOG "Please check the following :"
FUN_LOG "1. Permission for user $USERNAME to access all $ALLDIR"
FUN_LOG "2. Script may be running by any user other than 'svn' or 'root'"
FUN_LOG "\nExiting ENTIRE BACKUP PROCESS."
fi
else
FUN_LOG "changing user to 'svn' and running the script"
su svn -c 'sh $thisScript'
FUN_LOG "Exiting."
exit 1
fi
}
But su svn -c 'sh $thisScript' is not working correctly.
i tried all the following:
su svn -c 'sh $thisScript' --> Will go to bash$ prompt
su svn -c '$thisScript' --> Nothing will do
su - svn -c 'sh $thisScript' --> Nothing will do
su -c 'sh $thisScript' - svn --> Nothing will do
and
su svn -c 'echo "hi hi"' --> is working fine
any idea ?
.