Browse Source

mastostart-gnu: Agginto mastostart-service.

* mastostart-gnu/services/mastostart.scm: Nuovo file,
(mastostart-service): Nuova variabile,
(mastostart-configuration): Nuova variabile.
Giacomo Leidi 4 years ago
parent
commit
dd46539c94
2 changed files with 74 additions and 2 deletions
  1. 64 0
      mastostart-gnu/services/mastostart.scm
  2. 10 2
      mastostart-gnu/system/mastostart.scm

+ 64 - 0
mastostart-gnu/services/mastostart.scm

@@ -0,0 +1,64 @@
+(define-module (mastostart-gnu services mastostart)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+  #:use-module (gnu system shadow)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages base)
+  #:use-module (guix records)
+  #:use-module (guix gexp)
+  #:use-module (mastostart-gnu packages mastostart)
+  #:export (mastostart-service
+            mastostart-service-type
+            mastostart-configuration
+            mastostart-configuration?))
+
+(define-record-type* <mastostart-configuration>
+  mastostart-configuration make-mastostart-configuration
+  mastostart-configuration?
+  (mastostart mastostart-configuration-mastostart
+              (default mastostart))
+  (webroot mastostart-configuration-webroot
+           (default "/srv"))
+  (reference-email mastostart-configuration-reference-email
+                   (default "goodoldpaul@autistici.org"))
+  (test-email mastostart-configuration-test-email
+              (default "goodoldpaul@autistici.org"))
+  (memory-limit mastostart-configuration-memory-limit
+                (default "1G")))
+
+(define %mastostart-accounts
+  (list (user-group
+         (name "mastostart")
+         (system? #t))
+        (user-account
+         (name "mastostart")
+         (group "mastostart")
+         (system? #t)
+         (home-directory "/var/empty")
+         (shell (file-append shadow "/sbin/nologin")))))
+
+(define (mastostart-shepherd-service config)
+  (list
+   (let ((mastostart (mastostart-configuration-mastostart config))
+         (webroot (mastostart-configuration-webroot config)))
+     (shepherd-service
+      (provision '(mastostart))
+      (one-shot? #t)
+      (requirement '(httpd mysql))
+      (documentation "Start serving the MastodonStartpage.")
+      (start #~(make-forkexec-constructor
+                (list (string-append #$coreutils "/bin/ln")
+                      "-s"
+                      (string-append #$mastostart "/web/")
+                      #$webroot)))
+      (stop #~(make-kill-destructor))))))
+
+(define mastostart-service-type
+  (service-type
+   (name 'mastostart)
+   (extensions
+    (list (service-extension account-service-type
+                             (const %mastostart-accounts))
+          (service-extension shepherd-root-service-type
+                             mastostart-shepherd-service)))
+   (default-value (mastostart-configuration))))

+ 10 - 2
mastostart-gnu/system/mastostart.scm

@@ -15,6 +15,8 @@
                      ssh
                      web)
 
+(define-public %apache-webroot "/srv")
+
 (define-public mastostart-conf
   (operating-system
     (locale "it_IT.utf8")
@@ -46,24 +48,30 @@
              "mariadb"
              "php"
              "rsync"))
-      `(,mastostart)
       %base-packages))
 
     (services
      (append
       (list (service dhcp-client-service-type)
+
             (mysql-service)
+
+            (service mastostart-service-type
+                     (mastostart-configuration
+                      (webroot %apache-webroot)))
+
             (service openssh-service-type
                      (openssh-configuration
                       (port-number 10022)
                       (permit-root-login #t)))
+
             (service httpd-service-type
                      (httpd-configuration
                       (config
                        (httpd-config-file
                         (server-name "127.0.0.1")
                         (listen '("8080"))
-                        (document-root "/var/www")
+                        (document-root %apache-webroot)
                         (modules (cons*
                                   (httpd-module
                                    (name "rewrite_module")