Add log rotation

Julien LepillerThu Jan 30 03:54:00+0100 2020

38bb184

Add log rotation

modules/config/os.scm

4646
  #:use-module (gnu system locale)
4747
  #:use-module (gnu system shadow)
4848
  #:use-module (guix gexp)
49+
  #:use-module (config rotation)
4950
  #:export (server-services
5051
            desktop-services
5152
            tyreunom-os

5354
5455
(define (server-services host-name)
5556
  (cons*
57+
    server-rotation-service
5658
    (service ntp-service-type)
5759
    (service openssh-service-type
5860
	     (openssh-configuration

7678
      (qemu-binfmt-configuration
7779
	(platforms (lookup-qemu-platforms "arm" "aarch64" "i686" "ppc"))
7880
	(guix-support? #t)))
81+
    desktop-rotation-service
7982
    (modify-services %desktop-services
8083
      (udev-service-type config =>
8184
        (udev-configuration

modules/config/rotation.scm unknown status 1

1+
;;; Tyreunom's system administration and configuration tools.
2+
;;;
3+
;;; Copyright ?? 2019 Julien Lepiller <julien@lepiller.eu>
4+
;;;
5+
;;; This program is free software: you can redistribute it and/or modify
6+
;;; it under the terms of the GNU General Public License as published by
7+
;;; the Free Software Foundation, either version 3 of the License, or
8+
;;; (at your option) any later version.
9+
;;;
10+
;;; This program is distributed in the hope that it will be useful,
11+
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13+
;;; GNU General Public License for more details.
14+
;;;
15+
;;; You should have received a copy of the GNU General Public License
16+
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
17+
18+
;;
19+
;; Definition of rotation policies
20+
;;
21+
22+
(define-module (config rotation)
23+
  #:use-module (gnu services)
24+
  #:use-module (gnu services admin)
25+
  #:export (server-rotation-service
26+
            desktop-rotation-service))
27+
28+
(define base-rotations
29+
  (list
30+
    (log-rotation
31+
      ;; What about /var/log/guix?
32+
      (files '("/var/log/guix-daemon.log"))
33+
      (frequency 'daily)
34+
      (options '("rotate 1" "log_rotate")))
35+
    (log-rotation
36+
      (files '("/var/log/mcron.log"))
37+
      (frequency 'weekly)
38+
      (options '("rotate 2" "log_rotate")))
39+
    (log-rotation
40+
      (files
41+
        (map
42+
          (lambda (<>) (string-append "/var/log/" <>))
43+
          '("debug" "lastlog" "messages" "secure" "wtmp")))
44+
      (frequency 'weekly)
45+
      (options '("rotate 4" "log_rotate")))
46+
    (log-rotation
47+
      (files '("/var/log/shepherd.log"))
48+
      (frequency 'daily)
49+
      (options '("rotate 1" "log_rotate")))))
50+
51+
(define server-rotation-service
52+
  (service rottlog-service-type
53+
    (rottlog-configuration
54+
      (rotations
55+
        (append
56+
          (list
57+
            (log-rotation
58+
              (files '("/var/log/letsencrypt/letsencrypt.log"))
59+
              (frequency 'daily)
60+
              (options '("rotate 30" "log_rotate" "nocompress")))
61+
            (log-rotation
62+
              (files '("/var/log/maillog"))
63+
              (options '("rotate 5" "log_rotate"))
64+
              (frequency 'daily))
65+
            (log-rotation
66+
              (files '("/var/log/nginx/access.log" "/var/log/nginx/error.log"))
67+
              (frequency 'weekly)
68+
              (options '("rotate 1" "log_rotate" "nocompress"))))
69+
          base-rotations)))))
70+
71+
(define desktop-rotation-service
72+
  (service rottlog-service-type
73+
    (rottlog-configuration
74+
      (rotations base-rotations))))