diff options
-rw-r--r-- | captain/BUILD.md | 121 | ||||
-rw-r--r-- | captain/example/levitating.xinetd | 16 | ||||
-rw-r--r-- | captain/levitating-captain.prj | 26 | ||||
-rw-r--r-- | captain/makefile.gnu | 243 |
4 files changed, 389 insertions, 17 deletions
diff --git a/captain/BUILD.md b/captain/BUILD.md new file mode 100644 index 0000000..506adc4 --- /dev/null +++ b/captain/BUILD.md @@ -0,0 +1,121 @@ +# Building the Captain + +Levitating's captain is the central server to command and control the players. +Building is relatively simple since it only relies on a few packages on Linux, +though it should work on any UNIX-y system with a modern Fortran compiler. + +## Requirements + +The captain only has three dependencies: + + * SQLite3 development libraries + * SSL development libraries + * uuidgen + +The first two are necessary for building, while the third is a runtime +dependency. These can be installed on Debian with the following command: + +``` +apt-get install libssl-dev libsqlite3-dev uuid-runtime +``` + +## Building + +Levitating can be built either using [Simply Fortran](https://simplyfortran.com/) +or using the included *makefile.gnu* makefile: + +``` +make -f makefile.gnu all +``` + +You should end up with a nice, little executable + +## Installing + +### Basic File Locations + +The produced executable is both a CGI executable and an inetd client, so it +should be installed somewhere sensible. The conventional location would be in +the */var/www/cgi-bin* directory. If you're going with the conventional route, +the */var/www/data/captain* directory would be a nice place to install the +configuration files. + +The *example* directory contains some necessary configuration files that +should be subsequently placed in the */var/www/data/captain* directory. You'll +need to edit *levitating.conf* to reflect all the directories, and you'll need +to create the directories mentioned in said file as well: + + * uploads + * results + * instructions + * releases + +One might also notice that the captain configuration file mentions some static +files. These should be copied from the *example* directory to the +configured static directory. + +The *sql* directory can contain scripts that the server may have to run. This +directory should also be copied to the data folder. + +Finally, be sure to copy the *templates* directory to the subsequent data +directory as well. + +### Initialize the Database + +Wherever you've decided to store the database, probably in +*/var/www/data/captain/store.db* if you're following the suggestions, you need +manually initialize it with the following command: + +``` +sqlite3 /var/www/data/captain/store.db < create.sql +``` + +### Configuring Gemini and Titan Passthrough + +Regardless of your thoughts on the [Gemini protocol](https://geminiprotocol.net/), +Levitating relies on it for all file transfers to/from players. The server +hosting the captain must therefore be configured in a proper inetd server to +accept and handle requests on port 1965. + +Gemini, however, isn't a standard protocol. You might need to let Linux know +what the hell it is in */etc/services* if you're using an old inetd superserver. + +If you're starting from scratch, though, we'd recommned using xinetd. On +Debian, it's a quick command away: + +``` +apt-get install xinetd +``` + +Next, you can copy the example service configuration file *example/levitating.xinetd* +to */etc/xinetd.d/levitating* and edit it appropriately. + +### Generate Certificates for Gemini and Titan + +Gemini (and Titan) are encrypted protocols that require self-signed certificates +to operate. While you could use a legitimate, third-party certificate, there's +really no need in this case. The command is: + +``` +openssl req -newkey rsa:4096 -x509 -sha512 -days 2048 -nodes -out pub.crt -keyout priv.key +``` + +Note that the "days" argument is pretty long. We don't really want to have to +do this again. + +### Create an Admin + +Our last basic installation step is to create a single user: + +``` +/var/www/cgi-bin/levitating-captain -c /var/www/data/captain/levitating.conf --new-admin margaux password +``` + +### Optional: Web Interface + +You'll probably want to configure the web interface to Levitating if you're not +planning on doing everything via Gemini. This involves configuring a web server +to execute a CGI executable properly. The process depends heavily on the server +software the user has available, but one will probably want to use Apache or +Lighttpd. Nginx does not support CGI at all. + diff --git a/captain/example/levitating.xinetd b/captain/example/levitating.xinetd index 16eb0a1..bdb7b45 100644 --- a/captain/example/levitating.xinetd +++ b/captain/example/levitating.xinetd @@ -3,14 +3,14 @@ service gemini { - type = UNLISTED - port = 1965 - socket_type = stream - protocol = tcp - wait = no - user = pi - disable = no + type = UNLISTED + port = 1965 + socket_type = stream + protocol = tcp + wait = no + user = pi + disable = no server = /home/jeff/Workspace/levitating/captain/levitating-captain - server_args = -g -c /home/jeff/Workspace/levitating/captain/example/levitating.conf + server_args = -g -c /home/jeff/Workspace/levitating/captain/example/levitating.conf instances = 30 } diff --git a/captain/levitating-captain.prj b/captain/levitating-captain.prj index 9eda195..014c4c5 100644 --- a/captain/levitating-captain.prj +++ b/captain/levitating-captain.prj @@ -8,7 +8,7 @@ "Root":{ "Folders":[{ "Folders":[], - "Name":"+bin", + "Name":"-bin", "Files":[{ "filename":"bin/local.conf", "enabled":"1" @@ -18,7 +18,7 @@ }] },{ "Folders":[], - "Name":"-common", + "Name":"+common", "Files":[{ "filename":"../common/jessl.f90", "enabled":"1" @@ -54,6 +54,9 @@ },{ "filename":"example/levitating.conf", "enabled":"1" + },{ + "filename":"example/levitating.xinetd", + "enabled":"1" }] },{ "Folders":[], @@ -67,7 +70,7 @@ }] },{ "Folders":[], - "Name":"+templates", + "Name":"-templates", "Files":[{ "filename":"templates/home.html", "enabled":"1" @@ -96,6 +99,9 @@ "filename":"auth_level.f90", "enabled":"1" },{ + "filename":"BUILD.md", + "enabled":"1" + },{ "filename":"captain.f90", "enabled":"1" },{ @@ -160,7 +166,7 @@ "Name":"levitating-captain (levitating-captain)", "Options":{ "Compiler Options":{ - "Fortran Flags":"-DGNU -DHAS_CRYPT_GENSALT", + "Fortran Flags":"-DGNU", "Link Flags":"-lsqlite3 -lssl -lcrypt", "C Flags":"" }, @@ -176,13 +182,14 @@ }, "Target":"levitating-captain", "Fortran Options":{ + "Floating Point Exception Trap":0, + "Initialize Variables to Zero":"false", "Use C Preprocessor":"false", "Runtime Diagnostics":"true", - "Floating Point Exception Trap":0, "Cray Pointers":"false", - "Enable Coarrays":"false", + "Disable Floating Point Exception Warnings":0, "Enable OpenMP":"false", - "Initialize Variables to Zero":"false", + "Enable Coarrays":"false", "Default Double for Real":"false" }, "Code Generation Options":{ @@ -191,7 +198,8 @@ "Aggressive Loops":"false", "Debugging":"true", "Optimization Mode":0, - "Profiling":"false" + "Profiling":"false", + "Link Time Optimization":"false" }, "Build Dependencies":1, "Launch Options":{ @@ -213,4 +221,4 @@ "Link LAPACK":0 } } -} +}
\ No newline at end of file diff --git a/captain/makefile.gnu b/captain/makefile.gnu new file mode 100644 index 0000000..8eadb95 --- /dev/null +++ b/captain/makefile.gnu @@ -0,0 +1,243 @@ +# +# Automagically generated by Approximatrix Simply Fortran 3.37 +# +FC?="gfortran" +CC?="gcc" +AR?="ar" +WRC?="windres" +RM=rm -f + +IDIR= + +LDIR= + + +OPTFLAGS= -g -gdwarf-4 + +SPECIALFLAGS= + +RCFLAGS=-O coff --use-temp-file + +PRJ_FFLAGS=-DGNU -fcheck=all + +PRJ_CFLAGS= + +PRJ_LFLAGS=-lsqlite3 -lssl -lcrypt + +FFLAGS=$(SPECIALFLAGS) $(OPTFLAGS) $(IDIR) $(PRJ_FFLAGS) -Jmodules + +CFLAGS=$(SPECIALFLAGS) $(OPTFLAGS) $(IDIR) $(PRJ_CFLAGS) + +build: + mkdir -p $@ + +modules: + mkdir -p $@ + +.PHONY: all clean + +build/api.o: api.f90 modules/captain_db.mod modules/utilities.mod modules/server_response.mod modules/logging.mod modules/special_filenames.mod modules/security.mod modules/gemini_codes.mod | modules build + @echo Compiling api.f90 + @$(FC) -c -o "build/api.o" $(FFLAGS) "api.f90" +modules/api_handling.mod : | modules build/api.o + +build/auth_level.o: auth_level.f90 | modules build + @echo Compiling auth_level.f90 + @$(FC) -c -o "build/auth_level.o" $(FFLAGS) "auth_level.f90" +modules/auth_levels.mod : | modules build/auth_level.o + +build/captain.o: captain.f90 modules/captain_db.mod modules/config.mod modules/logging.mod modules/gemini.mod modules/web.mod modules/m_crypt.mod modules/m_uuid.mod | modules build + @echo Compiling captain.f90 + @$(FC) -c -o "build/captain.o" $(FFLAGS) "captain.f90" + +build/codes.o: codes.f90 | modules build + @echo Compiling codes.f90 + @$(FC) -c -o "build/codes.o" $(FFLAGS) "codes.f90" +modules/http_codes.mod : | modules build/codes.o +modules/gemini_codes.mod : | modules build/codes.o + +build/config.o: config.f90 modules/utilities.mod modules/auth_levels.mod | modules build + @echo Compiling config.f90 + @$(FC) -c -o "build/config.o" $(FFLAGS) "config.f90" +modules/config.mod : | modules build/config.o + +build/crypt.o: crypt.F90 | modules build + @echo Compiling crypt.F90 + @$(FC) -c -o "build/crypt.o" $(FFLAGS) "crypt.F90" +modules/m_crypt.mod : | modules build/crypt.o + +build/db.o: db.f90 modules/sqlite.mod modules/logging.mod modules/config.mod modules/utilities.mod modules/m_crypt.mod modules/auth_levels.mod modules/m_uuid.mod | modules build + @echo Compiling db.f90 + @$(FC) -c -o "build/db.o" $(FFLAGS) "db.f90" +modules/captain_db.mod : | modules build/db.o + +build/external.o: external.f90 modules/captain_db.mod modules/server_response.mod modules/request_utils.mod modules/logging.mod modules/config.mod modules/special_filenames.mod modules/utilities.mod modules/gemini_codes.mod modules/m_uuid.mod modules/page_template.mod modules/query_utilities.mod modules/security.mod | modules build + @echo Compiling external.f90 + @$(FC) -c -o "build/external.o" $(FFLAGS) "external.f90" +modules/external_handling.mod : | modules build/external.o + +build/gemini.o: gemini.f90 modules/jessl.mod modules/logging.mod modules/gemini_codes.mod modules/config.mod modules/external_handling.mod modules/api_handling.mod modules/m_uuid.mod modules/server_response.mod | modules build + @echo Compiling gemini.f90 + @$(FC) -c -o "build/gemini.o" $(FFLAGS) "gemini.f90" +modules/gemini.mod : | modules build/gemini.o + +build/http.o: http.f90 modules/logging.mod | modules build + @echo Compiling http.f90 + @$(FC) -c -o "build/http.o" $(FFLAGS) "http.f90" +modules/http.mod : | modules build/http.o + +build/jessl.o: ../common/jessl.f90 modules/utilities.mod | modules build + @echo Compiling ../common/jessl.f90 + @$(FC) -c -o "build/jessl.o" $(FFLAGS) "../common/jessl.f90" +modules/jessl.mod : | modules build/jessl.o + +build/launch.o: launch.f90 modules/captain_db.mod | modules build + @echo Compiling launch.f90 + @$(FC) -c -o "build/launch.o" $(FFLAGS) "launch.f90" +modules/remote_launch.mod : | modules build/launch.o + +build/log.o: log.f90 | modules build + @echo Compiling log.f90 + @$(FC) -c -o "build/log.o" $(FFLAGS) "log.f90" +modules/logging.mod : | modules build/log.o + +build/network.o: ../common/network.F90 | modules build + @echo Compiling ../common/network.F90 + @$(FC) -c -o "build/network.o" $(FFLAGS) "../common/network.F90" +modules/network.mod : | modules build/network.o + +build/postutils.o: postutils.f90 modules/query_utilities.mod modules/logging.mod | modules build + @echo Compiling postutils.f90 + @$(FC) -c -o "build/postutils.o" $(FFLAGS) "postutils.f90" +modules/http_post_utilities.mod : | modules build/postutils.o + +build/protocol.o: ../common/protocol.f90 modules/request.mod modules/utilities.mod modules/jessl.mod | modules build + @echo Compiling ../common/protocol.f90 + @$(FC) -c -o "build/protocol.o" $(FFLAGS) "../common/protocol.f90" +modules/gemini_protocol.mod : | modules build/protocol.o + +build/queryutils.o: queryutils.f90 modules/logging.mod | modules build + @echo Compiling queryutils.f90 + @$(FC) -c -o "build/queryutils.o" $(FFLAGS) "queryutils.f90" +modules/query_utilities.mod : | modules build/queryutils.o + +build/request.o: ../common/request.f90 modules/network.mod modules/jessl.mod | modules build + @echo Compiling ../common/request.f90 + @$(FC) -c -o "build/request.o" $(FFLAGS) "../common/request.f90" +modules/request.mod : | modules build/request.o + +build/requtils.o: requtils.f90 modules/http_codes.mod modules/gemini_codes.mod modules/server_response.mod modules/utilities.mod modules/captain_db.mod modules/logging.mod modules/config.mod modules/special_filenames.mod modules/remote_launch.mod | modules build + @echo Compiling requtils.f90 + @$(FC) -c -o "build/requtils.o" $(FFLAGS) "requtils.f90" +modules/request_utils.mod : | modules build/requtils.o + +build/response.o: response.f90 modules/query_utilities.mod modules/logging.mod modules/utilities.mod modules/captain_db.mod modules/auth_levels.mod modules/jessl.mod | modules build + @echo Compiling response.f90 + @$(FC) -c -o "build/response.o" $(FFLAGS) "response.f90" +modules/server_response.mod : | modules build/response.o + +build/security.o: security.f90 modules/captain_db.mod modules/logging.mod | modules build + @echo Compiling security.f90 + @$(FC) -c -o "build/security.o" $(FFLAGS) "security.f90" +modules/security.mod : | modules build/security.o + +build/special.o: special.f90 modules/utilities.mod modules/config.mod modules/logging.mod modules/captain_db.mod modules/server_response.mod | modules build + @echo Compiling special.f90 + @$(FC) -c -o "build/special.o" $(FFLAGS) "special.f90" +modules/special_filenames.mod : | modules build/special.o + +build/sqlite.o: sqlite.f90 | modules build + @echo Compiling sqlite.f90 + @$(FC) -c -o "build/sqlite.o" $(FFLAGS) "sqlite.f90" +modules/sqlite.mod : | modules build/sqlite.o + +build/template.o: template.f90 modules/logging.mod modules/utilities.mod modules/config.mod | modules build + @echo Compiling template.f90 + @$(FC) -c -o "build/template.o" $(FFLAGS) "template.f90" +modules/page_template.mod : | modules build/template.o + +build/utilities.o: ../common/utilities.F90 | modules build + @echo Compiling ../common/utilities.F90 + @$(FC) -c -o "build/utilities.o" $(FFLAGS) "../common/utilities.F90" +modules/utilities.mod : | modules build/utilities.o + +build/uuid.o: uuid.f90 modules/utilities.mod | modules build + @echo Compiling uuid.f90 + @$(FC) -c -o "build/uuid.o" $(FFLAGS) "uuid.f90" +modules/m_uuid.mod : | modules build/uuid.o + +build/web.o: web.f90 modules/utilities.mod modules/server_response.mod modules/page_template.mod modules/captain_db.mod modules/config.mod modules/logging.mod modules/request_utils.mod modules/query_utilities.mod modules/remote_launch.mod modules/special_filenames.mod modules/http_codes.mod modules/http_post_utilities.mod modules/http.mod | modules build + @echo Compiling web.f90 + @$(FC) -c -o "build/web.o" $(FFLAGS) "web.f90" +modules/web.mod : | modules build/web.o + +clean: + @echo Deleting build/api.o and related files + @$(RM) "build/api.o" "modules/api_handling.mod" "modules/api_handling.smod" + @echo Deleting build/auth_level.o and related files + @$(RM) "build/auth_level.o" "modules/auth_levels.mod" "modules/auth_levels.smod" + @echo Deleting build/captain.o and related files + @$(RM) "build/captain.o" + @echo Deleting build/codes.o and related files + @$(RM) "build/codes.o" "modules/http_codes.mod" "modules/http_codes.smod" "modules/gemini_codes.mod" "modules/gemini_codes.smod" + @echo Deleting build/config.o and related files + @$(RM) "build/config.o" "modules/config.mod" "modules/config.smod" + @echo Deleting build/crypt.o and related files + @$(RM) "build/crypt.o" "modules/m_crypt.mod" "modules/m_crypt.smod" + @echo Deleting build/db.o and related files + @$(RM) "build/db.o" "modules/captain_db.mod" "modules/captain_db.smod" + @echo Deleting build/external.o and related files + @$(RM) "build/external.o" "modules/external_handling.mod" "modules/external_handling.smod" + @echo Deleting build/gemini.o and related files + @$(RM) "build/gemini.o" "modules/gemini.mod" "modules/gemini.smod" + @echo Deleting build/http.o and related files + @$(RM) "build/http.o" "modules/http.mod" "modules/http.smod" + @echo Deleting build/jessl.o and related files + @$(RM) "build/jessl.o" "modules/jessl.mod" "modules/jessl.smod" + @echo Deleting build/launch.o and related files + @$(RM) "build/launch.o" "modules/remote_launch.mod" "modules/remote_launch.smod" + @echo Deleting build/log.o and related files + @$(RM) "build/log.o" "modules/logging.mod" "modules/logging.smod" + @echo Deleting build/network.o and related files + @$(RM) "build/network.o" "modules/network.mod" "modules/network.smod" + @echo Deleting build/postutils.o and related files + @$(RM) "build/postutils.o" "modules/http_post_utilities.mod" "modules/http_post_utilities.smod" + @echo Deleting build/protocol.o and related files + @$(RM) "build/protocol.o" "modules/gemini_protocol.mod" "modules/gemini_protocol.smod" + @echo Deleting build/queryutils.o and related files + @$(RM) "build/queryutils.o" "modules/query_utilities.mod" "modules/query_utilities.smod" + @echo Deleting build/request.o and related files + @$(RM) "build/request.o" "modules/request.mod" "modules/request.smod" + @echo Deleting build/requtils.o and related files + @$(RM) "build/requtils.o" "modules/request_utils.mod" "modules/request_utils.smod" + @echo Deleting build/response.o and related files + @$(RM) "build/response.o" "modules/server_response.mod" "modules/server_response.smod" + @echo Deleting build/security.o and related files + @$(RM) "build/security.o" "modules/security.mod" "modules/security.smod" + @echo Deleting build/special.o and related files + @$(RM) "build/special.o" "modules/special_filenames.mod" "modules/special_filenames.smod" + @echo Deleting build/sqlite.o and related files + @$(RM) "build/sqlite.o" "modules/sqlite.mod" "modules/sqlite.smod" + @echo Deleting build/template.o and related files + @$(RM) "build/template.o" "modules/page_template.mod" "modules/page_template.smod" + @echo Deleting build/utilities.o and related files + @$(RM) "build/utilities.o" "modules/utilities.mod" "modules/utilities.smod" + @echo Deleting build/uuid.o and related files + @$(RM) "build/uuid.o" "modules/m_uuid.mod" "modules/m_uuid.smod" + @echo Deleting build/web.o and related files + @$(RM) "build/web.o" "modules/web.mod" "modules/web.smod" + @echo Deleting build/wsa.o and related files + @$(RM) "build/wsa.o" + @echo Deleting directory modules + @rmdir modules + @echo Deleting directory build + @rmdir build + @echo Deleting levitating-captain + @$(RM) "levitating-captain" + +levitating-captain: build/api.o build/auth_level.o build/captain.o build/codes.o build/config.o build/crypt.o build/db.o build/external.o build/gemini.o build/http.o build/jessl.o build/launch.o build/log.o build/network.o build/postutils.o build/protocol.o build/queryutils.o build/request.o build/requtils.o build/response.o build/security.o build/special.o build/sqlite.o build/template.o build/utilities.o build/uuid.o build/web.o + @echo Generating levitating-captain + @$(FC) -o "levitating-captain" $(SPECIALFLAGS) build/api.o build/auth_level.o build/captain.o build/codes.o build/config.o build/crypt.o build/db.o build/external.o build/gemini.o build/http.o build/jessl.o build/launch.o build/log.o build/network.o build/postutils.o build/protocol.o build/queryutils.o build/request.o build/requtils.o build/response.o build/security.o build/special.o build/sqlite.o build/template.o build/utilities.o build/uuid.o build/web.o $(LDIR) $(PRJ_LFLAGS) + +all: levitating-captain + |