Compare commits

..

9 Commits

2 changed files with 13 additions and 8 deletions

View File

@ -76,21 +76,24 @@ the tiedote.md user on this system.")
"--sender-name" #$sender-name "--sender-name" #$sender-name
"--sendmail" #$sendmail-path "--sendmail" #$sendmail-path
"--socket" #$socket-path "--socket" #$socket-path
"server"
"--repository" repo-path "--repository" repo-path
"--port" #$(number->string port) "--port" #$(number->string port)
"--remote-url" #$remote-url "--remote-url" #$remote-url
;,@(if #$(maybe-value-set? remote-branch) ;,@(if #$(maybe-value-set? remote-branch)
; (list "--remote-branch" #$remote-branch) ; (list "--remote-branch" #$remote-branch)
; '()) ; '())
"server") )
#:user "tiedote.md" #:user "tiedote.md"
#:group "tiedote.md" #:group "tiedote.md"
#:environment (cons "GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt"
(default-environment-variable))
#:directory #$state-directory)))) #:directory #$state-directory))))
(stop #~(make-kill-destructor)))))) (stop #~(make-kill-destructor))))))
(define (tiedote.md-activation config) (define (tiedote.md-activation config)
(match-record config <tiedote.md-configuration> (match-record config <tiedote.md-configuration>
(state-directory) (state-directory email-address sender-name sendmail-path socket-path)
(let* ((receive-exec (list (file-append tiedote-md "/bin/tiedote.md") ; file to exec (let* ((receive-exec (list (file-append tiedote-md "/bin/tiedote.md") ; file to exec
(file-append tiedote-md "/bin/tiedote.md") ; arg $0 (file-append tiedote-md "/bin/tiedote.md") ; arg $0
"--address" email-address "--address" email-address
@ -99,9 +102,11 @@ the tiedote.md user on this system.")
"--socket" socket-path)) "--socket" socket-path))
(receive-script (program-file "tiedote.md-receive" (receive-script (program-file "tiedote.md-receive"
#~(apply execl #$receive-exec))) #~(apply execl #$receive-exec)))
(forward-file (mixed-text-file ".forward" "|" receive-script))) (forward-file (mixed-text-file "dot-forward" "|" receive-script)))
#~(symlink #$forward-file #~(let ((.forward (string-append #$state-directory "/.forward")))
(string-append #$state-directory "/.forward"))))) (if (file-exists? .forward)
(delete-file .forward))
(symlink #$forward-file .forward)))))
(define tiedote.md-service-type (define tiedote.md-service-type
(service-type (service-type

View File

@ -6,12 +6,12 @@ module Main where
import Control.Applicative (optional) import Control.Applicative (optional)
import Control.Concurrent (forkIO, threadDelay) import Control.Concurrent (forkIO, threadDelay)
import Control.Exception (onException) import Control.Exception (onException, catch)
import Control.Exception (throwIO) import Control.Exception (throwIO)
import Control.Monad (void, forever) import Control.Monad (void, forever)
import Data.Acid (AcidState(..), openLocalState, createCheckpoint, createArchive) import Data.Acid (AcidState(..), openLocalState, createCheckpoint, createArchive)
import Data.Acid.Remote (skipAuthenticationCheck, acidServerSockAddr, openRemoteStateSockAddr, skipAuthenticationPerform) import Data.Acid.Remote (skipAuthenticationCheck, acidServerSockAddr, openRemoteStateSockAddr, skipAuthenticationPerform)
import Data.FileStore (gitFileStore, initialize) import Data.FileStore (gitFileStore, initialize, FileStoreError(RepositoryExists))
import Data.IMF (Mailbox(..), parse, mailbox) import Data.IMF (Mailbox(..), parse, mailbox)
import Data.MIME.Charset (defaultCharsets) import Data.MIME.Charset (defaultCharsets)
import Data.Text.Encoding (encodeUtf8) import Data.Text.Encoding (encodeUtf8)
@ -36,7 +36,7 @@ import TiedoteMD.Debug
serverMain :: SockAddr -> Mailbox -> FilePath -> GitOrigin -> FilePath -> Int -> Int -> IO () serverMain :: SockAddr -> Mailbox -> FilePath -> GitOrigin -> FilePath -> Int -> Int -> IO ()
serverMain socket mail repoPath origin sendmailPath checkpointDelay port = do serverMain socket mail repoPath origin sendmailPath checkpointDelay port = do
initialize $ gitFileStore repoPath initialize (gitFileStore repoPath) `catch` \RepositoryExists -> pure ()
acid <- openLocalState $ emptyState acid <- openLocalState $ emptyState
_ <- forkIO $ acidServerSockAddr skipAuthenticationCheck socket acid _ <- forkIO $ acidServerSockAddr skipAuthenticationCheck socket acid
queueMessages acid queueMessages acid