mirror of https://github.com/samply/bridgehead.git
Move checkOwner() to functions.sh
This commit is contained in:
parent
ff3d6fb4fe
commit
57483e78d4
|
@ -7,6 +7,15 @@ exitIfNotRoot() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkOwner(){
|
||||||
|
COUNT=$(find $1 ! -user $2 |wc -l)
|
||||||
|
if [ $COUNT -gt 0 ]; then
|
||||||
|
log ERROR "$COUNT files in $1 are not owned by user $2. Run find $1 ! -user $2 to see them, chown -R $2 $1 to correct this issue."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
echo -e "$(date +'%Y-%m-%d %T')" "$1:" "$2"
|
echo -e "$(date +'%Y-%m-%d %T')" "$1:" "$2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,13 @@
|
||||||
|
|
||||||
source lib/functions.sh
|
source lib/functions.sh
|
||||||
|
|
||||||
checkOwner(){
|
|
||||||
## Check for file permissions
|
|
||||||
COUNT=$(find $1 ! -user $2 |wc -l)
|
|
||||||
if [ $COUNT -gt 0 ]; then
|
|
||||||
log ERROR "$COUNT files in $1 are not owned by user $2. Run find $1 ! -user $2 to see them, chown -R $2 $1 to correct this issue."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
if ! id "bridgehead" &>/dev/null; then
|
if ! id "bridgehead" &>/dev/null; then
|
||||||
log ERROR "User bridgehead does not exist. Please consult readme for installation."
|
log ERROR "User bridgehead does not exist. Please consult readme for installation."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
checkOwner . bridgehead
|
checkOwner . bridgehead || exit 1
|
||||||
checkOwner /etc/bridgehead bridgehead
|
checkOwner /etc/bridgehead bridgehead || exit 1
|
||||||
|
|
||||||
## Check if user is a su
|
## Check if user is a su
|
||||||
log INFO "Checking if all prerequisites are met ..."
|
log INFO "Checking if all prerequisites are met ..."
|
||||||
|
|
Loading…
Reference in New Issue