check-exec.sh
#! /bin/bash
function read_dir(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
file "${1}/${file}" | grep -q 'text'
retval=$?
if [ $retval -eq 0 -a -x "${1}/${file}" ]; then
# echo $1"/"$file >>xfile.txt
res=`echo $1"/"$file | sed 's/^.*'$dirPathname'//g'`
if [ -f exec-list.txt ]; then
rm exec-list.txt
fi
echo ${res#*/} >> exec-list.txt
else
echo $1"/"$file "no"
fi
fi
done
}
path1=`pwd`
path2=${path1%/*}
path3=${path2%/*}
path=${path3%/*}
dirPathname=${path##*/}
echo $dirPathname
read_dir $path
restore-exec.sh
#!/bin/bash
path1=`pwd`
path2=${path1%/*}
path3=${path2%/*}
path=${path3%/*}
#echo $path
while read line;do
# echo $path"/"$line
if [ ! -x $path"/"$line ]; then
finalpath1=$path"/"$line
finalpath=${finalpath1%/*}
resfile=${finalpath1##*/}
find $finalpath -name $resfile | xargs chmod 755
echo $resfile "yes 已修复权限"
fi
done < exec-list.txt
check-softlink.sh
#!/bin/bash
path1=`pwd`
path2=${path1%/*}
path3=${path2%/*}
path=${path3%/*}
dirPathname=${path##*/}
if [ -f softlink-list.txt ]; then
rm softlink-list.txt
fi
find $path -maxdepth 20 -type l | xargs ls -l | awk '{for(i=1;i<=8;i++){$i=""};print $0}' | sed 's/^\s*//g' | sed 's/^.*'$dirPathname'//g' | sed 's/^\///g' >> softlink-list.txt
#while read line; do
# `${line#*/}` >> softlink-list.txt
#done < softlink-list.txt
restore-softlink.sh
#!/bin/bash
path1=`pwd`
path2=${path1%/*}
path3=${path2%/*}
path=${path3%/*}
while read i; do
softlink1=`echo $i | awk '{print $1}'` #软链接路径
softlink2=$path"/"$softlink1 #实际的软链接路径
softlink=${softlink2%/*} #软链接目录名
#echo $softlink
softname=$(basename $softlink2) #软链接名字
#-----------处理软链接路径 end------------------------------------#
#-----------处理源文件路径 start----------------------------------#
srcpath=`echo $i | awk '{print $3}'`
# echo $srcpath
echo $softlink
cd $softlink
if [ -f $softname ]; then
if [ -h $softname ]; then
echo $softname "软链接已存在"
else
rm $softname
fi
else
ln -s $srcpath $softname
fi
echo $softname "yes 已修复" >> modifysoft.txt
# if [[ $srcpath1 == ..* ]]; then
# srcfile1=${softlink%/*}
# srcfile2=${srcfile1%/*} #源文件路径的上一级目录
# srcfile3=${srcpath1#*/}
# srcfile=$srcfile2"/"$srcfile3 #处理的源文件路径
# else
# srcfile1=${softlink%/*}
# srcfile=$srcfile1"/"$srcpath1 #如果同级目录下
# fi
# echo $srcfile
#-----------处理源文件路径 end------------------------------------#
#-----------处理是否为软链接 并修复 start------------------------#
# resfile=${softlink##*/}
# ln -s $srcfile $softlink
# echo $resfile "yes 已修复软链接" >> modifysoft.txt
done < softlink-list.txt