Test script for directory and file permissions.
This commit is contained in:
parent
fb0f8f3d43
commit
fda7c2e7ad
2 changed files with 102 additions and 1 deletions
98
check_permissions.sh
Executable file
98
check_permissions.sh
Executable file
|
@ -0,0 +1,98 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Script checking the right permissions for software installations:
|
||||||
|
# Ordinary files must at least have permissions 664 and directories 755.
|
||||||
|
#
|
||||||
|
# Christoph Niethammer <christoph.niethammer@web.de> (C) 2011
|
||||||
|
#
|
||||||
|
|
||||||
|
declare -r APP_NAME="${0##*/}"
|
||||||
|
declare -r VERSION="0.8"
|
||||||
|
declare SEARCH_DIRS=
|
||||||
|
declare VERBOSE=0
|
||||||
|
declare PRINT_FILES=0
|
||||||
|
declare PRINT_DIRS=0
|
||||||
|
declare -r FILE_PERMS="! -perm -664"
|
||||||
|
declare -r DIR_PERMS="! -perm 775"
|
||||||
|
|
||||||
|
|
||||||
|
function print_usage {
|
||||||
|
|
||||||
|
binary=`basename $0`
|
||||||
|
cat <<EOF
|
||||||
|
${APP_NAME}: (${VERSION})
|
||||||
|
|
||||||
|
Copyright (C) 2010-2011 Christoph Niethammer <christoph.niethammer@web.de>
|
||||||
|
|
||||||
|
Usage: $APP_NAME DIR
|
||||||
|
|
||||||
|
-h, --help Print this usage
|
||||||
|
-v, --verbose Be more verbose (print list of found directories and files)
|
||||||
|
|
||||||
|
Checks permissions in the given directories. Permissions for files must be
|
||||||
|
at least set to 664 and for directories must be exactly 775.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
function die {
|
||||||
|
echo $1
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
for arg in $@; do
|
||||||
|
case $arg in
|
||||||
|
--help|-h)
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--verbose|-v)
|
||||||
|
VERBOSE=1
|
||||||
|
PRINT_FILES=1
|
||||||
|
PRINT_DIRS=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ ! -d $arg ]]; then
|
||||||
|
echo "# Skipped $arg"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
SEARCH_DIRS+="${IFS}${arg}"
|
||||||
|
#echo "# Added $arg"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "# Searching for directories which do not match '$DIR_PERMS' ..."
|
||||||
|
WRONG_DIRS=(`find $SEARCH_DIRS -type d $DIR_PERMS -print`)
|
||||||
|
echo "# Searching for files which do not match '$FILE_PERMS' ..."
|
||||||
|
WRONG_FILES=(`find $SEARCH_DIRS -type f $FILE_PERMS -print`)
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $PRINT_FILES -eq 1 ]]; then
|
||||||
|
echo "# ** directories with wrong permissions:"
|
||||||
|
for dir in ${WRONG_DIRS[@]}; do
|
||||||
|
echo $dir
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "# ** files with wrong permissions:"
|
||||||
|
for file in ${WRONG_FILES[@]}; do
|
||||||
|
echo $file
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "#"
|
||||||
|
echo "# ------------------------------"
|
||||||
|
echo "# Summary:"
|
||||||
|
echo "# directories with wrong permissions: ${#WRONG_DIRS[@]}"
|
||||||
|
echo "# files with wrong permissions: ${#WRONG_FILES[@]}"
|
||||||
|
echo "# ------------------------------"
|
||||||
|
echo "#"
|
||||||
|
|
||||||
|
# clean up temporary files
|
||||||
|
#rm $WRONG_DIR_FILE
|
||||||
|
#rm $WRONG_FILES_FILE
|
|
@ -13,7 +13,8 @@ echo $SIT_DIR
|
||||||
export SRC_POOL=${HOME}/src
|
export SRC_POOL=${HOME}/src
|
||||||
export WORKDIR_BASE=${HOME}/work
|
export WORKDIR_BASE=${HOME}/work
|
||||||
|
|
||||||
PREFIX=$HOME/bin/local
|
#PREFIX=$HOME/bin/local
|
||||||
|
PREFIX=/opt/amtopt/autotools/local
|
||||||
MAKEOPTS="-j4"
|
MAKEOPTS="-j4"
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,6 +106,8 @@ P=autoconf-${AUTOCONF_VERSION}
|
||||||
A=${P}.tar.gz
|
A=${P}.tar.gz
|
||||||
sit_auto_install
|
sit_auto_install
|
||||||
|
|
||||||
|
export PATH=$PREFIX/bin:$PATH
|
||||||
|
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
|
||||||
# install automake
|
# install automake
|
||||||
P=automake-${AUTOMAKE_VERSION}
|
P=automake-${AUTOMAKE_VERSION}
|
||||||
A=${P}.tar.bz2
|
A=${P}.tar.bz2
|
||||||
|
|
Loading…
Reference in a new issue