From 2c16a75ef16087a071441153a45e5cb1db29e515 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 27 Jan 2017 14:28:59 +0100 Subject: [PATCH] Use stat to get owner of /var/log --- automated install/basic-install.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 85bcd40a..a98eb3aa 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -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!" }