1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-11-18 06:08:21 +00:00

Use stat to get owner of /var/log

This commit is contained in:
DL6ER 2017-01-27 14:28:59 +01:00
parent 6fd7e0311c
commit 2c16a75ef1
No known key found for this signature in database
GPG Key ID: BB8EC0BC77973A30

View File

@ -939,10 +939,16 @@ installLogrotate() {
echo ":::"
echo -n "::: Installing latest logrotate script..."
cp /etc/.pihole/advanced/logrotate /etc/pihole/logrotate
# Raspbian will use the default "su root root"
# Ubuntu will use a custom user/group "su root syslog"
# We read the global config file and copy what we find into our file
echo $(sed '/^su/!d' /etc/logrotate.conf) >> /etc/pihole/logrotate
# Different operating systems have different user / group
# settings for logrotate that makes it impossible to create
# a static logrotate file that will work with e.g.
# Rasbian and Ubuntu at the same time. Hence, we have to
# customize the logrotate script here in order to reflect
# the local properties of the /var/log directory
logusergroup="$(stat -c '%U %G' /var/log)"
if [[ ! -z $logusergroup ]]; then
echo "su ${logusergroup}" >> /etc/pihole/logrotate
fi
echo " done!"
}