Compare commits
5 commits
c70b5f90d1
...
8632430a4a
Author | SHA1 | Date | |
---|---|---|---|
8632430a4a | |||
1f70a4f6aa | |||
9452376873 | |||
2aa5edf2ac | |||
a478052194 |
7 changed files with 169 additions and 16 deletions
|
@ -16,3 +16,9 @@ tab_width = 2
|
|||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.py]
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
tab_width = 4
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
.env
|
||||
**/.vscode/*
|
||||
paperless/scripts/passwords.txt
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
services:
|
||||
|
||||
app:
|
||||
image: linuxserver/heimdall:${HEIMDALL_VERSION}
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Europe/Berlin
|
||||
homer:
|
||||
image: b4bz/homer
|
||||
volumes:
|
||||
- ${VOLUMES_PATH}/dashboard/heimdall:/config
|
||||
expose:
|
||||
- "80"
|
||||
- ${VOLUMES_PATH}/dashboard/homer:/www/assets
|
||||
networks:
|
||||
- web
|
||||
user: 1000:1000
|
||||
environment:
|
||||
- INIT_ASSETS=1
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.routers.heimdall.rule=Host(`dashboard.${DOMAIN}`)"
|
||||
- "traefik.http.routers.heimdall.entrypoints=web"
|
||||
- "traefik.http.services.heimdall.loadbalancer.server.port=80"
|
||||
- "traefik.http.routers.homer.rule=Host(`dashboard.${DOMAIN}`)"
|
||||
- "traefik.http.routers.homer.entrypoints=web"
|
||||
- "traefik.http.services.homer.loadbalancer.server.port=8080"
|
||||
- "docker.group=dashboard"
|
||||
restart: unless-stopped
|
||||
|
||||
|
|
62
doc/manual.md
Normal file
62
doc/manual.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
# Manual and Help
|
||||
|
||||
## Upgrade Postgrs to newer Version (i.e. 15 to 16)
|
||||
|
||||
|
||||
### 1. Copy Service
|
||||
|
||||
1.1 Copy whole service definition in docker-compose.yaml
|
||||
1.2 Rename old service to *-old
|
||||
1.3 Move path from new service to i.e postgres16
|
||||
1.4 Set postgres version explicit to new version
|
||||
|
||||
Example:
|
||||
```
|
||||
databasedb-old:
|
||||
image: postgres:${POSTGRES_VERSION}
|
||||
volumes:
|
||||
- ${VOLUMES_PATH}/databasedb:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
|
||||
databasedb:
|
||||
image: postgres:16
|
||||
volumes:
|
||||
- ${VOLUMES_PATH}/databasedb16:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=${POSTGRES_DB}
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
```
|
||||
|
||||
### 2. Move data
|
||||
Backup data from service one to new servic with the following command:
|
||||
```
|
||||
docker exec old-service pg_dumpall -U dbuser | docker exec -i new-service psql -U dbuser -d database
|
||||
```
|
||||
|
||||
### 3. Set password
|
||||
```
|
||||
docker exec -i monitoring-databasedb-1 psql -U dbuser -d database -c "ALTER USER \"dbuser\" PASSWORD 'secret';"
|
||||
```
|
||||
|
||||
### 4. Test
|
||||
```docker compose up -d``` and check if service is correctly running.
|
||||
|
||||
### 5. Cleanup
|
||||
5.1 Remove old service in docker-compose.yaml
|
||||
5.2 Set explicit version again to ${POSTGRES_VERSION} and adopt .env file
|
||||
5.4 remove old volume dir
|
||||
|
||||
|
||||
### 6. May be move Data dir
|
||||
6.1. ```docker compose down```
|
||||
6.2 ```mv /mnt/dockervolumes/databasedb16 /mnt/dockervolumes/databasedb```
|
||||
6.3 docker-compose.yaml anpassen
|
||||
6.1. ```docker compose up -d```
|
||||
|
||||
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ services:
|
|||
retries: 5
|
||||
volumes:
|
||||
- ${VOLUMES_PATH}/paperless/data:/usr/src/paperless/data
|
||||
- ${VOLUMES_PATH}/paperless/scripts:/usr/src/paperless/scripts
|
||||
- ./scripts:/usr/src/paperless/scripts
|
||||
- ${MEDIA_PATH}:/usr/src/paperless/media
|
||||
- ${EXPORT_PATH}:/usr/src/paperless/export
|
||||
- ${CONSUME_PATH}:/usr/src/paperless/consume
|
||||
|
|
87
paperless/scripts/removePdfPassword.py
Executable file
87
paperless/scripts/removePdfPassword.py
Executable file
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""Script for papeless-ngx to decrypt pdf files secured with a password
|
||||
Passwords to check ar in file /usr/src/paperless/scripts/passwords.txt
|
||||
Original from https://piep.tech/posts/automatic-password-removal-in-paperless-ngx/
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import pikepdf
|
||||
|
||||
|
||||
PWD_PATH = "/usr/src/paperless/scripts/passwords.txt"
|
||||
#PWD_PATH = "input/passwords.txt"
|
||||
|
||||
|
||||
def read_passwords_from_file():
|
||||
"""Read Paswors from file"""
|
||||
passwords = []
|
||||
|
||||
with open(PWD_PATH, "r", encoding="utf-8") as f:
|
||||
passwords = f.readlines()
|
||||
|
||||
passwords = list(filter(len, map(str.strip, passwords)))
|
||||
if not passwords:
|
||||
print("Empty password file")
|
||||
|
||||
passwords.append("") # some PDFs are encrypted with empty password
|
||||
return passwords
|
||||
|
||||
|
||||
def unlock_pdf(file_path, password_list):
|
||||
"""Removes Password from PDF. A list of passwords is tried through."""
|
||||
for pwd in password_list:
|
||||
try:
|
||||
with pikepdf.open(file_path, password=pwd, allow_overwriting_input=True) as pdf:
|
||||
pdf.save(file_path)
|
||||
return True
|
||||
except pikepdf.PasswordError:
|
||||
continue
|
||||
return False
|
||||
|
||||
|
||||
def is_pdf_encrypted(file_path):
|
||||
"""Checks if a PDF file is encrypted"""
|
||||
try:
|
||||
with pikepdf.open(file_path) as pdf:
|
||||
return pdf.is_encrypted
|
||||
except pikepdf.PasswordError:
|
||||
return True
|
||||
|
||||
|
||||
def is_pdf(file_path):
|
||||
"""Check if Filename ends with PDF. File is not opened"""
|
||||
return os.path.splitext(file_path)[-1].lower() == ".pdf"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
doc_path = os.environ.get('DOCUMENT_WORKING_PATH')
|
||||
|
||||
if not doc_path:
|
||||
doc_path = sys.argv[1]
|
||||
|
||||
if not doc_path:
|
||||
print("Neither DOCUMENT_WORKING_PATH set nor document passed by parameter.")
|
||||
sys.exit(1)
|
||||
|
||||
if not os.path.exists(doc_path):
|
||||
print(f"Document {doc_path} not found.")
|
||||
sys.exit(1)
|
||||
|
||||
if not is_pdf(doc_path):
|
||||
print(f"Document {doc_path} is not a PDF. So no decryption needed.")
|
||||
sys.exit(0)
|
||||
|
||||
if not is_pdf_encrypted(doc_path):
|
||||
print(f"Document {doc_path} was already decrypted and no password needed.")
|
||||
sys.exit(0)
|
||||
|
||||
pwds = read_passwords_from_file()
|
||||
if unlock_pdf(doc_path, pwds):
|
||||
print(f"Document {doc_path} successfull decrypted.")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print(f"Document {doc_path} could not be decrypted.")
|
||||
sys.exit(1)
|
|
@ -1,7 +1,7 @@
|
|||
services:
|
||||
|
||||
homeassistant:
|
||||
image: ghcr.io/home-assistant/home-assistant:stable
|
||||
image: ghcr.io/home-assistant/home-assistant:${HASSI_VERSION}
|
||||
volumes:
|
||||
- ${VOLUMES_PATH}/smartHome/homeassistent:/config
|
||||
- /run/dbus:/run/dbus:ro
|
||||
|
@ -17,7 +17,7 @@ services:
|
|||
- "docker.group=smartHome"
|
||||
|
||||
mqttbroker:
|
||||
image: eclipse-mosquitto:2.0
|
||||
image: eclipse-mosquitto:${MOSQUITTO_VERSION}
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
expose:
|
||||
|
|
Loading…
Reference in a new issue