Merge pull request #78 from phillxnet/logdir_owner
When creating our log directory we should set its owner:group to that of the log file owner
This commit is contained in:
commit
c12bca41e0
2 changed files with 12 additions and 1 deletions
|
|
@ -233,13 +233,16 @@ CLEAN_UP_VARIABLE="4"
|
|||
#REMOVE_INCREMENTALS_OLDER_THAN="4"
|
||||
|
||||
# LOGFILE INFORMATION DIRECTORY
|
||||
# Provide directory for logfile, ownership of logfile, and verbosity level.
|
||||
# Provide directory for logfile, ownership of logfile & directory, and verbosity level.
|
||||
# I run this script as root, but save the log files under my user name --
|
||||
# just makes it easier for me to read them and delete them as needed.
|
||||
|
||||
LOGDIR="/home/foobar_user_name/logs/test2/"
|
||||
LOG_FILE="duplicity-`date +%Y-%m-%d_%H-%M`.txt"
|
||||
LOG_FILE_OWNER="foobar_user_name:foobar_user_name"
|
||||
# Note that if the configured LOGDIR does not exist it will be created
|
||||
# and its owner:group set to that of the configured LOG_FILE_OWNER.
|
||||
# If the configured LOGDIR already exists no change to owner:group is attempted.
|
||||
#REMOVE_LOGS_OLDER_THAN='30' # (days) uncomment to activate
|
||||
VERBOSITY="-v3"
|
||||
|
||||
|
|
|
|||
|
|
@ -281,6 +281,14 @@ check_logdir()
|
|||
else
|
||||
echo "Directory ${LOGDIR} successfully created."
|
||||
fi
|
||||
echo "Attempting to change owner:group of ${LOGDIR} to ${LOG_FILE_OWNER} ..."
|
||||
if ! chown ${LOG_FILE_OWNER} ${LOGDIR}; then
|
||||
echo "User ${USER} could not change the owner:group of ${LOGDIR} to $LOG_FILE_OWNER"
|
||||
echo "Aborting..."
|
||||
exit 1
|
||||
else
|
||||
echo "Directory ${LOGDIR} successfully changed to owner:group of ${LOG_FILE_OWNER}"
|
||||
fi
|
||||
elif [ ! -w ${LOGDIR} ]; then
|
||||
echo "Log directory ${LOGDIR} is not writeable by this user: ${USER}"
|
||||
echo "Aborting..."
|
||||
|
|
|
|||
Loading…
Reference in a new issue