Patchwork gnu: rottlog: rotate messages daily.

login
register
mail settings
Submitter Jan Nieuwenhuizen
Date Aug. 11, 2016, 10:52 a.m.
Message ID <87d1lfziew.fsf@gnu.org>
Download mbox | patch
Permalink /patch/14482/
State New
Headers show

Comments

Jan Nieuwenhuizen - Aug. 11, 2016, 10:52 a.m.
Hi!

Using the attached patch and the configuration below, rottlog
actually rotates /var/log/messages daily.

Greetings,
Jan

--8<---------------cut here---------------start------------->8---

(use-package-modules admin)
(use-service-modules mcron)

(define rottlog-job
  #~(job '(next-hour '(5))
         (lambda ()
           (system (string-append  #$rottlog "/sbin/rottlog")))))

(define updatedb-job
  ;; Run 'updatedb' at 3AM every day.  Here we write the
  ;; job's action as a Scheme procedure.
  #~(job '(next-hour '(3))
         (lambda ()
           (execl (string-append #$findutils "/bin/updatedb")
                  "updatedb"
                  "--prunepaths=/tmp /var/tmp /gnu/store"))))

...

(operating-system
     ...
    (services
      ...

      (mcron-service (list rottlog-job
                           updatedb-job))
     ...
))
--8<---------------cut here---------------end--------------->8---
Ludovic Courtès - Sept. 7, 2016, 9:52 a.m.
Hi!

Jan Nieuwenhuizen <janneke@gnu.org> skribis:

> Using the attached patch and the configuration below, rottlog
> actually rotates /var/log/messages daily.

Woohoo!

> From c7fc570327faeb50503494b370a2f5ab21d4049b Mon Sep 17 00:00:00 2001
> From: Jan Nieuwenhuizen <janneke@gnu.org>
> Date: Sat, 18 Jun 2016 22:37:48 +0200
> Subject: [PATCH] gnu: rottlog: rotate messages daily.
>
> * gnu/packages/admin.scm (rottlog): Set packdir in etc/rc; fixes rotating.
> Rename weekly to daily; rotates /var/log/messages daily.

I split it in several patches and pushed part of this.

‘rottlog’ was looking for config files in OUT/etc, which made it
impossible for people to configure it.  So in commit
268ad34e0eadf8a015798b5c5587aad65b9f3a61 I changed it to look for
configuration files in /etc/rottlog.

Consequently, running “rottlog” alone won’t work; one has to provide
/etc/rottlog/{rc,daily} first.  We should have a GuixSD service that
does that.

Thoughts?

Thanks,
Ludo’.
Jan Nieuwenhuizen - Sept. 7, 2016, 12:32 p.m.
Ludovic Courtès writes:

>> Using the attached patch and the configuration below, rottlog
>> actually rotates /var/log/messages daily.
>
> Woohoo!

:-)

Yeah, made me quite happy too.

>> * gnu/packages/admin.scm (rottlog): Set packdir in etc/rc; fixes rotating.
>> Rename weekly to daily; rotates /var/log/messages daily.
>
> I split it in several patches and pushed part of this.

Great, thanks.

> ‘rottlog’ was looking for config files in OUT/etc, which made it
> impossible for people to configure it.  So in commit
> 268ad34e0eadf8a015798b5c5587aad65b9f3a61 I changed it to look for
> configuration files in /etc/rottlog.
>
> Consequently, running “rottlog” alone won’t work; one has to provide
> /etc/rottlog/{rc,daily} first.  We should have a GuixSD service that
> does that.

Ah, yes configuration was the bit I was wondering about.  A service
that initializes/writes these sounds like a good idea!

Greetings,
Jan

Patch

From c7fc570327faeb50503494b370a2f5ab21d4049b Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Sat, 18 Jun 2016 22:37:48 +0200
Subject: [PATCH] gnu: rottlog: rotate messages daily.

* gnu/packages/admin.scm (rottlog): Set packdir in etc/rc; fixes rotating.
Rename weekly to daily; rotates /var/log/messages daily.
---
 gnu/packages/admin.scm | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index eada796..f8ba6ef 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -731,11 +731,21 @@  over ssh connections.")
                                               (assoc-ref %outputs "out")
                                               "/etc")
                                "--localstatedir=/var")
-       #:phases (alist-cons-after
-                 'install 'install-info
-                 (lambda _
-                   (zero? (system* "make" "install-info")))
-                 %standard-phases)))
+       #:phases (modify-phases %standard-phases
+                  (add-after 'build 'set-packdir
+                    (lambda _
+                      (substitute* "rc/rc"
+                        (("packdir=\"\"")
+                         "packdir=\"/var/log\""))))
+                  (add-after 'install 'install-daily
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((out (assoc-ref outputs "out")))
+                        (zero? (system* "mv"
+                                        (string-append out "/etc/weekly")
+                                        (string-append out "/etc/daily"))))))
+                  (add-after 'install 'install-info
+                    (lambda _
+                      (zero? (system* "make" "install-info")))))))
     (native-inputs `(("texinfo" ,texinfo)
                      ("util-linux" ,util-linux))) ; for 'cal'
     (home-page "http://www.gnu.org/software/rottlog/")
-- 
2.9.2