PS4='+{$LINENO:${FUNCTIONNAME[0]}}'
#
# If need debug, using export DEBUG=value in parrent shell environment
#
[ $DEBUG ] && set -x
info() {
echo "[INFO]: $@"
return 0
}
error() {
echo "[ERROR]: $@"
return 0
}
#
# Add execute and read permission to a directory
# Add read permission to a file
#
give_perm() {
#dirpath=$1
#dirwd=`dirname $dirpath`
local dirwd=$1
for i in `ls $dirwd`;do
local j=$dirwd/$i
if [ -d $j ]; then
info modifying permission for directory: $j
chmod a+xr $j
cd $j
give_perm $j
cd -
else
info modifying permission for file: $j
chmod a+r $j
fi
done
}
#
# Get directory's full path
#
full_path() {
local path=$1
if [ `echo $path | grep '^/'` ];then
echo $path
else
path=$PWD
echo $path
fi
}
#give_perm /u/jingleil/OpenStack/feature/CBAM_Demo/data/cbam_ocs_backup
dir=$1
[ -d $dir ] && give_perm `full_path $dir` || error "$dir is not a directory"
exit
#
# If need debug, using export DEBUG=value in parrent shell environment
#
[ $DEBUG ] && set -x
info() {
echo "[INFO]: $@"
return 0
}
error() {
echo "[ERROR]: $@"
return 0
}
#
# Add execute and read permission to a directory
# Add read permission to a file
#
give_perm() {
#dirpath=$1
#dirwd=`dirname $dirpath`
local dirwd=$1
for i in `ls $dirwd`;do
local j=$dirwd/$i
if [ -d $j ]; then
info modifying permission for directory: $j
chmod a+xr $j
cd $j
give_perm $j
cd -
else
info modifying permission for file: $j
chmod a+r $j
fi
done
}
#
# Get directory's full path
#
full_path() {
local path=$1
if [ `echo $path | grep '^/'` ];then
echo $path
else
path=$PWD
echo $path
fi
}
#give_perm /u/jingleil/OpenStack/feature/CBAM_Demo/data/cbam_ocs_backup
dir=$1
[ -d $dir ] && give_perm `full_path $dir` || error "$dir is not a directory"
exit