title: Set up a manga server with Komga and mangal author: David Luévano lang: en summary: How to set up a manga server with Komga as media server and mangal for downloading manga, on Arch. Tachiyomi integration is available thanks to Komga. tags: server tools code tutorial english I've been wanting to set up a manga media server to hoard some mangas/comics and access them via Tachiyomi, but I didn't have enough space in my vultr VPS. Now that I have symmetric fiber optic at home and my spare PC to use as a server I decided to go ahead and create one. As always, ==i use arch btw== so these instructions are specifically for it, I'm not sure how easier/harder it is for other distros, I'm just too comfortable with arch honestly. I'm going to run it as an exposed service using a subdomain of my own, so the steps are taking that into account, if you want to run it locally (or on a LAN/VPN) then it is going to be easier/with less steps (you're on your own). Also, as you might notice I don't like to use D\*ck\*r images or anything (ew). As always, all commands are run as root unless stated otherwise. # Table of contents [TOC] # Prerequisites Similar to my early [tutorial](https://blog.luevano.xyz/tag/@tutorial.html) entries, if you want it as a subdomain: - An **A** (and/or **AAAA**) or a **CNAME** for `komga` (or whatever you want). - An SSL certificate, if you're following the other entries (specially the [website](https://blog.luevano.xyz/a/website_with_nginx.html) entry), add a `komga.conf` and run `certbot --nginx` (or similar) to extend/create the certificate. More details below: [Reverse proxy](#reverse-proxy) and [SSL certificate](#ssl-certificate). # yay This is the first time I mention the **AUR** (and `yay`) in my entries, so I might as well just write a bit about it. The [AUR](https://aur.archlinux.org/) is the **A**rch Linux **U**ser **R**epository and it's basically like an extension of the official one which is supported by the community, the only thing is that it requires a different package manager. The one I use (and I think everyone does, too) is `yay`, which as far as I know is like a wrapper of `pacman`. ## Install To install and use `yay` we need a normal account with sudo access, ==all the commands related to `yay` are run as normal user and then it asks for sudo password==. [Installation](https://github.com/Jguer/yay#installation) its straight forward: clone `yay` repo and install. Only dependencies are `git` and `base-devel`: Install dependencies: ```sh sudo pacman -S git base-devel ``` Clone `yay` and install it (I also like to delete the cloned git repo): ```sh git clone git@github.com:Jguer/yay.git cd yay makepkg -si cd .. sudo rm -r yay ``` ## Usage `yay` is used basically the same as `pacman` with the difference that it is run as normal user (then later requiring sudo password) and that it asks extra input when installing something, such as if we want to build the package from source or if we want to show package diffs. To install a package (for example Komga in this blog entry), run: ```sh yay -S komga ``` # mangal [mangal](https://github.com/metafates/mangal) is a CLI/TUI manga downloader with anilist integration and custom Lua scrapers. You could install it from the AUR with `yay`: ```sh yay -S mangal-bin ``` But I'll use my [fork](https://github.com/luevano/mangal) as it contains some fixes and extra stuff. ## Install from source As I mentioned in my past [entry](https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html) I had to [fork](https://github.com/luevano/mangal) `mangal` and related repositories to fix/change a few things. Currently the major fix I did in `mangal` is for the built in [MangaDex](https://mangadex.org/) scraper which had really annoying bug in the chunking of the manga chapter listing. So instad of installing with `yay` we'll build it from source. We need to have `go` installed: ```sh pacman -S go ``` Then clone my fork of `mangal` and `install` it: ```sh git clone https://github.com/luevano/mangal.git # not sure if you can use SSH to clone cd mangal make install # or just `make build` and then move the binary to somewhere in your $PATH ``` This will use `go install` so it will install to a path specified by the `go` environment variables, for more run `go help install`. It was installed to `$HOME/.local/bin/go/mangal` for me because my env vars, then just make sure this is included in your `PATH`. Check it was correctly installed by running `mangal version`, which should print something like: ``` ▇▇▇ mangal Version ... Git Commit ... Build Date ... Built By ... Platform ... ``` ## Configuration I'm going to do everything with a normal user (`manga-dl`) which I created just to download manga. So all of the commands will be run without sudo/root privileges. Change some of the configuration options: ```sh mangal config set -k downloader.path -v "/mnt/d/mangal" # downloads to current dir by default mangal config set -k formats.use -v "cbz" # downloads as pdf by default mangal config set -k installer.user -v "luevano" # points to my scrapers repository which contains a few extra scrapers and fixes, defaults to metafates' one; this is important if you're using my fork, don't use otherwise as it uses extra stuff I added mangal config set -k logs.write -v true # I like to get logs for what happens ``` **Note**: For testing purposes (if you want to explore `mangal`) set `downloader.path` once you're ready to start to populate the Komga library directory (at [Komga: populate manga library](#populate-manga-library)). For more configs and to read what they're for: ```sh mangal config info ``` Also install the custom Lua scrapers by running: ```sh mangal sources install ``` And install whatever you want, it picks up the sources/scrapers from the configured repository (`installer.` config), if you followed, it will show my scrapers. ## Usage Two main ways of using `mangal`: - **TUI**: for initial browsing/downloading and testing things out. If the manga finished publishing, this should be enough. - **inline**: for automation on manga that is still publishing and I need to check/download every once in a while. ### Headless browser Before continuing, I gotta say I went through some bullshit while trying to use the custom Lua scrapers that use the *headless* browser (actually just a wrapper of [go-rod/rod](https://github.com/go-rod/rod), and honestly it is not really a "headless" browser, `mangal` "documentation" is just wrong). For more on my rant check out my last [entry](https://blog.luevano.xyz/a/learned_go_and_lua_hard_way.html). There is no concrete documentation on the "headless" browser, only that it is automatically set up and ready to use... but it doesn't install any library/dependency needed. I discovered the following libraries that were missing on my Arch minimal install: - library -> arch package containing it - libnss3.so -> nss - libatk-1.0.so.0 -> at-spi2-core - libcups.so.2 -> libcups - libdrm.so.2 -> libdrm - libXcomposite.so.1 -> libxcomposite - libXdamage.so.1 -> libxdamage - libXrandr.so.2 -> libxrandr - libgbm.so.1 -> mesa - libxkbcommon.so.0 -> libxkbcommon - libpango-1.0.so.0 -> pango - libasound.so.2 -> alsa-lib To install them:: ```sh pacman -S nss at-spi2-core libcups libdrm libxcomposite libxdamage libxrandr mesa libxkbcommon pango alsa-lib ``` I can't guarantee that those are all the packages needed, those are the ones I happen to discover (had to [fork](https://github.com/luevano/mangal-lua-libs) the lua libs and add some logging because the error message was too fucking generic). These dependencies are probably met by installing either `chromedriver` or `google-chrome` from the AUR (for what I could see on the package dependencies). ### TUI Use the TUI by running ```sh mangal ``` Download manga using the TUI by selecting the source/scrapper, search the manga/comic you want and then you can select each chapter to download (use `tab` to select all). This is what I use when downloading manga that already finished publishing, or when I'm just searching and testing out how it downloads the manga (directory name, and manga information). Note that some scrapters will contain duplicated chapters, as they have multiple uploaded chapters from the community, usually for different *scanlation groups*. This happens a lot with [MangaDex](https://mangadex.org/). ### Inline The inline mode is a single terminal command meant to be used to automate stuff or for more advanced options. You can peek a bit into the "[documentation](https://github.com/metafates/mangal/wiki/Inline-mode#command-examples)" which honestly it's ass because it doesn't explain much. The minimal command for inline according to the `mangal help` is: ```sh mangal inline --manga