Gramps: move assets to local storage
This commit is contained in:
@@ -16,9 +16,9 @@ services:
|
|||||||
- "{{ (data_dir, 'gramps_users') | path_join }}:/app/users" # persist user database
|
- "{{ (data_dir, 'gramps_users') | path_join }}:/app/users" # persist user database
|
||||||
- "{{ (data_dir, 'gramps_index') | path_join }}:/app/indexdir" # persist search index
|
- "{{ (data_dir, 'gramps_index') | path_join }}:/app/indexdir" # persist search index
|
||||||
- "{{ (data_dir, 'gramps_secret') | path_join }}:/app/secret" # persist flask secret
|
- "{{ (data_dir, 'gramps_secret') | path_join }}:/app/secret" # persist flask secret
|
||||||
- "{{ (data_dir, 'gramps_media') | path_join }}:/app/media" # persist media files
|
|
||||||
- "{{ (cache_dir, 'gramps_thumb_cache') | path_join }}:/app/thumbnail_cache" # persist thumbnails
|
- "{{ (cache_dir, 'gramps_thumb_cache') | path_join }}:/app/thumbnail_cache" # persist thumbnails
|
||||||
- "{{ (cache_dir, 'gramps_cache') | path_join }}:/app/cache" # persist export and report caches
|
- "{{ (cache_dir, 'gramps_cache') | path_join }}:/app/cache" # persist export and report caches
|
||||||
|
- "{{ media_dir }}:/app/media" # persist media files
|
||||||
environment:
|
environment:
|
||||||
GRAMPSWEB_TREE: "Gramps" # will create a new tree if not exists
|
GRAMPSWEB_TREE: "Gramps" # will create a new tree if not exists
|
||||||
GRAMPSWEB_SECRET_KEY: "{{ gramps_secret_key }}"
|
GRAMPSWEB_SECRET_KEY: "{{ gramps_secret_key }}"
|
||||||
@@ -37,12 +37,8 @@ services:
|
|||||||
GRAMPSWEB_EMAIL_USE_TLS: "false"
|
GRAMPSWEB_EMAIL_USE_TLS: "false"
|
||||||
GRAMPSWEB_DEFAULT_FROM_EMAIL: "gramps@vakhrushev.me"
|
GRAMPSWEB_DEFAULT_FROM_EMAIL: "gramps@vakhrushev.me"
|
||||||
|
|
||||||
# media storage at s3
|
# media storage
|
||||||
GRAMPSWEB_MEDIA_BASE_DIR: "s3://av-gramps-media-storage"
|
GRAMPSWEB_MEDIA_BASE_DIR: "/app/media"
|
||||||
AWS_ENDPOINT_URL: "{{ gramps_s3_endpoint }}"
|
|
||||||
AWS_ACCESS_KEY_ID: "{{ gramps_s3_access_key_id }}"
|
|
||||||
AWS_SECRET_ACCESS_KEY: "{{ gramps_s3_secret_access_key }}"
|
|
||||||
AWS_DEFAULT_REGION: "{{ gramps_s3_region }}"
|
|
||||||
|
|
||||||
gramps_celery:
|
gramps_celery:
|
||||||
<<: *gramps_app # YAML merge key copying the entire grampsweb service config
|
<<: *gramps_app # YAML merge key copying the entire grampsweb service config
|
||||||
|
|||||||
@@ -26,3 +26,4 @@ models:
|
|||||||
archive:
|
archive:
|
||||||
includes:
|
includes:
|
||||||
- "{{ data_dir }}"
|
- "{{ data_dir }}"
|
||||||
|
- "{{ media_dir }}"
|
||||||
|
|||||||
65
files/gramps/gramps_rename.py
Executable file
65
files/gramps/gramps_rename.py
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env python3.12
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args() -> argparse.Namespace:
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Rename Gramps document files by appending extensions from a list."
|
||||||
|
)
|
||||||
|
parser.add_argument("directory", type=Path, help="Directory containing hashed files")
|
||||||
|
parser.add_argument("names_file", type=Path, help="Text file with target names")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def read_names(path: Path) -> list[str]:
|
||||||
|
if not path.is_file():
|
||||||
|
raise FileNotFoundError(f"Names file not found: {path}")
|
||||||
|
|
||||||
|
names = []
|
||||||
|
for line in path.read_text(encoding="utf-8").splitlines():
|
||||||
|
name = line.strip()
|
||||||
|
if name:
|
||||||
|
names.append(name)
|
||||||
|
return names
|
||||||
|
|
||||||
|
|
||||||
|
def rename_files(directory: Path, names: list[str]) -> None:
|
||||||
|
if not directory.is_dir():
|
||||||
|
raise NotADirectoryError(f"Directory not found: {directory}")
|
||||||
|
|
||||||
|
for name in names:
|
||||||
|
hash_part, dot, _ = name.partition(".")
|
||||||
|
if not dot:
|
||||||
|
print(f"Skipping invalid entry (missing extension): {name}", file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
source = directory / hash_part
|
||||||
|
target = directory / name
|
||||||
|
|
||||||
|
if target.exists():
|
||||||
|
print(f"Target already exists, skipping: {target}", file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not source.exists():
|
||||||
|
print(f"Source not found, skipping: {source}", file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
source.rename(target)
|
||||||
|
print(f"Renamed {source.name} -> {target.name}")
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
args = parse_args()
|
||||||
|
try:
|
||||||
|
names = read_names(args.names_file)
|
||||||
|
rename_files(args.directory, names)
|
||||||
|
except Exception as exc: # noqa: BLE001
|
||||||
|
print(str(exc), file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
app_owner_gid: 1010
|
app_owner_gid: 1010
|
||||||
base_dir: "{{ (application_dir, app_name) | path_join }}"
|
base_dir: "{{ (application_dir, app_name) | path_join }}"
|
||||||
data_dir: "{{ (base_dir, 'data') | path_join }}"
|
data_dir: "{{ (base_dir, 'data') | path_join }}"
|
||||||
|
media_dir: "{{ (base_dir, 'media') | path_join }}"
|
||||||
cache_dir: "{{ (base_dir, 'cache') | path_join }}"
|
cache_dir: "{{ (base_dir, 'cache') | path_join }}"
|
||||||
backups_dir: "{{ (base_dir, 'backups') | path_join }}"
|
backups_dir: "{{ (base_dir, 'backups') | path_join }}"
|
||||||
gobackup_config: "{{ (base_dir, 'gobackup.yml') | path_join }}"
|
gobackup_config: "{{ (base_dir, 'gobackup.yml') | path_join }}"
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
loop:
|
loop:
|
||||||
- "{{ base_dir }}"
|
- "{{ base_dir }}"
|
||||||
- "{{ data_dir }}"
|
- "{{ data_dir }}"
|
||||||
|
- "{{ media_dir }}"
|
||||||
- "{{ cache_dir }}"
|
- "{{ cache_dir }}"
|
||||||
- "{{ backups_dir }}"
|
- "{{ backups_dir }}"
|
||||||
|
|
||||||
@@ -55,6 +57,14 @@
|
|||||||
group: "{{ app_user }}"
|
group: "{{ app_user }}"
|
||||||
mode: "0750"
|
mode: "0750"
|
||||||
|
|
||||||
|
- name: "Copy rename script"
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "files/{{ app_name }}/gramps_rename.py"
|
||||||
|
dest: "{{ base_dir }}/gramps_rename.py"
|
||||||
|
owner: "{{ app_user }}"
|
||||||
|
group: "{{ app_user }}"
|
||||||
|
mode: "0750"
|
||||||
|
|
||||||
- name: "Copy docker compose file"
|
- name: "Copy docker compose file"
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "./files/{{ app_name }}/docker-compose.template.yml"
|
src: "./files/{{ app_name }}/docker-compose.template.yml"
|
||||||
|
|||||||
Reference in New Issue
Block a user