54 lines
1.3 KiB
Racket
Executable File
54 lines
1.3 KiB
Racket
Executable File
#!/usr/bin/env racket
|
|
#lang racket
|
|
; vim: ft=racket
|
|
|
|
(require db
|
|
crypto
|
|
crypto/libcrypto
|
|
net/base64)
|
|
|
|
; TODO
|
|
; if a blog tree already exists, print a nice error instead of letting make-directory error lol
|
|
|
|
; cache dirs
|
|
(make-directory "cache")
|
|
(make-directory "cache/actors")
|
|
|
|
; 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")
|
|
(make-directory "src/posts")
|
|
|
|
(make-directory "public")
|
|
(make-directory "public/posts")
|
|
|
|
; task queue
|
|
(define c (sqlite3-connect #:database "taskq.sqlite3" #:mode 'create))
|
|
(query-exec c "create table taskq (id blob(16) primary key, task blob, state integer)")
|
|
(disconnect c)
|