2020-05-10 18:37:28 +02:00
|
|
|
(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)
|
2020-05-11 13:59:02 +02:00
|
|
|
#:use-module (guix build utils)
|
2020-05-10 18:37:28 +02:00
|
|
|
#: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")))))
|
|
|
|
|
2020-05-11 13:59:02 +02:00
|
|
|
(define (%mastostart-activation config)
|
|
|
|
"Ritorna una gexp di attivazione per MastodonStartpage database server."
|
|
|
|
#~(begin
|
|
|
|
(use-modules (ice-9 popen)
|
|
|
|
(guix build utils))
|
|
|
|
(let* ((mustard.ini
|
|
|
|
(string-append #$mastostart "/web/mustard/sec/mustard.ini"))
|
|
|
|
(crawler.ini
|
|
|
|
(string-append #$mastostart "/web/mustard/crawler/php.ini"))
|
|
|
|
(memory-limit
|
|
|
|
#$(mastostart-configuration-memory-limit config))
|
|
|
|
(test-email
|
|
|
|
#$(mastostart-configuration-test-email config))
|
|
|
|
(reference-email
|
|
|
|
#$(mastostart-configuration-reference-email config)))
|
|
|
|
(call-with-output-file crawler.ini
|
|
|
|
(lambda (port)
|
|
|
|
(display (string-append "memory_limit="
|
|
|
|
memory-limit
|
|
|
|
"\n")
|
|
|
|
port)))
|
|
|
|
(rename-file (string-append #$mastostart
|
|
|
|
"/web/mustard/sec/mustard.ini.sample")
|
|
|
|
mustard.ini)
|
|
|
|
(substitute* mustard.ini
|
|
|
|
(("pippo@pippo\\.pip")
|
|
|
|
reference-email)
|
|
|
|
(("peppe@peppe\\.pep")
|
|
|
|
test-email)))))
|
|
|
|
|
2020-05-10 18:37:28 +02:00
|
|
|
(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.")
|
2020-05-11 13:59:02 +02:00
|
|
|
(start (with-imported-modules '((ice-9 ftw))
|
|
|
|
#~(lambda _
|
|
|
|
(use-modules (ice-9 ftw))
|
|
|
|
(if (equal? (scandir #$webroot) '("." ".."))
|
|
|
|
(begin
|
|
|
|
(invoke #$(file-append coreutils "/bin/rm") "-rf"
|
|
|
|
#$webroot)
|
|
|
|
(invoke #$(file-append coreutils "/bin/ln") "-s"
|
|
|
|
#$(file-append mastostart "/web")
|
|
|
|
#$webroot))
|
|
|
|
#t))))
|
2020-05-10 18:37:28 +02:00
|
|
|
(stop #~(make-kill-destructor))))))
|
|
|
|
|
|
|
|
(define mastostart-service-type
|
|
|
|
(service-type
|
|
|
|
(name 'mastostart)
|
|
|
|
(extensions
|
|
|
|
(list (service-extension account-service-type
|
|
|
|
(const %mastostart-accounts))
|
2020-05-11 13:59:02 +02:00
|
|
|
;; (service-extension activation-service-type
|
|
|
|
;; %mastostart-activation)
|
2020-05-10 18:37:28 +02:00
|
|
|
(service-extension shepherd-root-service-type
|
|
|
|
mastostart-shepherd-service)))
|
|
|
|
(default-value (mastostart-configuration))))
|