2020-04-27 05:44:48 +00:00
|
|
|
#!/usr/bin/env racket
|
|
|
|
#lang racket
|
|
|
|
; vim: ft=racket
|
|
|
|
|
|
|
|
(require db
|
|
|
|
crypto
|
|
|
|
crypto/libcrypto
|
2020-05-04 05:54:07 +00:00
|
|
|
net/base64
|
|
|
|
"../private/prefs.rkt"
|
|
|
|
"../private/taskq.rkt")
|
2020-04-27 05:44:48 +00:00
|
|
|
|
2020-05-02 00:01:47 +00:00
|
|
|
(when (file-exists? "version")
|
|
|
|
(displayln "current directory contains data")
|
|
|
|
(exit))
|
2020-04-27 20:56:21 +00:00
|
|
|
|
2020-04-27 05:44:48 +00:00
|
|
|
; cache dirs
|
|
|
|
(make-directory "cache")
|
|
|
|
(make-directory "cache/actors")
|
2020-05-09 06:37:19 +00:00
|
|
|
(make-directory "cache/posts")
|
2020-04-27 05:44:48 +00:00
|
|
|
|
|
|
|
; db dirs
|
|
|
|
(make-directory "db")
|
|
|
|
(make-directory "db/followers")
|
|
|
|
(make-directory "db/comments")
|
|
|
|
(make-directory "db/posted")
|
|
|
|
|
|
|
|
; actor keys
|
|
|
|
(define PK-BEGIN "-----BEGIN PUBLIC KEY-----")
|
|
|
|
(define PK-END "-----END PUBLIC KEY-----")
|
|
|
|
(crypto-factories (list libcrypto-factory))
|
|
|
|
(define actor-key (generate-private-key 'rsa '((nbits 4096))))
|
|
|
|
(with-output-to-file
|
|
|
|
"db/actorkey"
|
|
|
|
(lambda ()
|
|
|
|
(write-bytes (pk-key->datum actor-key 'PrivateKeyInfo))
|
|
|
|
(void)))
|
|
|
|
(with-output-to-file
|
|
|
|
"db/actorkey.pub"
|
|
|
|
(lambda ()
|
|
|
|
(write-bytes (string->bytes/utf-8 PK-BEGIN))
|
|
|
|
(write-bytes #"\n")
|
|
|
|
(define pem (pk-key->datum actor-key 'SubjectPublicKeyInfo))
|
|
|
|
(write-bytes (base64-encode pem))
|
|
|
|
(write-bytes (string->bytes/utf-8 PK-END))
|
|
|
|
(void)))
|
|
|
|
|
|
|
|
; src and public
|
|
|
|
(make-directory "src")
|
2020-05-04 05:54:07 +00:00
|
|
|
|
2020-05-02 08:17:22 +00:00
|
|
|
(with-output-to-file "src/instance.rktd"
|
2020-05-04 05:54:07 +00:00
|
|
|
(lambda () (prefs-save DEFAULT-PREFS) (void)))
|
2020-05-02 00:01:47 +00:00
|
|
|
(with-output-to-file "src/bio.md"
|
|
|
|
(lambda ()
|
|
|
|
(write-string "this section left intentionally blank")
|
|
|
|
(void)))
|
2020-05-14 20:39:57 +00:00
|
|
|
(with-output-to-file "src/style.sass"
|
|
|
|
(lambda () (write-string "// styles go here :P") (void)))
|
2020-04-27 23:15:59 +00:00
|
|
|
(make-directory "src/posts")
|
|
|
|
|
2020-04-27 05:44:48 +00:00
|
|
|
(make-directory "public")
|
2020-04-27 23:15:59 +00:00
|
|
|
(make-directory "public/posts")
|
2020-05-02 08:17:22 +00:00
|
|
|
(make-directory "public/tags")
|
|
|
|
|
|
|
|
(make-directory "nginx")
|
2020-04-27 05:44:48 +00:00
|
|
|
|
|
|
|
; task queue
|
2020-05-04 05:54:07 +00:00
|
|
|
(taskq-shutdown (make-taskq "taskq.sqlite3" #t))
|
2020-05-02 00:01:47 +00:00
|
|
|
|
|
|
|
(with-output-to-file "version" (lambda () (write-string "1.0") (void)))
|
|
|
|
|
|
|
|
(displayln "done")
|