Hayden Guide

Guide on how to setup and run hayden on a linux machine.

Warnings

 * Blame Ctrl-S for this document. (WIP)
 * Hayden is not really reliably stable on linux right now and may decide to enter a state where it will reliably crash on startup.
 * Hayden cares about the JSON config file syntax. If you missplace a comma it will probably reject the config file and crash.

Prerequisites
How to set up a system so hayden will download, build, and run.
 * 1) Prep system for updates
 * 2) * Debian-based systems (ubuntu, debian, etc)
 * 3) * RHEL-based systems (redhat, fedora, centos)
 * 1) * RHEL-based systems (redhat, fedora, centos)

Install dotnet
https://docs.microsoft.com/en-us/dotnet/core/install/linux-centos https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
 * 1) Install Microsoft dotnet runtime
 * 1) * RHEL-based systems (redhat, fedora, centos)
 * 2) * Debian-based systems (ubuntu, debian, etc)
 * 1) * Debian-based systems (ubuntu, debian, etc)

Database install
Hayden works with MariaDB and I dont know if it works with others. You could use any MariaDB installation if you wanted to, however that is left to advanced users who know how and is outside the scope of this guide.

Docker+Mariadb - Install Docker
https://docs.docker.com/engine/install/#server https://docs.docker.com/engine/install/centos/
 * 1) Setup repository:
 * 2) Install docker engine:
 * 3) Start docker service:
 * 4) Verify docker works
 * 1) Start docker service:
 * 2) Verify docker works
 * 1) Verify docker works

Docker+Mariadb - Install docker-compose
https://docs.docker.com/compose/
 * 1) Install docker-compose:
 * 2) Symlink into $PATH:
 * 3) * This is so that you do not need to type the absolute path to run the commands.
 * 4) Test installation:
 * 1) * This is so that you do not need to type the absolute path to run the commands.
 * 2) Test installation:

Docker+Mariadb - Setup Container

 * Prepare container definition
 * Example docker-compose definition file:
 * 1) * Ports in the 10XXX range are used in this example on the host side in an attempt to avoid conflicting with other programs wanting specific ports.
 * 2) * In practice, any port above 1024 which is not being used by another program should work.
 * 3) Bring up defined containers
 * 4) * Bring up defined containers in the foreground of your terminal:
 * Not reccomended outside of testing and development, as it is easy to close by mistake.
 * 1) * Bring up defined containers in the background ("-d" CLI flag):
 * Reccomended, as this is harder to close by mistake.
 * 1) * Bring up defined containers in the background ("-d" CLI flag):
 * Reccomended, as this is harder to close by mistake.

Docker+Mariadb - Usage

 * TODO
 * To connect to the DB through adminer:
 * TODO
 * To make a DB dump:
 * Find the name or ID of the DB container
 * Run the dump command targeting that container
 * Note that the dump command in the container outputs the DB dump SQL as text on its STDOUT; which is sent back from the container to the host; and that is redirected into a file on the host.
 * Explaination:
 * Runs a command inside a container.
 * Dumps a copy of the DB to STDOUT
 * Redirects the output into a file with a timestamp in the name.
 * Produces a timestamp in seconds since the epoch. e.g..
 * This is done using the DB root account as it always has full access to the entire database.
 * Produces a timestamp in seconds since the epoch. e.g..
 * This is done using the DB root account as it always has full access to the entire database.

Download and Build Hayden

 * 1) Prepare location:
 * 2) Clone (download) Hayden source code from Github:
 * 3) Build the Hayden solution file:
 * 4) Run with config file:
 * 1) Build the Hayden solution file:
 * 2) Run with config file:
 * 1) Run with config file:

Configuration

 * Configuration for Hayden is done through a JSON file that is specified as a command-line argument when starting Hayden.
 * Hayden is picy about the syntax of this JSON file.
 * Commas only go between key:value pars. Trailing commas are not tolerated by Hayden.
 * Some options are implimented but not shown in the example JSON file.
 * The option to scan archive.json to save threads that have recently fallen off the board:
 * Some databses will not let you connect as the DB root account from a system user other than root.
 * As a result of this, you should create a DB user specifically for Hayden to use.
 * The database connection is defined by this string value:
 * e.g.
 * Image downloading is controlled by two options:
 * These values must either be  or.
 * These values must either be  or.
 * These values must either be  or.
 * These values must either be  or.

Running

 * 1) Ensure DB is running
 * 2) * Hayden requires the database to be available to function.
 * 3) * See the database sections of this document for information on setting up and running a database in a container.
 * 4) Start Hayden
 * 5) * It is STRONGLY RECCOMENDED to run Hayden inside a Ccreen / Tmux / Byobu session so Hayden persists after your terminal disconnects.
 * e.g. One of the following three commands:
 * 1) * Start Hayden itself:
 * 1) * Start Hayden itself:
 * 1) * Start Hayden itself:
 * 1) * Start Hayden itself:

Proxies

 * UNTESTED BY AUTHOR
 * Hayden supports proxies and these can be configured through the config file.
 * The most common SSH server programs used by linux support acting as a proxy out of the box. You just have to tell it to start the proxy connection.
 * To test if your machine is rigged for automated SSH access to some remote host, run this command:
 * If it connects you to the remote host without needing to type things in, then your SSH key configuration is probably fine.
 * To start a SOCKS proxy over SSH, giving you a proxy accessible at the address localhost:10000:
 * To tell hayden to use a proxy:
 * To tell hayden to use a proxy:
 * To tell hayden to use a proxy:
 * To tell hayden to use a proxy:
 * To tell hayden to use a proxy:

Tips

 * Use absolute filepaths instead of relative filepaths whenever you can, as it makes it harder to screw up as bad.
 * e.g.  instead of   instead of
 * Back up your database frequently and regularly (i.e. mysqldump or similar)
 * Consider scheduling this via cron to occur automatically.
 * Run your programs inside screen/tmux/byobu so they dont get closed from you disconnecting your terminal.
 * Use a good password.  is a bad password.
 * Spaces need extra consideration regarding escaping, so try to avoid them.
 * Alphanumerical gibberish is hard to remember and to type in.
 * Passphrases are easy to remember and to type in.
 * Write down your usernames and passwords so you dont lose them.
 * Thumbnails can probably be generated from full images and thus can be turned off if you dont plan on running a public archive.
 * Save any error messages to a plain text file via copy/paste otherwise you won't be able to get real help from any experts.

Example files

 * These are what the configuration files should broardly look like.

Example config.json

 * The following configuration file code instructs Hayden to download the 4chan /vmg/ board, including the old threads temporarily retained by 4chan's archive.json API endpoint.

Example docker-compose.yml

 * The following configuration file defines two containers for docker-compose.
 * A MariaDB database container
 * A adminer DB webUI container