Initial commit
This commit is contained in:
commit
cf074be1a8
29
.env.example
Executable file
29
.env.example
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
# You can remove all the comments you don't want from this anymore in your .env file
|
||||||
|
|
||||||
|
# General
|
||||||
|
DOMAIN=domain.tld
|
||||||
|
TIMEZONE=Europe/London # Look up TZ timezones
|
||||||
|
|
||||||
|
# Subdomains
|
||||||
|
JELLYFIN_DOMAIN="jellyfin.${DOMAIN}"
|
||||||
|
SHOKO_ANIME_DOMAIN="shoko.${DOMAIN}"
|
||||||
|
TORRENT_DOMAIN="torrent.${DOMAIN}"
|
||||||
|
|
||||||
|
# Paths
|
||||||
|
# Inside the base folder, there should be a folder called downloads and another called import
|
||||||
|
BASE_DOWNLOADS_FOLDER="/mnt/e/AnimeDownloads" # change this to the folder you want to download anime to
|
||||||
|
DOWNLOADS_FOLDER="${BASE_DOWNLOADS_FOLDER}/downloads" # don't replace this
|
||||||
|
IMPORT_FOLDER="${BASE_DOWNLOADS_FOLDER}/import" # don't replace this
|
||||||
|
|
||||||
|
ANIME_FOLDER="/mnt/e/Anime"
|
||||||
|
MUSIC_FOLDER="/mnt/e/Musikk"
|
||||||
|
MOVIES_FOLDER="/mnt/e/Movies"
|
||||||
|
|
||||||
|
# Cloudflared
|
||||||
|
TUNNEL_UUID=x111xx1x-xxx1-1x111x-x11x-x1xxx11x11xx
|
||||||
|
# ^^ look at the end of the Cloudflare documentation in README.md
|
||||||
|
|
||||||
|
# Caddy Cloudflare plugin
|
||||||
|
EMAIL=address@domain.tld # Email used when signing up to Cloudflare
|
||||||
|
CF_API_TOKEN=dsfkjaeslkfssdlfkjaselrkdsfsef
|
||||||
|
# ^^ Check the Environment Variables section in the README.md
|
20
.gitignore
vendored
Executable file
20
.gitignore
vendored
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
# Jellyfin
|
||||||
|
Jellyfin/
|
||||||
|
|
||||||
|
# ShokoAnime
|
||||||
|
ShokoAnime/
|
||||||
|
|
||||||
|
# qBittorrent
|
||||||
|
qBittorrent/config/
|
||||||
|
|
||||||
|
# Caddy
|
||||||
|
Caddy/*
|
||||||
|
!Caddy/Caddyfile
|
||||||
|
!Caddy/Dockerfile
|
||||||
|
|
||||||
|
# Cloudflare
|
||||||
|
Cloudflared/config/*
|
||||||
|
!Cloudflared/config/config.yml
|
||||||
|
|
||||||
|
# General
|
||||||
|
.env
|
40
Caddy/Caddyfile
Executable file
40
Caddy/Caddyfile
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
acme_dns cloudflare {$CF_API_TOKEN}
|
||||||
|
}
|
||||||
|
|
||||||
|
(redirect) {
|
||||||
|
@http {
|
||||||
|
protocol http
|
||||||
|
}
|
||||||
|
redir @http https://{host}{uri} permanent
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
*.{$DOMAIN} {
|
||||||
|
|
||||||
|
@jellyfin host {$JELLYFIN_DOMAIN}
|
||||||
|
handle @jellyfin {
|
||||||
|
reverse_proxy jellyfin:8096
|
||||||
|
}
|
||||||
|
|
||||||
|
@shoko host {$SHOKO_ANIME_DOMAIN}
|
||||||
|
handle @shoko {
|
||||||
|
reverse_proxy shoko_server:8111
|
||||||
|
}
|
||||||
|
|
||||||
|
@torrent host {$TORRENT_DOMAIN}
|
||||||
|
handle @torrent {
|
||||||
|
reverse_proxy qbittorrent:9090
|
||||||
|
}
|
||||||
|
|
||||||
|
@ping host ping.{$DOMAIN}
|
||||||
|
handle @ping {
|
||||||
|
respond "Pong!"
|
||||||
|
}
|
||||||
|
|
||||||
|
handle {
|
||||||
|
abort
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
11
Caddy/Dockerfile
Executable file
11
Caddy/Dockerfile
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
ARG CADDY_VERSION=2.6.2
|
||||||
|
|
||||||
|
FROM caddy:${CADDY_VERSION}-builder AS builder
|
||||||
|
|
||||||
|
RUN xcaddy build \
|
||||||
|
--with github.com/caddy-dns/cloudflare \
|
||||||
|
--with github.com/greenpau/caddy-security
|
||||||
|
|
||||||
|
FROM caddy:${CADDY_VERSION}-alpine
|
||||||
|
|
||||||
|
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
14
Cloudflared/Dockerfile
Executable file
14
Cloudflared/Dockerfile
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
FROM alpine:latest AS alpine
|
||||||
|
|
||||||
|
ARG DOMAIN
|
||||||
|
ARG TUNNEL_UUID
|
||||||
|
|
||||||
|
RUN mkdir -p /etc/cloudflared
|
||||||
|
COPY config/ /etc/cloudflared
|
||||||
|
|
||||||
|
RUN sed -i "s/<domain.tld>/${DOMAIN}/g" /etc/cloudflared/config.yml
|
||||||
|
RUN sed -i "s/<tunnel-uuid>/${TUNNEL_UUID}/g" /etc/cloudflared/config.yml
|
||||||
|
|
||||||
|
FROM cloudflare/cloudflared:latest
|
||||||
|
|
||||||
|
COPY --from=alpine /etc/cloudflared /etc/cloudflared
|
13
Cloudflared/config/config.yml
Executable file
13
Cloudflared/config/config.yml
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
tunnel: <tunnel-uuid>
|
||||||
|
credentials-file: /etc/cloudflared/<tunnel-uuid>.json
|
||||||
|
|
||||||
|
ingress:
|
||||||
|
- hostname: '<domain.tld>'
|
||||||
|
service: https://caddy:443
|
||||||
|
originRequest:
|
||||||
|
originServerName: '<domain.tld>'
|
||||||
|
- hostname: '*.<domain.tld>'
|
||||||
|
service: https://caddy:443
|
||||||
|
originRequest:
|
||||||
|
originServerName: '*.<domain.tld>'
|
||||||
|
- service: http_status:404
|
158
README.md
Executable file
158
README.md
Executable file
@ -0,0 +1,158 @@
|
|||||||
|
# Media Server
|
||||||
|
|
||||||
|
Eases the setup of a media server that requires as little manual input as possible.
|
||||||
|
|
||||||
|
## Modules
|
||||||
|
|
||||||
|
### Jellyfin
|
||||||
|
|
||||||
|
For displaying and streaming your media
|
||||||
|
|
||||||
|
### ShokoAnime
|
||||||
|
|
||||||
|
For sorting your anime after downloading them
|
||||||
|
|
||||||
|
### qBittorrent
|
||||||
|
|
||||||
|
For downloading media
|
||||||
|
|
||||||
|
### Caddy
|
||||||
|
|
||||||
|
For securing your connection over HTTPS/TLS and handling incoming requests
|
||||||
|
|
||||||
|
### [Single PHP Filehost](https://github.com/Rouji/single_php_filehost)
|
||||||
|
|
||||||
|
For uploading and sharing files with others
|
||||||
|
|
||||||
|
### Cloudflare Tunnel (Cloudflared)
|
||||||
|
|
||||||
|
For securing your local router, preventing your IP from being exposed and eliminating the need for opening up a port in your router
|
||||||
|
|
||||||
|
## Scripts
|
||||||
|
|
||||||
|
- `./caddy` - lets you quickly reload your Caddy config if you made changes to the Caddyfile by running `./caddy reload`
|
||||||
|
- `./qBittorrent/scripts/hardlink-torrent.sh` - used with qBittorrent to create hardlinks to your torrents on successfully completed download. This allows you to keep seeding after Shoko moves the files elsewhere. Files can be deleted from the downloads folder if you no longer wish to seed. All hardlinks to a file has to be deleted for the file to be deleted.
|
||||||
|
- `./update.sh` will force rebuild (and update) all containers.
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
Install Docker on your system. Easiest way is to just download [Docker Desktop](https://docs.docker.com/desktop/troubleshoot/overview/) and let it handle it.
|
||||||
|
|
||||||
|
If you're using an Nvidia GPU and want GPU transcoding, you should also follow [these steps](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/nvidia-docker.html) to install the Nvidia container dependencies. For Fedora, try [this guide](https://gist.github.com/JuanM04/fcbed16d0f4405a286adebee5fd31cb2) instead.
|
||||||
|
|
||||||
|
### Cloudflare
|
||||||
|
|
||||||
|
Make sure you setup Cloudflare with your domain. Log into [cloudflare](https://www.cloudflare.com/) and follow the setup in the domains tab.
|
||||||
|
|
||||||
|
You need to setup `cloudflared` once and copy over some files to get the tunnel working. You can follow [this](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide/local/#set-up-a-tunnel-locally-cli-setup) guide to set it up locally. I'll summarise it here quickly but will skip how to install the `cloudflared` package as that varies by distro.
|
||||||
|
|
||||||
|
Run this command to generate required files
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cloudflared tunnel login
|
||||||
|
```
|
||||||
|
|
||||||
|
Then this one to create a tunnel. The name can be anything you want that helps you recognise the server.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cloudflared tunnel create <NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
Run this for each of the subdomains, `jellyfin.domain.tld`, `shoko.domain.tld`, `torrent.domain.tld`, `files.domain.tld` and if you want a way to quickly test if Caddy is working, you can also add `ping.domain.tld`. Replace `domain.tld` with your domain. You can use different subdomains by changing them in the `.env` file.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cloudflared tunnel route dns <UUID or NAME> <hostname>
|
||||||
|
```
|
||||||
|
|
||||||
|
An example of the command above could be
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cloudflared tunnel route dns example-pc ping.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
Copy the credentials file to `./Cloudflared/config/` (it should be stored in `~/.cloudflared/`). Example:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo cp ~/.cloudflared/<UUID>.json ~/Documents/media-server/Cloudflared/config/
|
||||||
|
```
|
||||||
|
|
||||||
|
The name of the credentials file above is the UUID of the tunnel, put that in the `.env` file as instructed in the next step.
|
||||||
|
|
||||||
|
### Environment Variables
|
||||||
|
|
||||||
|
Create a `.env` file based on the content in `.env.example`. The example will include comments that will help with what value is needed there.
|
||||||
|
|
||||||
|
The CF_API_TOKEN requires you to follow [this guide](https://samjmck.com/en/blog/using-caddy-with-cloudflare/). You can either follow the second step or the third step. If you follow the second step, you can skip the part about downloading some Caddy packages as the Dockerfile handles that already. Just skip to the part about generating an API token
|
||||||
|
|
||||||
|
### Passwords
|
||||||
|
|
||||||
|
**Use strong passwords for all services!!** A strong password is one that is long, not one that uses lots of weird symbols.
|
||||||
|
|
||||||
|
qBittorrent defaults to username 'admin' and password 'adminadmin'. Make sure you go into the settings under WebUI and change that immediately!
|
||||||
|
|
||||||
|
### ShokoAnime
|
||||||
|
|
||||||
|
After going through the setup (or potentially during setup) set the import folders like this
|
||||||
|
|
||||||
|
`Anime Source -> /mnt/import` using drop type "source" and enabling "watch for new files"<br>
|
||||||
|
`Anime Destination -> /mnt/anime` using drop type "Destination"
|
||||||
|
|
||||||
|
Go to settings and adjust these settings
|
||||||
|
|
||||||
|
```
|
||||||
|
# Import
|
||||||
|
Rename on Import = true
|
||||||
|
Move on Import = true
|
||||||
|
Move after rename = true
|
||||||
|
|
||||||
|
# Relation
|
||||||
|
Auto Group Series = true
|
||||||
|
```
|
||||||
|
|
||||||
|
### Jellyfin
|
||||||
|
|
||||||
|
#### Shokofin
|
||||||
|
|
||||||
|
You'll have to add the Shokofin plugin to Jellyfin. Do that by going to `Settings -> Dashboard -> Plugins`. In there go to the `Repositories` tab at the top. Add new
|
||||||
|
|
||||||
|
Repository Name: `Shokofin Stable`<br>
|
||||||
|
Repository URL: `https://raw.githubusercontent.com/ShokoAnime/Shokofin/master/manifest.json`
|
||||||
|
|
||||||
|
Now you have to go to the `Catalog` tab and install Shokofin (might be named Shoko). Restart Jellyfin after this.
|
||||||
|
|
||||||
|
Go back to the Plugins list and click Shoko/Shokofin to configure.
|
||||||
|
|
||||||
|
Host: `http://shoko_server:8111`
|
||||||
|
|
||||||
|
This lets Jellyfin talk to Shoko directly rather than going through Cloudflare for each request.
|
||||||
|
|
||||||
|
For Library settings I recommend using these settings
|
||||||
|
|
||||||
|
Series/Season Grouping: Group series into Seasons based on Shoko's Groups<br>
|
||||||
|
Box-Sets/Movie Grouping: Create Box-sets based upon Shoko's Groups and Series entries
|
||||||
|
|
||||||
|
Finally the advanced settings
|
||||||
|
|
||||||
|
Public Shoko host URL: `shoko.domain.tld`<br>
|
||||||
|
Add AniDB ID to items: enabled
|
||||||
|
|
||||||
|
#### Transcoding
|
||||||
|
|
||||||
|
You should enable transcoding to offload work from the CPU to the GPU. This process varies from GPU to GPU and detailed setup can be found [here](https://jellyfin.org/docs/general/administration/hardware-acceleration.html). The current config is based on using an Nvidia GPU, in which case you only have to select the Nvidia NVENC option under Hardware Accelleration.
|
||||||
|
|
||||||
|
### qBittorrent
|
||||||
|
|
||||||
|
For this, you need to set the hardlinker script to run after download.
|
||||||
|
|
||||||
|
Set the default downloads folder to /base/downloads. At the top of the downloads settings, set the `Torrent content layout` setting to `Create subfolder`.
|
||||||
|
|
||||||
|
Enable `Run external program on torrent completion` and put this in the input field<br>
|
||||||
|
`/scripts/hardlink-torrent.sh "%R" "/base/import/%N"`
|
||||||
|
|
||||||
|
Also set download category as Anime for anime, Music for music, and Movies for movies. You can add more categories in the `hardlink-torrent.sh` script
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
Shoko server has a local interface for use with Shoko Desktop in case you need that. The URL for that is `http://localhost:8111`.
|
3
caddy.sh
Executable file
3
caddy.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo docker-compose exec -w /etc/caddy caddy caddy $1
|
95
compose.yaml
Executable file
95
compose.yaml
Executable file
@ -0,0 +1,95 @@
|
|||||||
|
version: '3.9'
|
||||||
|
|
||||||
|
services:
|
||||||
|
jellyfin:
|
||||||
|
container_name: jellyfin
|
||||||
|
image: jellyfin/jellyfin
|
||||||
|
# user: 1000:1000
|
||||||
|
volumes:
|
||||||
|
- ./Jellyfin/config:/config
|
||||||
|
- ./Jellyfin/cache:/cache
|
||||||
|
- ./Jellyfin/data:/data
|
||||||
|
- ${ANIME_FOLDER}:/Anime
|
||||||
|
- ${MUSIC_FOLDER}:/Music
|
||||||
|
- ${MOVIES_FOLDER}:/Movies
|
||||||
|
# ports: 8096:8096
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- TZ=${TIMEZONE}
|
||||||
|
- PUID=1000
|
||||||
|
- PGID=1000
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
reservations:
|
||||||
|
devices:
|
||||||
|
- driver: nvidia
|
||||||
|
count: 1
|
||||||
|
capabilities: [gpu]
|
||||||
|
|
||||||
|
shoko_server:
|
||||||
|
container_name: shokoserver
|
||||||
|
image: shokoanime/server:daily
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- PUID=1000
|
||||||
|
- PGID=1000
|
||||||
|
- TZ=${TIMEZONE}
|
||||||
|
- AVDUMP_MONO=true
|
||||||
|
ports:
|
||||||
|
- 8111:8111
|
||||||
|
volumes:
|
||||||
|
- ./ShokoAnime:/home/shoko/.shoko/Shoko.CLI
|
||||||
|
- ${ANIME_FOLDER}:/mnt/anime
|
||||||
|
- ${BASE_DOWNLOADS_FOLDER}/import:/mnt/import
|
||||||
|
|
||||||
|
qbittorrent:
|
||||||
|
container_name: qbittorrent
|
||||||
|
image: lscr.io/linuxserver/qbittorrent:latest
|
||||||
|
environment:
|
||||||
|
- PUID=1000
|
||||||
|
- PGID=1000
|
||||||
|
- TZ=${TIMEZONE}
|
||||||
|
- WEBUI_PORT=9090
|
||||||
|
volumes:
|
||||||
|
- ./qBittorrent/config:/config
|
||||||
|
- ./qBittorrent/scripts:/scripts
|
||||||
|
- ${BASE_DOWNLOADS_FOLDER}:/base
|
||||||
|
- ${MUSIC_FOLDER}:/Music
|
||||||
|
- ${MOVIES_FOLDER}:/Movies
|
||||||
|
# ports:
|
||||||
|
# - 9090:9090
|
||||||
|
# - 6881:6881
|
||||||
|
# - 6881:6881/udp
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
caddy:
|
||||||
|
container_name: caddy
|
||||||
|
build: ./Caddy
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./Caddy/Caddyfile:/etc/caddy/Caddyfile
|
||||||
|
- ./Caddy/site:/srv
|
||||||
|
- ./Caddy/data:/data
|
||||||
|
- ./Caddy/config:/config
|
||||||
|
user: root
|
||||||
|
depends_on:
|
||||||
|
- cloudflared
|
||||||
|
|
||||||
|
cloudflared:
|
||||||
|
container_name: cloudflared
|
||||||
|
build:
|
||||||
|
context: ./Cloudflared
|
||||||
|
args:
|
||||||
|
DOMAIN: '${DOMAIN}'
|
||||||
|
TUNNEL_UUID: '${TUNNEL_UUID}'
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
command: 'tunnel --config /etc/cloudflared/config.yml run'
|
||||||
|
restart: unless-stopped
|
||||||
|
# ports:
|
||||||
|
# - 80:80
|
||||||
|
# - 443:443
|
||||||
|
# - 443:443/udp
|
||||||
|
user: root
|
29
qBittorrent/scripts/hardlink-torrent.sh
Executable file
29
qBittorrent/scripts/hardlink-torrent.sh
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# 1: root path
|
||||||
|
# 2: torrent name
|
||||||
|
# 3: category
|
||||||
|
|
||||||
|
echo "1: $1" >> /base/actions.txt
|
||||||
|
echo "2: $2" >> /base/actions.txt
|
||||||
|
echo "3: $3" >> /base/actions.txt
|
||||||
|
|
||||||
|
if [ $3 == 'Anime' ]
|
||||||
|
then
|
||||||
|
cp -lR "$1" "/base/import/$2"
|
||||||
|
echo "cp -lR '$1' '/base/import/$2'" >> /base/actions.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $3 == 'Music' ]
|
||||||
|
then
|
||||||
|
mv -R "$1" "/Music/$2"
|
||||||
|
echo "mv -R '$1' '/Music/$2'" >> /base/actions.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $3 == 'Movies' ]
|
||||||
|
then
|
||||||
|
mv -R "$1" "/Movies/$2"
|
||||||
|
echo "mv -R '$1' '/Movies/$2'" >> /base/actions.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> /base/actions.txt
|
Loading…
Reference in New Issue
Block a user