-
Notifications
You must be signed in to change notification settings - Fork 12
/
start.sh
executable file
·136 lines (117 loc) · 4.86 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
set -e
PAPERLESS_PORT=8000
PAPERLESS_UID=1000
PAPERLESS_GID=1000
PAPERLESS_VERSION=latest
PAPERLESS_TIME_ZONE=America/Chicago
PAPERLESS_OCR_LANGUAGE=eng
SFTPGO_VERSION=v2.5.4
SFTPGO_SFTP_PORT=2022
SFTPGO_HTTP_PORT=8022
PAPERLESS_URL=https://localhost:8000
SFTPGO_ADMIN_USER=sftpadmin
SFTPGO_ADMIN_PASSWORD=supersecret
SFTPGO_PAPERLESS_USER=scanner
SFTPGO_PAPERLESS_PASSWORD=anothersupersecret
SFTPGO_SFTPD_KEX_ALGORITHMS=curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
SFTPGO_SFTPD_HOST_KEY_ALGORITHMS=rsa-sha2-256,rsa-sha2-512,ecdsa-sha2-nistp256,ssh-ed25519,ssh-rsa
PAPERLESS_SECRET_KEY=chamgemechamgemechamgemechamgemechamgemechamgemechamgemechamgeme
REDIS_VERSION=6
REDIS_PORT=6379
POSTGRESQL_VERSION=13
POSTGRESQL_PORT=5432
POSTGRES_USER=paperless
POSTGRESQL_DB=paperless
POSTGRESQL_PASSWORD=paperlesschangeme
echo "Creating Paperless Pod..."
podman pod create --replace --name paperless \
--infra-name paperless-pod \
-p ${PAPERLESS_PORT}:${PAPERLESS_PORT} \
-p ${SFTPGO_SFTP_PORT}:${SFTPGO_SFTP_PORT} \
-p ${SFTPGO_HTTP_PORT}:${SFTPGO_HTTP_PORT}
echo "Starting Redis..."
podman volume create paperless-redis 2> /dev/null ||:
podman create --replace --pod paperless \
--restart=unless-stopped \
--name paperless-redis \
--volume paperless-redis:/data:Z \
docker.io/library/redis:${REDIS_VERSION}
podman start paperless-redis
echo "Starting PostgreSQL..."
podman volume create paperless-postgresql 2> /dev/null ||:
podman create --replace --pod paperless \
--restart=unless-stopped \
--name paperless-postgresql \
--expose ${POSTGRESQL_PORT} \
-e POSTGRES_USER=${POSTGRES_USER} \
-e POSTGRES_PASSWORD=${POSTGRESQL_PASSWORD} \
--volume paperless-postgresql:/var/lib/postgresql/data:Z \
docker.io/library/postgres:${POSTGRESQL_VERSION}
podman start paperless-postgresql
echo "Starting Gotenberg..."
podman create --replace --pod paperless \
--restart=unless-stopped \
--name paperless-gotenberg \
-e CHROMIUM_DISABLE_ROUTES=1 \
docker.io/gotenberg/gotenberg:7
podman start paperless-gotenberg
echo "Starting Tika..."
podman create --replace --pod paperless \
--restart=unless-stopped \
--name paperless-tika \
docker.io/apache/tika
podman start paperless-tika
echo "Starting Paperless..."
podman create --replace --pod paperless \
--name paperless-webserver \
--restart=unless-stopped \
--stop-timeout=90 \
--health-cmd='["curl", "-f", "http://localhost:8000"]' \
--health-retries=5 \
--health-start-period=60s \
--health-timeout=10s \
-e PAPERLESS_REDIS=redis://localhost:${REDIS_PORT} \
-e PAPERLESS_DBHOST=localhost \
-e PAPERLESS_DBNAME=${POSTGRES_USER} \
-e PAPERLESS_DBPASS=${POSTGRESQL_PASSWORD} \
-e PAPERLESS_TIKA_ENABLED=1 \
-e PAPERLESS_TIKA_GOTENBERG_ENDPOINT=http://localhost:3000 \
-e PAPERLESS_TIKA_ENDPOINT=http://localhost:9998 \
-e PAPERLESS_URL=${PAPERLESS_URL} \
-e USERMAP_UID=${PAPERLESS_UID} \
-e USERMAP_GID=${PAPERLESS_GID} \
-e PAPERLESS_SECRET_KEY=${PAPERLESS_SECRET_KEY} \
-e PAPERLESS_TIME_ZONE=${PAPERLESS_TIME_ZONE} \
-e PAPERLESS_OCR_LANGUAGE=${PAPERLESS_OCR_LANGUAGE} \
-v paperless-data:/usr/src/paperless/data:Z \
-v paperless-media:/usr/src/paperless/media:Z \
-v paperless-consume:/usr/src/paperless/consume:U,z \
-v ${PWD}/export:/usr/src/paperless/export:U,Z \
ghcr.io/paperless-ngx/paperless-ngx:${PAPERLESS_VERSION}
podman start paperless-webserver
echo "Starting SFTPGo..."
podman create --replace --pod paperless \
--restart=unless-stopped \
--name paperless-sftpgo \
-e SFTPGO_DATA_PROVIDER__CREATE_DEFAULT_ADMIN=1 \
-e SFTPGO_DEFAULT_ADMIN_USERNAME=${SFTPGO_ADMIN_USER} \
-e SFTPGO_DEFAULT_ADMIN_PASSWORD=${SFTPGO_ADMIN_PASSWORD} \
-e SFTPGO_HTTPD__BINDINGS__0__PORT=${SFTPGO_HTTP_PORT} \
-e SFTPGO_SFTPD__KEX_ALGORITHMS=${SFTPGO_SFTPD_KEX_ALGORITHMS} \
-e SFTPGO_SFTPD__HOST_KEY_ALGORITHMS=${SFTPGO_SFTPD_HOST_KEY_ALGORITHMS} \
-v paperless-sftpgo:/var/lib/sftpgo:Z \
-v paperless-consume:/opt/paperless/consume:rw,z \
ghcr.io/drakkan/sftpgo:${SFTPGO_VERSION}
podman start paperless-sftpgo
sleep 5
JWT=$(curl -s -u ${SFTPGO_ADMIN_USER}:${SFTPGO_ADMIN_PASSWORD} http://127.0.0.1:${SFTPGO_HTTP_PORT}/api/v2/token | jq -r '.access_token')
curl -s --header "Content-Type: application/json" \
--header 'Accept: application/json' -H "Authorization: Bearer ${JWT}" \
--request POST \
--data '{"username": "'${SFTPGO_PAPERLESS_USER}'", "password": "'${SFTPGO_PAPERLESS_PASSWORD}'", "status": 1, "home_dir": "/opt/paperless/consume", "permissions": {"/": ["*"]}}' \
http://127.0.0.1:${SFTPGO_HTTP_PORT}/api/v2/users
SFTP_PUBLIC_KEY=$(podman exec -it paperless-sftpgo cat /var/lib/sftpgo/id_rsa.pub)
echo "Add the SFTP Public Key to your scanner:"
echo "${SFTP_PUBLIC_KEY}"
echo "${SFTP_PUBLIC_KEY}" > ${PWD}/sftp_rsa_host_key.pub