pepe: set up dms server
This commit is contained in:
parent
87006e54c4
commit
eca3701605
3 changed files with 89 additions and 24 deletions
|
@ -10,7 +10,7 @@
|
|||
./syncthing.nix
|
||||
./tinc.nix
|
||||
./wifi-access-point.nix
|
||||
./vsftpd.nix
|
||||
./dms.nix
|
||||
|
||||
];
|
||||
|
||||
|
|
88
configs/pepe/dms.nix
Normal file
88
configs/pepe/dms.nix
Normal file
|
@ -0,0 +1,88 @@
|
|||
{ lib, pkgs, config, ... }:
|
||||
|
||||
# a very simple dms setup which.
|
||||
# I have a brother ADS-1600W scanner, which is configured to send all
|
||||
# PDFs to this machine in /home/ftp-upload/input
|
||||
# from there the dms.py scans them and makes them searchable.
|
||||
|
||||
let
|
||||
dms = pkgs.fetchgit {
|
||||
url = "https://github.com/mrVanDalo/dms.git";
|
||||
rev = "23308490c99eb2ca4a4936e6c4e87403137d9ac1";
|
||||
sha256 = "1gzxlqni9ybmbj8ip2cbkbld3nid3x7552f8v8868nzw1crqky3b";
|
||||
};
|
||||
in {
|
||||
|
||||
# setup ftp
|
||||
services.vsftpd = {
|
||||
enable = true;
|
||||
userlist = [ "ftp-upload" ];
|
||||
userlistEnable = true;
|
||||
localUsers = true;
|
||||
writeEnable = true;
|
||||
};
|
||||
networking.firewall.allowedTCPPortRanges = [
|
||||
{
|
||||
# ftp
|
||||
from = 1024;
|
||||
to = 65535;
|
||||
}
|
||||
{
|
||||
# ftp
|
||||
from = 20;
|
||||
to = 21;
|
||||
}
|
||||
];
|
||||
|
||||
# create user
|
||||
users.users.ftp-upload = {
|
||||
passwordFile = toString <secrets/ftp/password>;
|
||||
isNormalUser = true;
|
||||
};
|
||||
|
||||
# create dms service
|
||||
systemd.services.dms = {
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [
|
||||
(pkgs.python3.withPackages (ps: with ps; [ flask ]))
|
||||
pkgs.imagemagick
|
||||
pkgs.pdfsandwich
|
||||
pkgs.poppler_utils
|
||||
pkgs.which
|
||||
pkgs.ghostscript
|
||||
pkgs.netpbm
|
||||
];
|
||||
serviceConfig = { User = "ftp-upload"; };
|
||||
preStart = ''
|
||||
if [[ ! -L /home/ftp-upload/db/SOURCE_DIR ]]
|
||||
then
|
||||
rm -rf /home/ftp-upload/db/SOURCE_DIR
|
||||
mkdir -p /home/ftp-upload/db
|
||||
mkdir -p /home/ftp-upload/input
|
||||
ln -s /home/ftp-upload/input /home/ftp-upload/db/SOURCE_DIR
|
||||
fi
|
||||
'';
|
||||
script = ''
|
||||
DMSDATA=/home/ftp-upload/db \
|
||||
FLASK_APP=${dms}/dms.py \
|
||||
flask run --host 0.0.0.0 \
|
||||
"$@"
|
||||
'';
|
||||
};
|
||||
|
||||
# host nginx setup
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"dms.pepe.private" = {
|
||||
serverAliases = [ "pdf.pepe.private" "docs.pepe.private" ];
|
||||
locations."/" = { proxyPass = "http://localhost:5000"; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# add documents to backup
|
||||
backup.all.restic.dirs = [ "/home/ftp-upload/db" ];
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{ lib, pkgs, config, ... }: {
|
||||
|
||||
services.vsftpd = {
|
||||
enable = true;
|
||||
userlist = [ "ftp-upload" ];
|
||||
userlistEnable = true;
|
||||
localUsers = true;
|
||||
writeEnable = true;
|
||||
};
|
||||
|
||||
users.users.ftp-upload = {
|
||||
passwordFile = toString <secrets/ftp/password>;
|
||||
isNormalUser = true;
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
20 # ftp
|
||||
21 # ftp
|
||||
];
|
||||
|
||||
networking.firewall.allowedTCPPortRanges = [ {from = 1024 ; to = 65535; }];
|
||||
|
||||
}
|
Loading…
Reference in a new issue