|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2026 community-scripts ORG |
| 4 | +# Author: GitHub Copilot |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE |
| 6 | +# Source: https://www.grampsweb.org/ |
| 7 | + |
| 8 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
| 9 | +color |
| 10 | +verb_ip6 |
| 11 | +catch_errors |
| 12 | +setting_up_container |
| 13 | +network_check |
| 14 | +update_os |
| 15 | + |
| 16 | +if apt-cache show libgirepository-2.0-dev >/dev/null 2>&1; then |
| 17 | + GI_DEV_PACKAGE="libgirepository-2.0-dev" |
| 18 | +else |
| 19 | + GI_DEV_PACKAGE="libgirepository1.0-dev" |
| 20 | +fi |
| 21 | + |
| 22 | +msg_info "Installing Dependencies" |
| 23 | +$STD apt install -y \ |
| 24 | + appstream \ |
| 25 | + build-essential \ |
| 26 | + ffmpeg \ |
| 27 | + gettext \ |
| 28 | + gir1.2-gexiv2-0.10 \ |
| 29 | + gir1.2-gtk-3.0 \ |
| 30 | + gir1.2-osmgpsmap-1.0 \ |
| 31 | + gir1.2-pango-1.0 \ |
| 32 | + git \ |
| 33 | + graphviz \ |
| 34 | + libicu-dev \ |
| 35 | + libopencv-dev \ |
| 36 | + pkg-config \ |
| 37 | + poppler-utils \ |
| 38 | + python3-dev \ |
| 39 | + tesseract-ocr \ |
| 40 | + "$GI_DEV_PACKAGE" |
| 41 | +msg_ok "Installed Dependencies" |
| 42 | + |
| 43 | +PYTHON_VERSION="3.12" setup_uv |
| 44 | +NODE_VERSION="22" setup_nodejs |
| 45 | + |
| 46 | +fetch_and_deploy_gh_release "gramps-web-api" "gramps-project/gramps-web-api" "tarball" "latest" "/opt/gramps-web-api" |
| 47 | +fetch_and_deploy_gh_release "gramps-web" "gramps-project/gramps-web" "tarball" "latest" "/opt/gramps-web/frontend" |
| 48 | + |
| 49 | +msg_info "Setting up Gramps Web" |
| 50 | +mkdir -p \ |
| 51 | + /opt/gramps-web/config \ |
| 52 | + /opt/gramps-web/data/cache/export \ |
| 53 | + /opt/gramps-web/data/cache/persistent \ |
| 54 | + /opt/gramps-web/data/cache/report \ |
| 55 | + /opt/gramps-web/data/cache/request \ |
| 56 | + /opt/gramps-web/data/cache/thumbnail \ |
| 57 | + /opt/gramps-web/data/gramps/grampsdb \ |
| 58 | + /opt/gramps-web/data/indexdir \ |
| 59 | + /opt/gramps-web/data/media \ |
| 60 | + /opt/gramps-web/data/users |
| 61 | + |
| 62 | +SECRET_KEY="$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")" |
| 63 | + |
| 64 | +cat <<EOF >/opt/gramps-web/config/config.cfg |
| 65 | +TREE="Gramps Web" |
| 66 | +SECRET_KEY="${SECRET_KEY}" |
| 67 | +BASE_URL="http://${LOCAL_IP}:5000" |
| 68 | +USER_DB_URI="sqlite:////opt/gramps-web/data/users/users.sqlite" |
| 69 | +SEARCH_INDEX_DB_URI="sqlite:////opt/gramps-web/data/indexdir/search_index.db" |
| 70 | +MEDIA_BASE_DIR="/opt/gramps-web/data/media" |
| 71 | +STATIC_PATH="/opt/gramps-web/frontend/dist" |
| 72 | +THUMBNAIL_CACHE_CONFIG={"CACHE_TYPE":"FileSystemCache","CACHE_DIR":"/opt/gramps-web/data/cache/thumbnail","CACHE_THRESHOLD":1000,"CACHE_DEFAULT_TIMEOUT":0} |
| 73 | +REQUEST_CACHE_CONFIG={"CACHE_TYPE":"FileSystemCache","CACHE_DIR":"/opt/gramps-web/data/cache/request","CACHE_THRESHOLD":1000,"CACHE_DEFAULT_TIMEOUT":0} |
| 74 | +PERSISTENT_CACHE_CONFIG={"CACHE_TYPE":"FileSystemCache","CACHE_DIR":"/opt/gramps-web/data/cache/persistent","CACHE_THRESHOLD":0,"CACHE_DEFAULT_TIMEOUT":0} |
| 75 | +REPORT_DIR="/opt/gramps-web/data/cache/report" |
| 76 | +EXPORT_DIR="/opt/gramps-web/data/cache/export" |
| 77 | +EOF |
| 78 | + |
| 79 | +$STD uv venv -c -p python3.12 /opt/gramps-web/venv |
| 80 | +source /opt/gramps-web/venv/bin/activate |
| 81 | +$STD uv pip install --no-cache-dir --upgrade pip setuptools wheel |
| 82 | +$STD uv pip install --no-cache-dir gunicorn |
| 83 | +$STD uv pip install --no-cache-dir /opt/gramps-web-api |
| 84 | + |
| 85 | +cd /opt/gramps-web/frontend |
| 86 | +export COREPACK_ENABLE_DOWNLOAD_PROMPT=0 |
| 87 | +corepack enable |
| 88 | +$STD npm install |
| 89 | +$STD npm run build |
| 90 | + |
| 91 | +GRAMPS_API_CONFIG=/opt/gramps-web/config/config.cfg \ |
| 92 | + GRAMPSHOME=/opt/gramps-web/data/gramps \ |
| 93 | + GRAMPS_DATABASE_PATH=/opt/gramps-web/data/gramps/grampsdb \ |
| 94 | + $STD /opt/gramps-web/venv/bin/python3 -m gramps_webapi user migrate |
| 95 | +msg_ok "Set up Gramps Web" |
| 96 | + |
| 97 | +msg_info "Creating Service" |
| 98 | +cat <<EOF >/etc/systemd/system/gramps-web.service |
| 99 | +[Unit] |
| 100 | +Description=Gramps Web Service |
| 101 | +After=network.target |
| 102 | +
|
| 103 | +[Service] |
| 104 | +Type=simple |
| 105 | +User=root |
| 106 | +WorkingDirectory=/opt/gramps-web-api |
| 107 | +Environment=GRAMPS_API_CONFIG=/opt/gramps-web/config/config.cfg |
| 108 | +Environment=GRAMPSHOME=/opt/gramps-web/data/gramps |
| 109 | +Environment=GRAMPS_DATABASE_PATH=/opt/gramps-web/data/gramps/grampsdb |
| 110 | +Environment=PATH=/opt/gramps-web/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
| 111 | +ExecStart=/opt/gramps-web/venv/bin/gunicorn -w 2 -b 0.0.0.0:5000 gramps_webapi.wsgi:app --timeout 120 --limit-request-line 8190 |
| 112 | +Restart=on-failure |
| 113 | +RestartSec=5 |
| 114 | +
|
| 115 | +[Install] |
| 116 | +WantedBy=multi-user.target |
| 117 | +EOF |
| 118 | +systemctl enable -q --now gramps-web |
| 119 | +msg_ok "Created Service" |
| 120 | + |
| 121 | +motd_ssh |
| 122 | +customize |
| 123 | +cleanup_lxc |
0 commit comments