From 0adbfeed83c1d77ffe4d9a16b82d558c26736d8a Mon Sep 17 00:00:00 2001 From: not manx Date: Sun, 14 Jun 2020 23:09:21 +0000 Subject: [PATCH] Uhh --- env/bantflags.service | 16 ++++++++++++++++ env/database.sql | 36 ++++++++++++++++++++++++++++++++++++ env/nginx.conf | 36 ++++++++++++++++++++++++++++++++++++ src/init.lisp | 9 +++++++++ 4 files changed, 97 insertions(+) create mode 100644 env/bantflags.service create mode 100644 env/database.sql create mode 100644 env/nginx.conf create mode 100644 src/init.lisp diff --git a/env/bantflags.service b/env/bantflags.service new file mode 100644 index 0000000..9487db4 --- /dev/null +++ b/env/bantflags.service @@ -0,0 +1,16 @@ +[Unit] +Description=bantflags serb + +[Service] +# Set to the location of the application +WorkingDirectory=/var/www/bantflags/src/ +ExecStart=/usr/bin/env sbcl --load init.el +Restart=always +# restarts 10 seconds after it goes bang +RestartSec=10 +KillSignal=SIGINT +SyslogIdentifier=bantflags +User=nginx + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/env/database.sql b/env/database.sql new file mode 100644 index 0000000..82d161b --- /dev/null +++ b/env/database.sql @@ -0,0 +1,36 @@ +DROP DATABASE IF EXISTS `bantflags`; +CREATE DATABASE `bantflags`; + +CREATE USER IF NOT EXISTS flags@localhost IDENTIFIED BY 'default'; +GRANT ALL PRIVILEGES ON bantflags.* TO flags@localhost; +FLUSH PRIVILEGES; + +USE `bantflags`; + +CREATE TABLE `flags` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `flag` varchar(100) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `flag` (`flag`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; + +CREATE TABLE `posts` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `post_nr` int(10) NOT NULL DEFAULT '0', + `board` varchar(10) NOT NULL DEFAULT 'bant', + PRIMARY KEY (`id`), + UNIQUE KEY `post_nr_board` (`post_nr`,`board`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; + +CREATE TABLE `postflags` ( + `id` int(10) NOT NULL AUTO_INCREMENT, + `post_nr` int(10) NOT NULL DEFAULT '0', + `flag` int(10) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `flag` (`flag`), + KEY `post_nr` (`post_nr`), + CONSTRAINT `flag` FOREIGN KEY (`flag`) REFERENCES `flags` (`id`) ON DELETE CASCADE, + CONSTRAINT `post_nr` FOREIGN KEY (`post_nr`) REFERENCES `posts` (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; + +INSERT INTO `flags` (`flag`) VALUES ('empty, or there were errors. Re-set your flags.'); diff --git a/env/nginx.conf b/env/nginx.conf new file mode 100644 index 0000000..0dd81e5 --- /dev/null +++ b/env/nginx.conf @@ -0,0 +1,36 @@ +events { + worker_connections 768; +} + +http { + types { + text/html html htm shtm; + text/css css; + image/gif gif; + image/jpeg jpg jpeg; + image/png png; + } + + default_type application/octet-stream; + sendfile on; + tcp_nopush on; + charset utf-8; + index index.html; + + server { + root /var/www/flags; + server_name flags.plum.moe; + listen 80; + + location / { + proxy_pass http://127.0.0.1:5000; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $http_connection; + proxy_cache_bypass $http_upgrade; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_http_version 1.1; + } + } +} diff --git a/src/init.lisp b/src/init.lisp new file mode 100644 index 0000000..7bfd356 --- /dev/null +++ b/src/init.lisp @@ -0,0 +1,9 @@ +;; This needs to be run with a lisp started in the same directory as +;; bantflags +(push (truename ".") ql:*local-project-directories*) +(ql:register-local-projects) +(ql:quickload :bantflags) + +(bantflags:main) +(hunchentoot:start bantflags:*serb*) +(loop (sleep 43200) (gc :full t))