2022-09-29 22:29:13 +00:00
|
|
|
warn() {
|
|
|
|
(>&2 printf '\E[34mWARNING:\E[0m %s\n' "$@" )
|
|
|
|
}
|
|
|
|
|
2022-07-15 00:00:09 +00:00
|
|
|
error() {
|
|
|
|
(>&2 printf '\E[31mERROR:\E[0m %s\n' "$@" )
|
|
|
|
}
|
|
|
|
|
|
|
|
require_root() {
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
error "This script should only be run using sudo or as the root user"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-09-29 22:29:13 +00:00
|
|
|
recommend_root() {
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
warn "This script works better using sudo or as the root user"
|
|
|
|
return 3
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-07-15 00:00:09 +00:00
|
|
|
function setacl() {
|
|
|
|
if [[ $# -lt 4 ]]; then
|
|
|
|
error "setacl missing arguments, called with '$1' ${@:2}"
|
2022-08-06 00:00:36 +00:00
|
|
|
printf "%s\n" "Usage:" "\tsetacl <Options> <Ownership> <Permissions> <Path> [<Additional Paths>...]"
|
2022-07-15 00:00:09 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
local Options=${1}
|
|
|
|
local Ownership=${2}
|
|
|
|
local Permissions=${3}
|
|
|
|
|
|
|
|
[[ -n "${SZ_DEBUG}" ]] \
|
|
|
|
&& echo "chown $Options $Ownership \"${@:4}\""
|
|
|
|
chown $Options $Ownership "${@:4}"
|
|
|
|
[[ -n "${SZ_DEBUG}" ]] \
|
|
|
|
&& echo "chmod $Options $Permissions \"${@:4}\""
|
|
|
|
chmod $Options $Permissions "${@:4}"
|
|
|
|
}
|
|
|
|
|