Paperless

提供: ArchWiki
2024年4月12日 (金) 18:36時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (→‎インストール: 飜訳)
ナビゲーションに移動 検索に移動

Paperless は、スキャンした文書を索引付けし、文書を簡単に検索したり、文書と一緒にメタデータを保存することができるオープンソースの文書管理システムです。この記事は、Paperless-ngx に関するもので、これは Paperless-ng のコミュニティによって維持されているフォークであり、さらにそれは 元の Paperless プロジェクトのフォークであり、両方とも放棄されています。

インストール

paperless-ngxAUR パッケージをインストールします。

フォルダ

Paperless は /usr/share/paperless にインストールされます。Paperless の永続的なストレージは /var/lib/paperless に位置しており、media フォルダ、デフォルトで SQLite データベースを含む data フォルダ、文書を消費する consume フォルダ、一時的な uploads フォルダおよび tmp 変換フォルダを含んでいます。 consume フォルダは paperless グループのすべてのユーザーに対して書き込み権限があります。

消費フォルダの権限

ユーザー(例えば "http")が消費フォルダに文書を置くことを許可したい場合は、それらのユーザーを paperless ユーザーグループ に追加してください。

OCR 言語

Paperless で英語以外の言語の文書を処理したい場合、対応する tesseract 言語データパッケージをインストールする必要があります。ドイツ語の場合は tesseract-data-deu がそれに該当します。

生成された PDF 文書のサイズを減らす

生成された PDF 文書のサイズを減らすために、オプションの依存関係 jbig2enc-gitAUR をインストールすることができます。これにより Paperless は PDF のサイズを小さくすることが可能です。

Paperless-ng からの移行

もし paperless-ng がインストールされており、paperless-ngxAUR に移行したい場合、paperless-ngxAUR をインストールし、尋ねられた際に paperless-ng を削除することを選択できます。データは失われません。それでも、root として次のコマンドを実行する必要があります:

# paperless-manage makemigrations

その後、paperless ユーザーとして通常のデータベースマイグレーションを適用します:

[paperless]$ paperless-manage migrate

最後に、paperless.target再起動してください。

Start

Start/enable paperless.target. Your Paperless instance should now be available at port 8000.

Configuration

For details on Paperless configuration, visit its official documentation. The configuration file is located at /etc/paperless.conf.

ノート: The paperless-ngxAUR package creates a paperless system user and provides a paperless-manage command which should always be run as the paperless user. See below for an example. The paperless-manage command should be used wherever the official documentation refers to python3 manage.py.

Do not forget to restart paperless.target after changing configurations.

Adjust the configuration to your needs

Open the configuration file located at /etc/paperless.conf at adjust the parameters to your needs, especially those concerning OCR. For explanations of the individual settings, refer to the official documentation.

Set a secret key

After initial installation, you should generate and set a secret key. You do not need to remember it, but since it is used for securing signed data, you should keep it secret. To set a secret key, uncomment and modify the following line:

/etc/paperless.conf
#PAPERLESS_SECRET_KEY=change-me

To generate a key and set it in the configuration file, you can simply run the following command:

# sed -i /etc/paperless.conf -e "s|#PAPERLESS_SECRET_KEY=change-me|PAPERLESS_SECRET_KEY=$(date | md5sum | awk '{print $1;}')|"

Run database migrations

After initial installation and after updates, you should run the database migrations:

[paperless]$ paperless-manage migrate

Create admin user

After initial installation, you should create an admin user for your Paperless instance:

[paperless]$ paperless-manage createsuperuser

Nginx

Install Nginx and use the following configuration as a starting point for the Paperless virtual host:

/etc/nginx/sites-available/paperless.domain.tld
server {

    server_name paperless.domain.tld;
    listen 80;
    listen [::]:80;

    location / {

        # Adjust host and port as required.
        proxy_pass http://localhost:8000/;

        # These configuration options are required for WebSockets to work.
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }

}

Pacman hook

To automatically run migrations for the Paperless database on package updates, you can make use of the included pacman hook:

# mkdir -vp /etc/pacman.d/hooks
# ln -sv /usr/share/paperless/docs/paperless.hook /etc/pacman.d/hooks/

Troubleshooting

BadSignature errors logged when trying to import documents

If you see BadSignature errors when trying to import documents, it is likely that your configuration file located at /etc/paperless.conf is not taken into account because the template configuration file /usr/share/paperless/paperless.conf is given precedence. In that case, remove or rename /usr/share/paperless/paperless.conf and restart paperless.target.

Warning about misconfigured retry and timeout

If you see a warning about misconfigured retry and timeout, you can safely ignore it and wait for the simple upstream fix in python-django-q. The warning would look like this:

gunicorn[29457]: /usr/lib/python3.9/site-packages/django_q/conf.py:136: UserWarning: Retry and timeout are misconfigured. Set retry larger than timeout,
gunicorn[29457]:         failure to do so will cause the tasks to be retriggered before completion.
gunicorn[29457]:         See https://django-q.readthedocs.io/en/latest/configure.html#retry for details.
gunicorn[29457]:   warn("""Retry and timeout are misconfigured. Set retry larger than timeout,

Thumbnail generation with ImageMagick fails

You have to disable a policy rule in /etc/ImageMagick-7/policy.xml. Add <!-- and --> to comment out the following line:

/etc/ImageMagick-7/policy.xml
<!-- <policy domain="delegate" rights="none" pattern="gs" /> -->

Consider the possible security implications noted at the beginning of the ImageMagick article. Also note that Paperless will fall back to using ghostscript anyway if the ImageMagick policy rule stays active.

The consumer service keeps one CPU core constantly at 100%

Uncomment the line concerning the PAPERLESS_CONSUMER_POLLING setting in your /etc/paperless.conf configuration file:

/etc/paperless.conf
PAPERLESS_CONSUMER_POLLING=10