├── doc
├── .gitkeep
├── screenshots
│ ├── .gitkeep
│ └── immich-screenshots.png
├── DESCRIPTION.md
├── DESCRIPTION_fr.md
├── POST_INSTALL.md
├── POST_UPGRADE.md
├── PRE_INSTALL.md
├── PRE_UPGRADE.md
├── POST_INSTALL_fr.md
├── POST_UPGRADE_fr.md
├── PRE_INSTALL_fr.md
├── PRE_UPGRADE_fr.md
└── ADMIN.md
├── .gitignore
├── conf
├── immich-server-start.sh
├── env
├── nginx.conf
├── immich-machine-learning-start.sh
├── restore_immich_db_backup.sh
├── immich-machine-learning.service
└── immich-server.service
├── .github
├── PULL_REQUEST_TEMPLATE.md
├── workflows
│ ├── update_master.yml
│ └── package_linter.yml
└── ISSUE_TEMPLATE.md
├── tests.toml
├── scripts
├── remove
├── change_url
├── backup
├── restore
├── install
├── upgrade
└── _common.sh
├── README.md
├── manifest.toml
└── LICENSE
/doc/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/doc/screenshots/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | *.sw[op]
3 |
--------------------------------------------------------------------------------
/doc/screenshots/immich-screenshots.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YunoHost-Apps/immich_ynh/HEAD/doc/screenshots/immich-screenshots.png
--------------------------------------------------------------------------------
/conf/immich-server-start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -a
4 | source "__INSTALL_DIR__/immich/env"
5 | set +a
6 |
7 | cd "__INSTALL_DIR__/immich/app"
8 | exec __NODEJS_DIR__/node "__INSTALL_DIR__/immich/app/dist/main" "$@"
9 |
--------------------------------------------------------------------------------
/doc/DESCRIPTION.md:
--------------------------------------------------------------------------------
1 | Self-hosted photo and video management solution.
2 |
3 | ### Features
4 |
5 | - Simple-to-use backup tool with a native mobile app that can view photos and videos efficiently ;
6 | - Easy-to-use and friendly interface
7 |
--------------------------------------------------------------------------------
/doc/DESCRIPTION_fr.md:
--------------------------------------------------------------------------------
1 | Solution d'autohébergement pour la gestion de vos photos et vidéos.
2 |
3 | ### Caractéristiques
4 |
5 | - Sauvegarde depuis l'applicaton mobile qui permet également de visualiser efficacement photos et vidéos ;
6 | - Interface conviviale et egronomique
7 |
--------------------------------------------------------------------------------
/doc/POST_INSTALL.md:
--------------------------------------------------------------------------------
1 | ⚠️ Immich v2.3.2 will certainly be the last (or one of the last) update for Debian Bookworm (aka YunoHost 12).
2 | Building Immich and its new plugins functionality require external tools not compiled against Debian Bookworm. I manage it by compiling them on my own repo, which is not a sustainable situation.
3 |
--------------------------------------------------------------------------------
/doc/POST_UPGRADE.md:
--------------------------------------------------------------------------------
1 | ⚠️ Immich v2.3.2 will certainly be the last (or one of the last) update for Debian Bookworm (aka YunoHost 12).
2 | Building Immich and its new plugins functionality require external tools not compiled against Debian Bookworm. I manage it by compiling them on my own repo, which is not a sustainable situation.
3 |
--------------------------------------------------------------------------------
/doc/PRE_INSTALL.md:
--------------------------------------------------------------------------------
1 | - ⚠️ Always follow [3-2-1](https://www.backblaze.com/blog/the-3-2-1-backup-strategy/) backup plan for your precious photos and videos!
2 |
3 | - ℹ️ The installation requires some free memory to succeed. A swap file will be created if needed.
4 |
5 | - ⏳ Not only resource hungry, the building process take a long time to achieve. This can be very long, be patient !
6 |
--------------------------------------------------------------------------------
/doc/PRE_UPGRADE.md:
--------------------------------------------------------------------------------
1 | - ⚠️ Always follow [3-2-1](https://www.backblaze.com/blog/the-3-2-1-backup-strategy/) backup plan for your precious photos and videos!
2 |
3 | - ℹ️ The installation requires some free memory to succeed. A swap file will be created if needed.
4 |
5 | - ⏳ Not only resource hungry, the building process take a long time to achieve. This can be very long, be patient !
6 |
7 |
--------------------------------------------------------------------------------
/doc/POST_INSTALL_fr.md:
--------------------------------------------------------------------------------
1 | ⚠️ Immich v2.3.2 sera certainement la dernière (ou l'une des dernières) mise à jour pour Debian Bookworm (càd YunoHost 12).
2 | Compiler Immich et sa nouvelle focntionnalité de plugins requiert des outls externes qui ne sont pas tous existant pour Debian Bookworm. Pour gérer ce problème je les ai compilé sur dans mon dépôt personnel, ce qui n'est pas maintenable sur du long terme.
3 |
--------------------------------------------------------------------------------
/doc/POST_UPGRADE_fr.md:
--------------------------------------------------------------------------------
1 | ⚠️ Immich v2.3.2 sera certainement la dernière (ou l'une des dernières) mise à jour pour Debian Bookworm (càd YunoHost 12).
2 | Compiler Immich et sa nouvelle focntionnalité de plugins requiert des outls externes qui ne sont pas tous existant pour Debian Bookworm. Pour gérer ce problème je les ai compilé sur dans mon dépôt personnel, ce qui n'est pas maintenable sur du long terme.
3 |
--------------------------------------------------------------------------------
/doc/PRE_INSTALL_fr.md:
--------------------------------------------------------------------------------
1 | - ⚠️ Il est important de toujours respecter la règle [3-2-1](https://www.backblaze.com/blog/the-3-2-1-backup-strategy/) comme stratégie de sauvegarde pour vos précieuses photos et vidéos !
2 |
3 | - ℹ️ Le processus d'installation nécessite suffisemment de mémoire vive libre pour aboutir. Un fichier swap sera créé si nécessaire.
4 |
5 | - ⏳ Non seulement gourmande en resource, la construction de l'application dure longtemps. Cela peut être vraiment très long... soyez patient !
6 |
--------------------------------------------------------------------------------
/doc/PRE_UPGRADE_fr.md:
--------------------------------------------------------------------------------
1 | - ⚠️ Il est important de toujours respecter la règle [3-2-1](https://www.backblaze.com/blog/the-3-2-1-backup-strategy/) comme stratégie de sauvegarde pour vos précieuses photos et vidéos !
2 |
3 | - ℹ️ Le processus d'installation nécessite suffisemment de mémoire vive libre pour aboutir. Un fichier swap sera créé si nécessaire.
4 |
5 | - ⏳ Non seulement gourmande en resource, la construction de l'application dure longtemps. Cela peut être vraiment très long... soyez patient !
6 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Problem
2 |
3 | - *Description of why you made this PR*
4 |
5 | ## Solution
6 |
7 | - *And how do you fix that problem*
8 |
9 | ## PR Status
10 |
11 | - [ ] Code finished and ready to be reviewed/tested
12 | - [ ] The fix/enhancement were manually tested (if applicable)
13 |
14 | ## Automatic tests
15 |
16 | Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)
17 |
--------------------------------------------------------------------------------
/doc/ADMIN.md:
--------------------------------------------------------------------------------
1 | ### Proper backups
2 |
3 | Always follow [3-2-1](https://www.backblaze.com/blog/the-3-2-1-backup-strategy/) backup plan for your precious photos and videos!
4 |
5 | ### Automatic Database Dumps (see [here](https://immich.app/docs/administration/backup-and-restore/#automatic-database-dumps))
6 |
7 | In order to restore a backup done by __APP__ itself:
8 | 1. Open an shell session using **root**[^1]: `sudo su`
9 |
10 | 2. Go to the backups folder: `cd __DATA_DIR__/backups`
11 |
12 | 3. Restore a backup by launching that script: `bash restore_immich_db_backup.sh`
13 |
14 | [^1]: you may still be able to login using `root` from the local network - or from a direct console on the server.
15 |
--------------------------------------------------------------------------------
/tests.toml:
--------------------------------------------------------------------------------
1 | #:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
2 |
3 | test_format = 1.0
4 |
5 | [default]
6 |
7 | # ------------
8 | # Tests to run
9 | # ------------
10 |
11 | # -------------------------------
12 | # Default args to use for install
13 | # -------------------------------
14 |
15 | # -------------------------------
16 | # Commits to test upgrade from
17 | # -------------------------------
18 | #test_upgrade_from.d70256707e598e5817b600036a742da65939746a.name = "Upgrade from 1.136.0~ynh1"
19 | #test_upgrade_from.f1b8557e127accfaea284851cbd47ba3964dfd38.name = "Upgrade from 1.141.1~ynh1"
20 | test_upgrade_from.7b46f4dd6540b38ab2d1667acea38798bf40a680.name = "Upgrade from 2.2.3~ynh2"
21 |
--------------------------------------------------------------------------------
/.github/workflows/update_master.yml:
--------------------------------------------------------------------------------
1 | name: Create master promotion pull request
2 | on:
3 | # Allow to manually trigger the workflow
4 | workflow_dispatch:
5 | # Run it when when someone pushes to testing
6 | push:
7 | branches:
8 | - testing
9 | jobs:
10 | masterPromotion:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v4
14 | with:
15 | ref: master
16 | - name: Reset promotion branch
17 | run: |
18 | git fetch origin testing:testing
19 | git reset --hard testing
20 | - name: Create Pull Request
21 | uses: peter-evans/create-pull-request@v6
22 | with:
23 | branch: master-promotion
24 | title: 'Upgrade master from testing'
25 | body: |
26 | Upgrade master from testing
27 |
--------------------------------------------------------------------------------
/conf/env:
--------------------------------------------------------------------------------
1 | ## General
2 | NODE_ENV=production
3 | UPLOAD_LOCATION=__DATA_DIR__
4 | IMMICH_MEDIA_LOCATION=__DATA_DIR__
5 | IMMICH_WEB_ROOT=__INSTALL_DIR__/immich/app/www
6 | IMMICH_VERSION=release
7 | IMMICH_LOG_LEVEL=log
8 |
9 | ## Ports
10 | IMMICH_HOST=127.0.0.1
11 | IMMICH_PORT=__PORT__
12 | IMMICH_MACHINE_LEARNING_URL=http://127.0.0.1:__PORT_MACHINELEARNING__
13 |
14 | ## Database
15 | DB_HOSTNAME=127.0.0.1
16 | DB_PORT=__DB_PORT__
17 | DB_USERNAME=__APP__
18 | DB_PASSWORD=__DB_PWD__
19 | DB_DATABASE_NAME=__APP__
20 | DB_VECTOR_EXTENSION=pgvector
21 |
22 | ## Redis
23 | REDIS_HOSTNAME=127.0.0.1
24 |
25 | ## Third-party information
26 | IMMICH_THIRD_PARTY_SOURCE_URL=https://github.com/YunoHost-Apps/immich_ynh/
27 | IMMICH_THIRD_PARTY_BUG_FEATURE_URL=https://github.com/YunoHost-Apps/immich_ynh/issues
28 |
29 | LD_LIBRARY_PATH=__INSTALL_DIR__/vips/lib
30 |
--------------------------------------------------------------------------------
/conf/nginx.conf:
--------------------------------------------------------------------------------
1 | location __PATH__/ {
2 |
3 | proxy_pass http://127.0.0.1:__PORT__;
4 |
5 | # allow large file uploads
6 | client_max_body_size 50G;
7 | client_body_timeout 600s;
8 | client_body_buffer_size 512k;
9 |
10 | # Set headers
11 | proxy_set_header Host $host;
12 | proxy_set_header X-Real-IP $remote_addr;
13 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
14 | proxy_set_header X-Forwarded-Proto $scheme;
15 | proxy_set_header X-Forwarded-Host $server_name;
16 |
17 | # enable websockets: http://nginx.org/en/docs/http/websocket.html
18 | proxy_http_version 1.1;
19 | proxy_set_header Upgrade $http_upgrade;
20 | proxy_set_header Connection "upgrade";
21 | proxy_redirect off;
22 |
23 | # set timeout
24 | proxy_read_timeout 600s;
25 | proxy_send_timeout 600s;
26 | send_timeout 600s;
27 | }
28 |
--------------------------------------------------------------------------------
/.github/workflows/package_linter.yml:
--------------------------------------------------------------------------------
1 | name: YunoHost apps package linter
2 |
3 | on:
4 | # Allow to manually trigger the workflow
5 | workflow_dispatch:
6 | push:
7 | pull_request:
8 |
9 | jobs:
10 | test:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: actions/checkout@v4
14 |
15 | - name: Set up Python
16 | uses: actions/setup-python@v5
17 | with:
18 | python-version: '3.11'
19 |
20 | - name: Install dependencies
21 | run: |
22 | python -m pip install --upgrade pip
23 | pip install tomli pyparsing six jsonschema
24 |
25 | - name: 'Clone YunoHost apps package linter'
26 | run: |
27 | git clone --depth=1 https://github.com/YunoHost/package_linter ~/package_linter
28 |
29 | - name: 'Run linter'
30 | run: |
31 | ~/package_linter/package_linter.py .
32 |
--------------------------------------------------------------------------------
/conf/immich-machine-learning-start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -a
4 | source "__INSTALL_DIR__/immich/env"
5 | set +a
6 |
7 | cd "__INSTALL_DIR__/immich/app/machine-learning"
8 | source venv/bin/activate
9 |
10 | : "${IMMICH_HOST:=127.0.0.1}"
11 | : "${MACHINE_LEARNING_PORT:=__PORT_MACHINELEARNING__}"
12 | : "${MACHINE_LEARNING_WORKERS:=1}"
13 | : "${MACHINE_LEARNING_HTTP_KEEPALIVE_TIMEOUT_S:=2}"
14 | : "${MACHINE_LEARNING_WORKER_TIMEOUT:=300}"
15 | : "${MACHINE_LEARNING_CACHE_FOLDER:=__INSTALL_DIR__/immich/.cache_ml}"
16 | : "${TRANSFORMERS_CACHE:=__INSTALL_DIR__/immich/.cache_ml}"
17 |
18 | exec gunicorn immich_ml.main:app \
19 | --worker-class immich_ml.config.CustomUvicornWorker \
20 | --config immich_ml/gunicorn_conf.py \
21 | --bind "$IMMICH_HOST":"$MACHINE_LEARNING_PORT" \
22 | --workers "$MACHINE_LEARNING_WORKERS" \
23 | --timeout "$MACHINE_LEARNING_WORKER_TIMEOUT" \
24 | --log-config-json immich_ml/log_conf.json \
25 | --keep-alive "$MACHINE_LEARNING_HTTP_KEEPALIVE_TIMEOUT_S" \
26 | --graceful-timeout 10 \
27 | --log-level debug \
28 | --preload
29 |
--------------------------------------------------------------------------------
/scripts/remove:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #=================================================
4 | # IMPORT GENERIC HELPERS
5 | #=================================================
6 |
7 | source _common.sh
8 | source /usr/share/yunohost/helpers
9 |
10 | #=================================================
11 | # REMOVE SYSTEM CONFIGURATION
12 | #=================================================
13 | ynh_script_progression "Removing system configurations related to $app..."
14 |
15 | ynh_config_remove_fail2ban
16 |
17 | ynh_config_remove_logrotate
18 |
19 | # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
20 | if ynh_hide_warnings yunohost service status "$app-server" >/dev/null; then
21 | yunohost service remove "$app-server"
22 | fi
23 | ynh_config_remove_systemd "$app-server"
24 |
25 | if ynh_hide_warnings yunohost service status "$app-machine-learning" >/dev/null; then
26 | yunohost service remove "$app-machine-learning"
27 | fi
28 | ynh_config_remove_systemd "$app-machine-learning"
29 |
30 | ynh_config_remove_nginx
31 |
32 | db_cluster=$(ynh_app_setting_get --key=db_cluster)
33 | myynh_drop_psql_db
34 |
35 | ynh_nodejs_remove
36 |
37 | #=================================================
38 | # END OF SCRIPT
39 | #=================================================
40 |
41 | ynh_script_progression "Removal of $app completed"
42 |
--------------------------------------------------------------------------------
/scripts/change_url:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #=================================================
4 | # IMPORT GENERIC HELPERS
5 | #=================================================
6 |
7 | source _common.sh
8 | source /usr/share/yunohost/helpers
9 |
10 | #=================================================
11 | # STOP SYSTEMD SERVICE
12 | #=================================================
13 | ynh_script_progression "Stopping $app's systemd service..."
14 |
15 | ynh_systemctl --service="$app-machine-learning" --action="stop" --log_path="/var/log/$app/$app-machine-learning.log"
16 | ynh_systemctl --service="$app-server" --action="stop" --log_path="/var/log/$app/$app-server.log"
17 |
18 | #=================================================
19 | # MODIFY URL IN NGINX CONF
20 | #=================================================
21 | ynh_script_progression "Updating NGINX web server configuration..."
22 |
23 | # this will most likely adjust NGINX config correctly
24 | ynh_config_change_url_nginx
25 |
26 | #=================================================
27 | # START SYSTEMD SERVICE
28 | #=================================================
29 | ynh_script_progression "Starting $app's systemd service..."
30 |
31 | ynh_systemctl --service="$app-machine-learning" --action="start" --wait_until="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log" --timeout=900
32 | ynh_systemctl --service="$app-server" --action="start" --wait_until="Immich Server is listening" --log_path="/var/log/$app/$app-server.log" --timeout=900
33 |
34 | #=================================================
35 | # END OF SCRIPT
36 | #=================================================
37 |
38 | ynh_script_progression "Change of URL completed for $app"
39 |
--------------------------------------------------------------------------------
/conf/restore_immich_db_backup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | source /etc/yunohost/apps/immich/scripts/_common.sh
4 | YNH_HELPERS_VERSION="2.1" source /usr/share/yunohost/helpers
5 |
6 | YNH_STDINFO=1
7 | backup_files=( *.sql.gz )
8 |
9 | PS3="Select backup file to restore, or 0 to exit:"
10 | select backup_file in "${backup_files[@]}"
11 | do
12 | if [[ $REPLY == "0" ]]
13 | then
14 | ynh_print_info "[####################] Bye!"
15 | exit
16 | elif [[ -z $backup_file ]]; then
17 | ynh_print_info "[....................] Invalid choice, try again"
18 | else
19 | break
20 | fi
21 | done
22 |
23 | cat << EOF
24 |
25 | You select "$backup_file".
26 |
27 | To proceed we are going to:
28 | 1) stop immich
29 | 2) drop the curent database
30 | 3) restore the databse with the selected backup
31 | 4) restart immich
32 |
33 | EOF
34 |
35 | read -r -p "Are you sure you want to continue restoring? [y/N] " response
36 | if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
37 | then
38 | app="__APP__"
39 | db_cluster="__DB_CLUSTER__"
40 | db_name="__APP__"
41 |
42 | ynh_print_info "[+...................] Stopping immich..."
43 | ynh_systemctl --service="$app-server" --action="stop"
44 |
45 | ynh_print_info "[#+..................] Droping current immich db..."
46 | myynh_drop_psql_db 1>/dev/null
47 |
48 | ynh_print_info "[##+.................] Creating an empty immich db..."
49 | myynh_create_psql_db 1>/dev/null
50 | myynh_update_psql_db 1>/dev/null
51 |
52 | ynh_print_info "[###++++++++++++++++.] Restoring immich db backup... (Depending on your database size, this may take a long while)"
53 | {
54 | gunzip --stdout "$backup_file" > "db.sql"
55 | myynh_restore_psql_db
56 | ynh_safe_rm "db.sql"
57 | set +o xtrace
58 | } &>/dev/null
59 |
60 | ynh_print_info "[###################+] Restarting immich..."
61 | ynh_systemctl --service="$app-server" --action="start"
62 |
63 | ynh_print_info "[####################] Restoration of the immich db backup completed!"
64 | else
65 | ynh_print_info "[####################] Bye!"
66 | fi
67 |
--------------------------------------------------------------------------------
/scripts/backup:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #=================================================
4 | # IMPORT GENERIC HELPERS
5 | #=================================================
6 |
7 | # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
8 | source ../settings/scripts/_common.sh
9 | source /usr/share/yunohost/helpers
10 |
11 | ynh_print_info "Declaring files to be backed up..."
12 |
13 | #=================================================
14 | # BACKUP THE APP MAIN DIR
15 | #=================================================
16 |
17 | ynh_backup "$install_dir"
18 |
19 | #=================================================
20 | # BACKUP THE DATA DIR
21 | #=================================================
22 |
23 | ynh_backup "$data_dir"
24 |
25 | #=================================================
26 | # BACKUP SYSTEM CONFIGURATION
27 | #=================================================
28 |
29 | # Backup the NGINX configuration
30 | ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
31 |
32 | # Backup the systemd service unit
33 | ynh_backup "/etc/systemd/system/$app-server.service"
34 | ynh_backup "/etc/systemd/system/$app-machine-learning.service"
35 |
36 | # Backup the logrotate configuration
37 | ynh_backup "/etc/logrotate.d/$app"
38 |
39 | # Backup the Fail2Ban config
40 | ynh_backup "/etc/fail2ban/jail.d/$app.conf"
41 | ynh_backup "/etc/fail2ban/filter.d/$app.conf"
42 |
43 | #=================================================
44 | # BACKUP VARIOUS FILES
45 | #=================================================
46 | ynh_backup "/var/log/$app/"
47 |
48 | #=================================================
49 | # BACKUP THE POSTGRESQL DATABASE
50 | #=================================================
51 | ynh_print_info "Backing up a PostgreSQL database..."
52 |
53 | db_cluster=$(ynh_app_setting_get --key=db_cluster)
54 |
55 | myynh_update_psql_db
56 | myynh_dump_psql_db
57 |
58 | #=================================================
59 | # END OF SCRIPT
60 | #=================================================
61 |
62 | ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
63 |
--------------------------------------------------------------------------------
/conf/immich-machine-learning.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Immich machine-learning
3 | Documentation=https://github.com/immich-app/immich
4 | After=network.target
5 | PartOf=__APP__-server.service
6 | Before=__APP__-server.service
7 |
8 | [Service]
9 | Type=simple
10 | Restart=on-failure
11 | User=__APP__
12 | Group=__APP__
13 | WorkingDirectory=__INSTALL_DIR__/immich/app
14 | EnvironmentFile=__INSTALL_DIR__/immich/env
15 | ExecStart=__INSTALL_DIR__/immich/app/machine-learning/ml_start.sh
16 | SyslogIdentifier=immich-machine-learning
17 | StandardOutput=append:/var/log/__APP__/__APP__-machine-learning.log
18 | StandardError=append:/var/log/__APP__/__APP__-machine-learning.log
19 | Restart=on-failure
20 | UMask=0077
21 |
22 | # Sandboxing options to harden security
23 | # Depending on specificities of your service/app, you may need to tweak these
24 | # .. but this should be a good baseline
25 | # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
26 | NoNewPrivileges=yes
27 | PrivateTmp=yes
28 | PrivateDevices=yes
29 | RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
30 | RestrictNamespaces=yes
31 | RestrictRealtime=yes
32 | DevicePolicy=closed
33 | ProtectSystem=full
34 | ProtectControlGroups=yes
35 | ProtectKernelModules=yes
36 | ProtectKernelTunables=yes
37 | LockPersonality=yes
38 | SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
39 |
40 | # Denying access to capabilities that should not be relevant for webapps
41 | # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
42 | CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
43 | CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
44 | CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
45 | CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
46 | CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
47 | CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
48 | CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
49 | CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
50 | CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
51 |
52 | [Install]
53 | WantedBy=immich-server.service
54 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 | Immich, packaged for YunoHost
9 |
10 |
11 | Photo and video backup solution directly from your mobile phone
12 |
13 | [](https://immich.app)
14 | [](https://demo.immich.app)
15 | [?style=for-the-badge)](https://ci-apps.yunohost.org/ci/apps/immich/)
16 |
17 |
18 |

19 |

20 |
21 |
22 |
23 | ## Screenshots
24 | 
25 |
26 | ## 📦 Developer info
27 |
28 | [](https://ci-apps.yunohost.org/ci/apps/immich/)
29 |
30 | 🛠️ Upstream Immich repository:
31 |
32 | Pull request are welcome and should target the [`testing` branch](https://github.com/YunoHost-Apps/immich_ynh/tree/testing).
33 |
34 | The `testing` branch can be tested using:
35 | ```
36 | # fresh install:
37 | sudo yunohost app install https://github.com/YunoHost-Apps/immich_ynh/tree/testing
38 |
39 | # upgrade an existing install:
40 | sudo yunohost app upgrade immich -u https://github.com/YunoHost-Apps/immich_ynh/tree/testing
41 | ```
42 |
43 | ### 📚 App packaging documentation
44 |
45 | Please see for more information.
--------------------------------------------------------------------------------
/conf/immich-server.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Immich server
3 | Documentation=https://github.com/immich-app/immich
4 | Requires=redis-server.service
5 | Requires=postgresql.service
6 | Requires=__APP__-machine-learning.service
7 | After=network.target
8 |
9 | [Service]
10 | Type=simple
11 | Restart=on-failure
12 | User=__APP__
13 | Group=__APP__
14 | WorkingDirectory=__INSTALL_DIR__/immich/app
15 | Environment="PATH=/usr/lib/jellyfin-ffmpeg/:__PATH_WITH_NODEJS__"
16 | EnvironmentFile=__INSTALL_DIR__/immich/env
17 | ExecStart=__NODEJS_DIR__/node __INSTALL_DIR__/immich/app/dist/main
18 | SyslogIdentifier=immich-server
19 | StandardOutput=append:/var/log/__APP__/__APP__-server.log
20 | StandardError=append:/var/log/__APP__/__APP__-server.log
21 | Restart=on-failure
22 | UMask=0077
23 |
24 | # Sandboxing options to harden security
25 | # Depending on specificities of your service/app, you may need to tweak these
26 | # .. but this should be a good baseline
27 | # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
28 | NoNewPrivileges=yes
29 | PrivateTmp=yes
30 | PrivateDevices=no
31 | RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
32 | RestrictNamespaces=yes
33 | RestrictRealtime=yes
34 | DevicePolicy=auto
35 | ProtectSystem=full
36 | ProtectControlGroups=yes
37 | ProtectKernelModules=yes
38 | ProtectKernelTunables=yes
39 | LockPersonality=yes
40 | SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
41 |
42 | # Denying access to capabilities that should not be relevant for webapps
43 | # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
44 | CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
45 | CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
46 | CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
47 | CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
48 | CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
49 | CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
50 | CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
51 | CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
52 | CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
53 |
54 | [Install]
55 | WantedBy=multi-user.target
56 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
4 |
5 | ---
6 |
7 | **How to post a meaningful bug report**
8 | 1. *Read this whole template first.*
9 | 2. *Determine if you are on the right place:*
10 | - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
11 | - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
12 | - *When in doubt, post here and we will figure it out together.*
13 | 3. *Delete the italic comments as you write over them below, and remove this guide.*
14 | ---
15 |
16 | ### Describe the bug
17 |
18 | *A clear and concise description of what the bug is.*
19 |
20 | ### Context
21 |
22 | - Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
23 | - YunoHost version: x.x.x
24 | - I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
25 | - Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
26 | - If yes, please explain:
27 | - Using, or trying to install package version/branch:
28 | - If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
29 |
30 | ### Steps to reproduce
31 |
32 | - *If you performed a command from the CLI, the command itself is enough. For example:*
33 | ```sh
34 | sudo yunohost app install the_app
35 | ```
36 | - *If you used the webadmin, please perform the equivalent command from the CLI first.*
37 | - *If the error occurs in your browser, explain what you did:*
38 | 1. *Go to '...'*
39 | 2. *Click on '...'*
40 | 3. *Scroll down to '...'*
41 | 4. *See error*
42 |
43 | ### Expected behavior
44 |
45 | *A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
46 |
47 | ### Logs
48 |
49 | *When an operation fails, YunoHost provides a simple way to share the logs.*
50 | - *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
51 | - *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
52 |
53 | *After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
54 |
55 | *If applicable and useful, add screenshots to help explain your problem.*
56 |
--------------------------------------------------------------------------------
/manifest.toml:
--------------------------------------------------------------------------------
1 | #:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
2 |
3 | packaging_format = 2
4 |
5 | id = "immich"
6 | name = "Immich"
7 | description.en = "Photo and video backup solution directly from your mobile phone"
8 | description.fr = "Sauvegarde de photos et de vidéos directement depuis votre mobile"
9 |
10 | version = "2.4.1~ynh1"
11 |
12 | maintainers = ["ewilly"]
13 |
14 | [upstream]
15 | license = "AGPL-3.0-or-later"
16 | website = "https://immich.app"
17 | demo = "https://demo.immich.app"
18 | admindoc = "https://github.com/immich-app/immich#getting-started"
19 | userdoc = "https://github.com/immich-app/immich#getting-started"
20 | code = "https://github.com/immich-app/immich"
21 |
22 | [integration]
23 | yunohost = ">= 12.1.23"
24 | helpers_version = "2.1"
25 | architectures = ["arm64", "amd64"]
26 | multi_instance = false
27 |
28 | ldap = false
29 | sso = false
30 |
31 | disk = "2G"
32 | ram.build = "4G"
33 | ram.runtime = "2G"
34 |
35 | [install]
36 | [install.domain]
37 | type = "domain"
38 |
39 | [install.init_main_permission]
40 | type = "group"
41 | default = "visitors"
42 |
43 | [resources]
44 | [resources.sources]
45 |
46 | [resources.sources.main]
47 | url = "https://github.com/immich-app/immich/archive/refs/tags/v2.4.1.tar.gz"
48 | sha256 = "885cf36509f79fa1ed7541236b671d7eae900c80145920299be922a45a086fc5"
49 |
50 | autoupdate.strategy = "latest_github_release"
51 |
52 | [resources.sources.libheif]
53 | # Version from https://github.com/immich-app/base-images/blob/main/server/sources/libheif.json
54 | url = "https://github.com/strukturag/libheif/releases/download/v1.20.2/libheif-1.20.2.tar.gz"
55 | sha256 = "68ac9084243004e0ef3633f184eeae85d615fe7e4444373a0a21cebccae9d12a"
56 |
57 | [resources.sources.libvips]
58 | # Version from https://github.com/immich-app/base-images/blob/main/server/sources/libvips.json
59 | url = "https://github.com/libvips/libvips/releases/download/v8.17.3/vips-8.17.3.tar.xz"
60 | sha256 = "41e9a1439cd57dcc6d4435a085e2cfe181d9da1962fa84a484f09e8b536e4b77"
61 |
62 | [resources.system_user]
63 |
64 | [resources.install_dir]
65 |
66 | [resources.data_dir]
67 |
68 | [resources.permissions]
69 | main.url = "/"
70 | api.url = "/api"
71 | api.allowed = "visitors"
72 | api.show_tile = false
73 | api.protected = true
74 |
75 | [resources.ports]
76 | main.default = 2283
77 | machinelearning.default = 3003
78 |
79 | [resources.apt]
80 | packages = [
81 | "pipx",
82 | "curl",
83 | "postgresql",
84 | "redis-server",
85 | "python3",
86 | "python3-dev",
87 | "libssl-dev",
88 | "libffi-dev",
89 | "uuid-runtime",
90 | "autoconf",
91 | "build-essential",
92 | "unzip",
93 | "jq",
94 | "perl",
95 | "libnet-ssleay-perl",
96 | "libio-socket-ssl-perl",
97 | "libcapture-tiny-perl",
98 | "libfile-which-perl",
99 | "libfile-chdir-perl",
100 | "libpkgconfig-perl",
101 | "libffi-checklib-perl",
102 | "libtest-warnings-perl",
103 | "libtest-fatal-perl",
104 | "libtest-needs-perl",
105 | "libtest2-suite-perl",
106 | "libsort-versions-perl",
107 | "libpath-tiny-perl",
108 | "libtry-tiny-perl",
109 | "libterm-table-perl",
110 | "libany-uri-escape-perl",
111 | "libmojolicious-perl",
112 | "libfile-slurper-perl",
113 | "liblcms2-2",
114 | "wget",
115 | "yq",
116 | "ccache",
117 | "libgl1",
118 | "cmake",
119 | "meson",
120 | "ninja-build",
121 | "pkg-config",
122 | "libdav1d-dev",
123 | "libwebp-dev",
124 | "libaom-dev",
125 | "libde265-dev",
126 | "libexpat1-dev",
127 | "libglib2.0-dev",
128 | "libjpeg-dev",
129 | "libpng-dev",
130 | "libgif-dev",
131 | "libimagequant-dev",
132 | "libcgif-dev"
133 | ]
134 | packages_from_raw_bash = """
135 | if [[ $YNH_DEBIAN_VERSION == "trixie" ]]; then
136 | echo "postgresql-17-pgvector";
137 | fi
138 | """
139 |
140 | [resources.apt.extras.jellyfin-ffmpeg]
141 | repo = "deb https://repo.jellyfin.org/debian __YNH_DEBIAN_VERSION__ main"
142 | key = "https://repo.jellyfin.org/jellyfin_team.gpg.key"
143 | packages = [
144 | "jellyfin-ffmpeg7"
145 | ]
146 |
147 | [resources.apt.extras.mise]
148 | repo = "deb https://mise.jdx.dev/deb stable main"
149 | key = "https://mise.jdx.dev/gpg-key.pub"
150 | packages = [
151 | "mise"
152 | ]
153 |
154 | [resources.database]
155 | type = "postgresql"
156 |
--------------------------------------------------------------------------------
/scripts/restore:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #=================================================
4 | # IMPORT GENERIC HELPERS
5 | #=================================================
6 |
7 | # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
8 | source ../settings/scripts/_common.sh
9 | source /usr/share/yunohost/helpers
10 |
11 | #=================================================
12 | # CHECK HARDWARE REQUIREMENTS
13 | #=================================================
14 | ynh_script_progression "Checking hardware requirements..."
15 |
16 | myynh_check_hardware
17 |
18 | #=================================================
19 | # RESTORE THE APP MAIN DIR
20 | #=================================================
21 | ynh_script_progression "Restoring the app main directory..."
22 |
23 | ynh_restore "$install_dir"
24 |
25 | #=================================================
26 | # RESTORE THE DATA DIRECTORY
27 | #=================================================
28 | ynh_script_progression "Restoring the data directory..."
29 |
30 | ynh_restore "$data_dir"
31 |
32 | #=================================================
33 | # INSTALL NODEJS
34 | #=================================================
35 | ynh_script_progression "Reinstalling nodejs..."
36 |
37 | nodejs_version=$(ynh_app_setting_get --key=nodejs_version)
38 | ynh_nodejs_install
39 |
40 | #=================================================
41 | # INSTALL PACKAGES
42 | #=================================================
43 | ynh_script_progression "Installing additionnal packages (if needed)..."
44 |
45 | myynh_install_postgresql_packages
46 |
47 | #=================================================
48 | # RESTORE THE DATABASE
49 | #=================================================
50 | ynh_script_progression "Restoring the database..."
51 |
52 | db_cluster=$(ynh_app_setting_get --key=db_cluster)
53 |
54 | if [[ $YNH_DEBIAN_VERSION == "bookworm" ]]
55 | then
56 | myynh_create_psql_cluster
57 | myynh_create_psql_db
58 | myynh_set_default_psql_cluster_to_debian_default
59 | fi
60 |
61 | myynh_restore_psql_db
62 | myynh_update_psql_db
63 |
64 | #=================================================
65 | # RESTORE SYSTEM CONFIGURATION
66 | #=================================================
67 | ynh_script_progression "Restoring system configurations related to $app..."
68 |
69 | ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
70 |
71 | ynh_restore "/etc/systemd/system/$app-server.service"
72 | ynh_restore "/etc/systemd/system/$app-machine-learning.service"
73 |
74 | systemctl enable "$app-server.service" --quiet
75 | systemctl enable "$app-machine-learning.service" --quiet
76 |
77 | yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log"
78 | yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log"
79 |
80 | ynh_multimedia_build_main_dir
81 | ynh_multimedia_addaccess "$app"
82 |
83 | ynh_restore "/etc/logrotate.d/$app"
84 |
85 | ynh_restore "/etc/fail2ban/jail.d/$app.conf"
86 | ynh_restore "/etc/fail2ban/filter.d/$app.conf"
87 | ynh_systemctl --service="fail2ban" --action="restart"
88 |
89 | #=================================================
90 | # RESTORE VARIOUS FILES
91 | #=================================================
92 |
93 | ynh_restore "/var/log/$app/"
94 |
95 | #=================================================
96 | # UPDATE A CONFIG FILE
97 | #=================================================
98 | ynh_script_progression "Updating $app's configuration files..."
99 |
100 | # In case the psql port is not the same between old system vs new system, apply the new port in env file
101 | ynh_replace --match="DB_PORT=.*" --replace="DB_PORT=$db_port" --file="$install_dir/immich/env"
102 |
103 | #=================================================
104 | # SET FILE OWNERSHIP / PERMISSIONS
105 | #=================================================
106 |
107 | myynh_set_permissions
108 |
109 | #=================================================
110 | # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
111 | #=================================================
112 | ynh_script_progression "Reloading NGINX web server and $app's service..."
113 |
114 | ynh_systemctl --service="$app-machine-learning" --action="start" --wait_until="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log"
115 | ynh_systemctl --service="$app-server" --action="start" --wait_until="Immich Server is listening" --log_path="/var/log/$app/$app-server.log" --timeout=900
116 |
117 | ynh_systemctl --service="nginx" --action="reload"
118 |
119 | #=================================================
120 | # END OF SCRIPT
121 | #=================================================
122 |
123 | ynh_script_progression "Restoration completed for $app"
124 |
--------------------------------------------------------------------------------
/scripts/install:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #=================================================
4 | # IMPORT GENERIC HELPERS
5 | #=================================================
6 |
7 | source _common.sh
8 | source /usr/share/yunohost/helpers
9 |
10 | #=================================================
11 | # CHECK HARDWARE REQUIREMENTS
12 | #=================================================
13 | ynh_script_progression "Checking hardware requirements..."
14 |
15 | myynh_check_hardware
16 |
17 | #=================================================
18 | # INITIALIZE AND STORE SETTINGS
19 | #=================================================
20 |
21 | #=================================================
22 | # DOWNLOAD, CHECK AND UNPACK SOURCE
23 | #=================================================
24 | ynh_script_progression "Setting up source files..."
25 |
26 | source_dir="$install_dir/source"
27 | ynh_setup_source --source_id="main" --dest_dir="$source_dir"
28 |
29 | #=================================================
30 | # INSTALL NODEJS
31 | #=================================================
32 | ynh_script_progression "Installing nodejs..."
33 |
34 | nodejs_version=$(cat "$source_dir/server/.nvmrc" | cut -d '.' -f1) # 22
35 | ynh_nodejs_install
36 |
37 | #=================================================
38 | # INSTALL PACKAGES
39 | #=================================================
40 | ynh_script_progression "Installing additionnal packages (if needed)..."
41 |
42 | myynh_install_postgresql_packages
43 |
44 | #=================================================
45 | # CREATE A POSTGRESQL DATABASE
46 | #=================================================
47 | ynh_script_progression "Creating a PostgreSQL database (if needed)..."
48 |
49 | if [[ $YNH_DEBIAN_VERSION == "bookworm" ]]
50 | then
51 | myynh_create_psql_cluster
52 | myynh_create_psql_db
53 | myynh_set_default_psql_cluster_to_debian_default
54 | fi
55 |
56 | myynh_update_psql_db
57 |
58 | #=================================================
59 | # ADD SWAP IF NEEDED
60 | #=================================================
61 | ynh_script_progression "Temporary adding additional swap if needed..."
62 |
63 | myynh_add_swap
64 |
65 | #=================================================
66 | # MAKE INSTALL
67 | #=================================================
68 | ynh_script_progression "Making install..."
69 |
70 | myynh_install_immich
71 |
72 | #=================================================
73 | # REMOVE TEMPORARY SWAP IF ADDED
74 | #=================================================
75 | ynh_script_progression "Remove temporary swap if added..."
76 |
77 | ynh_del_swap_fixed
78 |
79 | #=================================================
80 | # APP INITIAL CONFIGURATION
81 | #=================================================
82 | ynh_script_progression "Adding $app's configuration files..."
83 |
84 | ynh_config_add --template="env" --destination="$install_dir/immich/env"
85 | mkdir --parents "$data_dir/backups"
86 | ynh_config_add --template="restore_immich_db_backup.sh" --destination="$data_dir/backups/restore_immich_db_backup.sh"
87 |
88 | #=================================================
89 | # SYSTEM CONFIGURATION
90 | #=================================================
91 | ynh_script_progression "Adding system configurations related to $app..."
92 |
93 | ynh_config_add_nginx
94 |
95 | ynh_config_add_systemd --service="$app-server" --template="$app-server.service"
96 | ynh_config_add_systemd --service="$app-machine-learning" --template="$app-machine-learning.service"
97 |
98 | yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log"
99 | yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log"
100 |
101 | ynh_multimedia_build_main_dir
102 | ynh_multimedia_addaccess "$app"
103 |
104 | # Use logrotate to manage application logfile(s)
105 | ynh_config_add_logrotate
106 |
107 | # Create a dedicated Fail2Ban config
108 | ynh_config_add_fail2ban --logpath="/var/log/$app/$app-server.log" --failregex="$failregex"
109 |
110 | #=================================================
111 | # SET FILE OWNERSHIP / PERMISSIONS
112 | #=================================================
113 |
114 | myynh_set_permissions
115 |
116 | #=================================================
117 | # START SYSTEMD SERVICE
118 | #=================================================
119 | ynh_script_progression "Starting $app's systemd service..."
120 |
121 | ynh_systemctl --service="$app-machine-learning" --action="start" --wait_until="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log"
122 | ynh_systemctl --service="$app-server" --action="start" --wait_until="Immich Server is listening" --log_path="/var/log/$app/$app-server.log" --timeout=900
123 |
124 | #=================================================
125 | # END OF SCRIPT
126 | #=================================================
127 |
128 | ynh_script_progression "Installation of $app completed"
129 |
--------------------------------------------------------------------------------
/scripts/upgrade:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #=================================================
4 | # IMPORT GENERIC HELPERS
5 | #=================================================
6 |
7 | source _common.sh
8 | source /usr/share/yunohost/helpers
9 |
10 | #=================================================
11 | # CHECK HARDWARE REQUIREMENTS
12 | #=================================================
13 | ynh_script_progression "Checking hardware requirements..."
14 |
15 | myynh_check_hardware
16 |
17 | #=================================================
18 | # STOP SYSTEMD SERVICE
19 | #=================================================
20 | ynh_script_progression "Stopping $app's systemd service..."
21 |
22 | ynh_systemctl --service="$app-server" --action="stop"
23 |
24 | #=================================================
25 | # ENSURE DOWNWARD COMPATIBILITY
26 | #=================================================
27 | ynh_script_progression "Ensuring downward compatibility..."
28 |
29 | if ynh_app_upgrading_from_version_before 1.118.2~ynh1
30 | then
31 | if ynh_hide_warnings yunohost service status "$app-microservices" >/dev/null
32 | then
33 | yunohost service remove "$app-microservices"
34 | fi
35 | ynh_config_remove_systemd "$app-microservices"
36 | find "/var/log/$app/" -name "$app-microservices.log*" -delete
37 | ynh_app_setting_delete --key="port_microservices"
38 | ynh_app_setting_delete --key="checksum__var_www_immich_env-machine-learning"
39 | ynh_app_setting_delete --key="checksum__var_www_immich_env-server"
40 | ynh_app_setting_delete --key="checksum__etc_systemd_system_immich-microservices.service"
41 | fi
42 | if ynh_app_upgrading_from_version_before 1.132.0~ynh1
43 | then
44 | ynh_die "This update requires applications to have started up at least once on 1.132.0+. \
45 | \nPlease first manually update with 1.136.0~ynh1 with the following command: \
46 | \n's\0u\0d\0o yunohost app upgrade immich -u https://github.com/YunoHost-Apps/immich_ynh/tree/d70256707e598e5817b600036a742da65939746a' \
47 | \nOnce done you can upgrade to the latest version."
48 | fi
49 | if ynh_app_upgrading_from_version_before 1.142.0~ynh2
50 | then
51 | ynh_app_setting_delete --key=python
52 | ynh_app_setting_set --key=db_cluster --value="$(ynh_app_setting_get --key=psql_version)/main"
53 | ynh_app_setting_delete --key=psql_version
54 | ynh_app_setting_delete --key=psql_port
55 | ynh_app_setting_set --key=db_pwd --value="$(ynh_app_setting_get --key=psql_pwd)"
56 | ynh_app_setting_delete --key=psql_pwd
57 | fi
58 | if ynh_app_upgrading_from_version_before 2.3.1~ynh4
59 | then
60 | ynh_safe_rm "$install_dir"
61 | fi
62 |
63 | #=================================================
64 | # DOWNLOAD, CHECK AND UNPACK SOURCE
65 | #=================================================
66 | ynh_script_progression "Upgrading source files..."
67 |
68 | ynh_safe_rm "$install_dir/immich"
69 |
70 | source_dir="$install_dir/source"
71 | ynh_setup_source --source_id="main" --dest_dir="$source_dir" --full_replace
72 |
73 | #=================================================
74 | # INSTALL NODEJS
75 | #=================================================
76 | ynh_script_progression "Installing nodejs..."
77 |
78 | nodejs_version=$(cat "$source_dir/server/.nvmrc" | cut -d '.' -f1) # 22
79 | ynh_nodejs_install
80 |
81 | #=================================================
82 | # INSTALL PACKAGES
83 | #=================================================
84 | ynh_script_progression "Installing additionnal packages (if needed)..."
85 |
86 | myynh_install_postgresql_packages
87 |
88 | #=================================================
89 | # UPDATE A POSTGRESQL DATABASE
90 | #=================================================
91 | ynh_script_progression "Updating a PostgreSQL database..."
92 |
93 | if [[ $YNH_DEBIAN_VERSION == "bookworm" ]]
94 | then
95 | myynh_set_default_psql_cluster_to_debian_default
96 | elif [[ $YNH_DEBIAN_VERSION == "trixie" ]]
97 | then
98 | # Check if the db is not yet on trixie cluster and if no migrate it (aka dumb and restore the db to 17 + delete the db on 16)
99 | if [[ $(ynh_app_setting_get --key=db_cluster) != "$psql_trixie/main" ]]
100 | then
101 | # Dump db on old cluster
102 | myynh_dump_psql_db --cluster="$psql_bookworm/main"
103 | # Drop empty db on new cluster
104 | myynh_drop_psql_db --cluster="$psql_trixie/main"
105 | # Restore db on new cluster
106 | myynh_restore_psql_db --cluster="$psql_trixie/main"
107 | # Drop db on old cluster
108 | myynh_drop_psql_db --cluster="$psql_bookworm/main"
109 | fi
110 | fi
111 |
112 | myynh_update_psql_db
113 |
114 | #=================================================
115 | # ADD SWAP IF NEEDED
116 | #=================================================
117 | ynh_script_progression "Temporary adding additional swap if needed..."
118 |
119 | myynh_add_swap
120 |
121 | #=================================================
122 | # MAKE INSTALL
123 | #=================================================
124 | ynh_script_progression "Making install..."
125 |
126 | myynh_install_immich
127 |
128 | #=================================================
129 | # REMOVE TEMPORARY SWAP IF ADDED
130 | #=================================================
131 | ynh_script_progression "Remove temporary swap if added..."
132 |
133 | ynh_del_swap_fixed
134 |
135 | #=================================================
136 | # UPDATE A CONFIG FILE
137 | #=================================================
138 | ynh_script_progression "Updating $app's configuration files..."
139 |
140 | db_pwd=$(ynh_app_setting_get --key=db_pwd)
141 | db_port=$(ynh_app_setting_get --key=db_port)
142 | ynh_config_add --template="env" --destination="$install_dir/immich/env"
143 | mkdir --parents "$data_dir/backups"
144 | ynh_config_add --template="restore_immich_db_backup.sh" --destination="$data_dir/backups/restore_immich_db_backup.sh"
145 |
146 | #=================================================
147 | # REAPPLY SYSTEM CONFIGURATION
148 | #=================================================
149 | ynh_script_progression "Upgrading system configurations related to $app..."
150 |
151 | ynh_config_add_nginx
152 |
153 | ynh_config_add_systemd --service="$app-server" --template="$app-server.service"
154 | ynh_config_add_systemd --service="$app-machine-learning" --template="$app-machine-learning.service"
155 |
156 | yunohost service add "$app-server" --description="Immich Server" --log="/var/log/$app/$app-server.log"
157 | yunohost service add "$app-machine-learning" --description="Immich Machine Learning" --log="/var/log/$app/$app-machine-learning.log"
158 |
159 | ynh_multimedia_build_main_dir
160 | ynh_multimedia_addaccess "$app"
161 |
162 | ynh_config_add_logrotate
163 |
164 | ynh_config_add_fail2ban --logpath="/var/log/$app/$app-server.log" --failregex="$failregex"
165 |
166 | #=================================================
167 | # SET FILE OWNERSHIP / PERMISSIONS
168 | #=================================================
169 |
170 | myynh_set_permissions
171 |
172 | #=================================================
173 | # START SYSTEMD SERVICE
174 | #=================================================
175 | ynh_script_progression "Starting $app's systemd service..."
176 |
177 | ynh_systemctl --service="$app-machine-learning" --action="start" --wait_until="Application startup complete" --log_path="/var/log/$app/$app-machine-learning.log"
178 | ynh_systemctl --service="$app-server" --action="start" --wait_until="Immich Server is listening" --log_path="/var/log/$app/$app-server.log" --timeout=900
179 |
180 | #=================================================
181 | # END OF SCRIPT
182 | #=================================================
183 |
184 | ynh_script_progression "Upgrade of $app completed"
185 |
--------------------------------------------------------------------------------
/scripts/_common.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #=================================================
4 | # COMMON VARIABLES AND CUSTOM HELPERS
5 | #=================================================
6 |
7 | # Postgresql version
8 | psql_bookworm=16
9 | psql_trixie=17
10 | if [[ $YNH_DEBIAN_VERSION == "bookworm" ]]
11 | then
12 | psql_version=$psql_bookworm
13 | elif [[ $YNH_DEBIAN_VERSION == "trixie" ]]
14 | then
15 | psql_version=$psql_trixie
16 | fi
17 |
18 | # Fail2ban
19 | failregex="$app-server.*Failed login attempt for user.+from ip address\s?"
20 |
21 | # Check hardware requirements
22 | myynh_check_hardware() {
23 | # CPU: Prebuilt binaries for linux-x64 require v2 microarchitecture
24 | local file_test="/lib64/ld-linux-x86-64.so.2"
25 | if [ -f "$file_test" ]
26 | then
27 | if [ -z "$( $file_test --help | grep 'x86-64-v2 (supported' )" ]
28 | then
29 | ynh_die "Your CPU is too old and not supported. Installation of $app is not possible on your system."
30 | fi
31 | fi
32 | }
33 |
34 | # Add postgresql packages from postgresql repo if needed
35 | myynh_install_postgresql_packages() {
36 | if [[ $YNH_DEBIAN_VERSION == "bookworm" ]]
37 | then
38 | ynh_apt_install_dependencies_from_extra_repository \
39 | --repo="deb https://apt.postgresql.org/pub/repos/apt $YNH_DEBIAN_VERSION-pgdg main $psql_version" \
40 | --key="https://www.postgresql.org/media/keys/ACCC4CF8.asc" \
41 | --package="libpq5 libpq-dev postgresql-$psql_version postgresql-$psql_version-pgvector postgresql-client-$psql_version"
42 | db_cluster="$psql_version/main"
43 | elif [[ $YNH_DEBIAN_VERSION == "trixie" ]]
44 | then
45 | YNH_APT_INSTALL_DEPENDENCIES_REPLACE="false" ynh_apt_install_dependencies "postgresql-$psql_version-pgvector"
46 | db_cluster="$psql_version/main"
47 | fi
48 | ynh_app_setting_set --key=db_cluster --value="$db_cluster"
49 | }
50 |
51 | # Add swap if needed
52 | myynh_add_swap() {
53 | # Remove existing SWAP
54 | ynh_del_swap_fixed
55 | # Retrieve RAM needed in G
56 | local ram_needed_full=$(ynh_read_manifest "integration.ram.build")
57 | local ram_needed_value=${ram_needed_full::-1}
58 | local ram_needed_unit=${ram_needed_full: -1}
59 | if [ $ram_needed_unit = "M" ]
60 | then
61 | ram_needed_G=$(($ram_needed_value/1024))
62 | else
63 | ram_needed_G=$(($ram_needed_value))
64 | fi
65 | # Retrieve free RAM in G
66 | local ram_free_G=$(($(ynh_get_ram --free)/1024))
67 | # Check and add right amount of SWAP if needed
68 | local swap_needed_M=0
69 | if [ $ram_free_G -lt $ram_needed_G ]
70 | then
71 | swap_needed_M=$((($ram_needed_G-$ram_free_G)*1024))
72 | fi
73 | if [ $swap_needed_M -gt 0 ]
74 | then
75 | ynh_print_info "Adding $swap_needed_M Mb to swap..."
76 | ynh_add_swap_fixed --size=$swap_needed_M
77 | fi
78 | # Recheck free RAM in G
79 | local ram_free_G=$(($(ynh_get_ram --free)/1024))
80 | if [ $ram_free_G -lt $ram_needed_G ]
81 | then
82 | # Remove existing SWAP
83 | ynh_del_swap_fixed
84 | # Terminate install/upgarde script
85 | ynh_die "There is no enough free memory on your system ($ram_needed_G GB are needed to build successfully $app). You need to either add RAM or manually add swap to your system."
86 | fi
87 | }
88 |
89 | # Install libheif and libvips from source for HEIC support
90 | # Based on https://github.com/community-scripts/ProxmoxVE/blob/main/install/immich-install.sh
91 | # and https://github.com/immich-app/base-images/blob/main/server/Dockerfile
92 | myynh_install_libvips() {
93 | local build_dir="$source_dir/vips-build"
94 | local libs_dir="$install_dir/vips"
95 | ynh_safe_rm "$libs_dir"
96 | mkdir -p "$build_dir" "$libs_dir" "$build_dir/libheif"
97 | pushd "$build_dir"
98 |
99 | # Build libheif
100 | ynh_print_info "Building libheif for HEIC support..."
101 | ynh_setup_source --source_id="libheif" --dest_dir="$build_dir/libheif"
102 | pushd libheif
103 | mkdir -p build
104 | cd build
105 | ynh_hide_warnings cmake --preset=release-noplugins \
106 | -DCMAKE_INSTALL_PREFIX="$libs_dir" \
107 | -DWITH_DAV1D=ON \
108 | -DENABLE_PARALLEL_TILE_DECODING=ON \
109 | -DWITH_LIBSHARPYUV=ON \
110 | -DWITH_LIBDE265=ON \
111 | -DWITH_AOM_DECODER=OFF \
112 | -DWITH_AOM_ENCODER=ON \
113 | -DWITH_X265=OFF \
114 | -DWITH_EXAMPLES=OFF \
115 | ..
116 | ynh_hide_warnings make -j "$(nproc)"
117 | ynh_hide_warnings make install
118 | popd
119 |
120 | # Build libvips
121 | ynh_print_info "Building libvips with HEIC support..."
122 | export PKG_CONFIG_PATH="$libs_dir/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
123 | export LD_LIBRARY_PATH="$libs_dir/lib:${LD_LIBRARY_PATH:-}"
124 | ynh_setup_source --source_id="libvips" --dest_dir="$build_dir/libvips"
125 | pushd libvips
126 | ynh_hide_warnings meson setup build --buildtype=release \
127 | --prefix="$libs_dir" \
128 | --libdir=lib \
129 | -Dintrospection=disabled \
130 | -Dtiff=disabled
131 | cd build
132 | ynh_hide_warnings ninja install
133 | popd
134 |
135 | # Return to original directory
136 | popd
137 |
138 | # Save versions in settings
139 | ynh_app_setting_set --key=libheif_version --value=$(ynh_read_manifest "resources.sources.libheif.url")
140 | ynh_app_setting_set --key=libvips_version --value=$(ynh_read_manifest "resources.sources.libvips.url")
141 |
142 | # Cleanup
143 | ynh_print_info "Cleaning up libvips build directory..."
144 | ynh_safe_rm "$build_dir"
145 | }
146 |
147 | # Install immich
148 | myynh_install_immich() {
149 | # Thanks to https://github.com/arter97/immich-native, https://github.com/community-scripts/ProxmoxVE/blob/main/install/immich-install.sh, https://github.com/loeeeee/immich-in-lxc/blob/main/install.sh
150 | # Check https://github.com/immich-app/base-images/blob/main/server/Dockerfile for changes
151 |
152 | # Add jellyfin-ffmpeg direcotry to $PATH
153 | PATH="/usr/lib/jellyfin-ffmpeg/:$PATH"
154 |
155 | # Build libvips with HEIC support
156 | if [[ $(ynh_read_manifest "resources.sources.libheif.url") != $(ynh_app_setting_get --key=libheif_version) \
157 | || $(ynh_read_manifest "resources.sources.libvips.url") != $(ynh_app_setting_get --key=libvips_version) ]]
158 | then
159 | myynh_install_libvips
160 | else
161 | ynh_print_info "Current libheif and libvips are up-to-date for HEIC support, no need to rebuild them..."
162 | fi
163 | export LD_LIBRARY_PATH="$install_dir/vips/lib:${LD_LIBRARY_PATH:-}"
164 |
165 | # Define nodejs options
166 | ram_G=$((($(ynh_get_ram --free) - (1024/2))/1024))
167 | ram_G=$(($ram_G > 1 ? $ram_G : 1))
168 | ram_G=$(($ram_G > 8 ? 8 : $ram_G))
169 | ram_G=$(($ram_G*1024))
170 | export NODE_OPTIONS="${NODE_OPTIONS:-} --max_old_space_size=$ram_G"
171 | export NODE_ENV=production
172 |
173 | # Install pnpm
174 | ynh_hide_warnings npm install --global corepack@latest
175 | export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
176 | export CI=1
177 | pnpm_version=$(cat "$source_dir/package.json" \
178 | | jq -r '.packageManager | split("@")[1] | split(".")[0]') #10
179 | ynh_hide_warnings corepack enable pnpm
180 | ynh_hide_warnings corepack use pnpm@latest-$pnpm_version
181 |
182 | # Print versions
183 | echo "node version: $(node -v)"
184 | echo "npm version: $(npm -v)"
185 | echo "pnpm version: $(pnpm -v)"
186 |
187 | # Install immich-server
188 | # Replace /usr/src
189 | cd "$source_dir"
190 | grep -Rl "/usr/src" | xargs -n1 sed -i -e "s@/usr/src@$install_dir/immich@g"
191 | # Replace /build
192 | grep -RlE "\"/build\"|'/build'" \
193 | | xargs -n1 sed -i -e "s@\"/build\"@\"$install_dir/immich/app\"@g" -e "s@'/build'@'$install_dir/immich/app'@g"
194 | # Definie pnpm & mise options
195 | export PNPM_HOME="$source_dir/pnpm"
196 | export MISE_DATA_DIR="$source_dir/mise"
197 | export MISE_CACHE_DIR="$MISE_DATA_DIR/cache"
198 | # Build server
199 | ynh_print_info "Building immich server..."
200 | cd "$source_dir/server"
201 | ynh_hide_warnings pnpm --filter immich --frozen-lockfile build
202 | ynh_hide_warnings pnpm --filter immich --frozen-lockfile --prod deploy "$install_dir/immich/app/"
203 |
204 | cp "$install_dir/immich/app/package.json" "$install_dir/immich/app/bin"
205 | ynh_replace --match="^start" --replace="./start" --file="$install_dir/immich/app/bin/immich-admin"
206 | # Build openapi & web
207 | ynh_print_info "Building immich openapi & web interface..."
208 | cd "$source_dir"
209 | ynh_hide_warnings pnpm --filter @immich/sdk --filter immich-web --frozen-lockfile --force install
210 | ynh_hide_warnings pnpm --filter @immich/sdk --filter immich-web build
211 | cp -a web/build "$install_dir/immich/app/www"
212 | # Build cli
213 | ynh_print_info "Building immich cli..."
214 | cd "$source_dir"
215 | ynh_hide_warnings pnpm --filter @immich/sdk --filter @immich/cli --frozen-lockfile install
216 | ynh_hide_warnings pnpm --filter @immich/sdk --filter @immich/cli build
217 | ynh_hide_warnings pnpm --filter @immich/cli --prod --no-optional deploy "$install_dir/immich/app/cli"
218 | ln -s "$install_dir/immich/app/cli/bin/immich" "$install_dir/immich/app/bin/immich"
219 | # Build plugins
220 | ynh_print_info "Building immich plugins..."
221 | cd "$source_dir"
222 | mkdir -p "$install_dir/immich/app/corePlugin"
223 | if [[ $YNH_DEBIAN_VERSION == "bookworm" ]]
224 | then
225 | ynh_replace \
226 | --match="github:extism/js-pdk" \
227 | --replace="github:ewilly/js-pdk" \
228 | --file="$source_dir/plugins/mise.toml"
229 | fi
230 | ynh_hide_warnings mise trust --ignore ./mise.toml
231 | ynh_hide_warnings mise trust ./plugins/mise.toml
232 | cd "$source_dir/plugins"
233 | ynh_hide_warnings mise install
234 | PATH="$MISE_DATA_DIR/shims:$PATH"
235 | ynh_hide_warnings mise run build
236 | mkdir -p "$install_dir/immich/app/corePlugin"
237 | cp -r dist "$install_dir/immich/app/corePlugin/dist"
238 | cp manifest.json "$install_dir/immich/app/corePlugin"
239 | # Copy remaining assets
240 | cp -a LICENSE "$install_dir/immich/app/"
241 | # Install custom start.sh script
242 | ynh_safe_rm "$install_dir/immich/app/bin/start.sh"
243 | ynh_config_add --template="$app-server-start.sh" --destination="$install_dir/immich/app/bin/start.sh"
244 | # Cleanup
245 | ynh_hide_warnings pnpm prune
246 | ynh_hide_warnings pnpm store prune
247 | #ynh_hide_warnings mise implode
248 | unset PNPM_HOME
249 | unset MISE_DATA_DIR
250 | unset MISE_CACHE_DIR
251 | unset SHARP_IGNORE_GLOBAL_LIBVIPS
252 |
253 | # Install immich-machine-learning
254 | ynh_print_info "Building immich machine learning..."
255 | cd "$source_dir/machine-learning"
256 | mkdir -p "$install_dir/immich/app/machine-learning"
257 | # Install uv
258 | PIPX_HOME="/opt/pipx" PIPX_BIN_DIR="/usr/local/bin" pipx install uv --force 2>&1
259 | PIPX_HOME="/opt/pipx" PIPX_BIN_DIR="/usr/local/bin" pipx upgrade uv --force 2>&1
260 | local uv="/usr/local/bin/uv"
261 | # Execute in a subshell
262 | (
263 | # Define some options for uv
264 | export UV_PYTHON_INSTALL_DIR="$install_dir/immich/app/machine-learning"
265 | export UV_NO_CACHE=true
266 | export UV_NO_MODIFY_PATH=true
267 | # Create the virtual environment
268 | python_version=$(cat "$source_dir/machine-learning/Dockerfile" \
269 | | grep "FROM python:" | head -n1 | cut -d':' -f2 | cut -d'-' -f1) # 3.11
270 | ynh_app_setting_set --key=python_version --value=$python_version
271 | "$uv" venv --quiet "$install_dir/immich/app/machine-learning/venv" --python "$python_version" --python-preference only-managed
272 | # Activate the virtual environment
273 | set +o nounset
274 | source "$install_dir/immich/app/machine-learning/venv/bin/activate"
275 | set -o nounset
276 | # Add pip
277 | "$uv" pip --quiet --no-cache-dir install --upgrade pip
278 | # Add uv
279 | ynh_hide_warnings "$install_dir/immich/app/machine-learning/venv/bin/pip" install --no-cache-dir --upgrade uv
280 | # Install with uv
281 | ynh_hide_warnings "$install_dir/immich/app/machine-learning/venv/bin/uv" sync \
282 | --quiet --frozen --extra cpu --no-dev --no-editable --no-install-project --compile-bytecode --no-progress --active --link-mode copy
283 | # Clear uv options
284 | unset UV_PYTHON_INSTALL_DIR
285 | unset UV_NO_CACHE
286 | unset UV_NO_MODIFY_PATH
287 | )
288 | # Copy built files
289 | cp -a "$source_dir/machine-learning/ann" "$install_dir/immich/app/machine-learning/"
290 | cp -a "$source_dir/machine-learning/immich_ml" "$install_dir/immich/app/machine-learning/"
291 | # Install custom start.sh script
292 | ynh_config_add --template="$app-machine-learning-start.sh" --destination="$install_dir/immich/app/machine-learning/ml_start.sh"
293 | # Create the cache direcotry
294 | mkdir -p "$install_dir/immich/.cache_ml"
295 |
296 | # Install geonames
297 | ynh_print_info "Adding geonames capabilities..."
298 | mkdir -p "$source_dir/geonames"
299 | cd "$source_dir/geonames"
300 | # Download files
301 | curl -LO "https://download.geonames.org/export/dump/cities500.zip" 2>&1
302 | curl -LO "https://download.geonames.org/export/dump/admin1CodesASCII.txt" 2>&1
303 | curl -LO "https://download.geonames.org/export/dump/admin2Codes.txt" 2>&1
304 | curl -LO "https://raw.githubusercontent.com/nvkelso/natural-earth-vector/v5.1.2/geojson/ne_10m_admin_0_countries.geojson" 2>&1
305 | unzip "cities500.zip"
306 | # Copy built files
307 | mkdir -p "$install_dir/immich/app/geodata/"
308 | cp -a "$source_dir/geonames/cities500.txt" "$install_dir/immich/app/geodata/"
309 | cp -a "$source_dir/geonames/admin1CodesASCII.txt" "$install_dir/immich/app/geodata/"
310 | cp -a "$source_dir/geonames/admin2Codes.txt" "$install_dir/immich/app/geodata/"
311 | cp -a "$source_dir/geonames/ne_10m_admin_0_countries.geojson" "$install_dir/immich/app/geodata/"
312 | # Update geodata-date
313 | date --iso-8601=seconds | tr -d "\n" > "$install_dir/immich/app/geodata/geodata-date.txt"
314 |
315 | # Cleanup
316 | ynh_print_info "Cleaning up immich source directory..."
317 | ynh_safe_rm "$source_dir"
318 | }
319 |
320 | # Execute a psql command as root user
321 | # usage: myynh_execute_psql_as_root [--tool=tool] --sql=sql [--options=options] [--cluster=cluster] [--database=database]
322 | # | arg: -t, --tool= - the psql tool to run (default: psql)
323 | # | arg: -s, --sql= - the SQL command to execute
324 | # | arg: -o, --options= - the options to add to psql
325 | # | arg: -c, --cluster= - the cluster to connect to (default: current cluster)
326 | # | arg: -d, --database= - the database to connect to
327 | myynh_execute_psql_as_root() {
328 | # Declare an array to define the options of this helper.
329 | local legacy_args=sod
330 | local -A args_array=([t]=tool= [s]=sql= [o]=options= [c]=cluster= [d]=database=)
331 | local tool
332 | local sql
333 | local options
334 | local cluster
335 | local database
336 | # Manage arguments with getopts
337 | ynh_handle_getopts_args "$@"
338 | tool="${tool:-psql}"
339 | sql="${sql:-}"
340 | options="${options:-}"
341 | cluster="${cluster:-$db_cluster}"
342 | database="${database:-}"
343 | if [ -n "$sql" ]
344 | then
345 | sql="--command=$sql"
346 | fi
347 | cluster="--cluster=$cluster"
348 | if [ -n "$database" ]
349 | then
350 | database="--dbname=$database"
351 | fi
352 |
353 | LC_ALL=C sudo --login --user=postgres PGUSER=postgres PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" \
354 | $tool "$cluster" $options "$database" "$sql"
355 | }
356 |
357 | # Create the cluster
358 | myynh_create_psql_cluster() {
359 | if [[ -z `pg_lsclusters | grep "$db_cluster"` ]]
360 | then
361 | pg_createcluster ${db_cluster/\// } --start
362 | fi
363 | }
364 |
365 | # Install the database
366 | myynh_create_psql_db() {
367 | db_pwd=$(ynh_app_setting_get --key=db_pwd)
368 |
369 | myynh_execute_psql_as_root --sql="CREATE DATABASE $app;"
370 | myynh_execute_psql_as_root --sql="CREATE USER $app WITH ENCRYPTED PASSWORD '$db_pwd';" --database="$app"
371 | myynh_execute_psql_as_root --sql="GRANT ALL PRIVILEGES ON DATABASE $app TO $app;" --database="$app"
372 | }
373 |
374 | # Update the database
375 | myynh_update_psql_db() {
376 | # Fix collation version mismatch
377 | databases=$(myynh_execute_psql_as_root \
378 | --sql="SELECT datname FROM pg_database WHERE datistemplate = false OR datname = 'template1';" \
379 | --options="--tuples-only --no-align" --database="postgres")
380 |
381 | for db in $databases
382 | do
383 | if ynh_hide_warnings myynh_execute_psql_as_root --sql=";" --database="$db" \
384 | | grep -q "collation version mismatch"
385 | then
386 | ynh_hide_warnings myynh_execute_psql_as_root --sql="REINDEX DATABASE $db;" --database="$db"
387 | myynh_execute_psql_as_root --sql="ALTER DATABASE $db REFRESH COLLATION VERSION;" --database="$db"
388 | fi
389 | done
390 |
391 | # Tune immich db
392 | myynh_execute_psql_as_root --sql="ALTER USER $app WITH SUPERUSER;" --database="$app"
393 | ynh_hide_warnings myynh_execute_psql_as_root --sql="CREATE EXTENSION IF NOT EXISTS vector;" --database="$app"
394 |
395 | # Retrive and save the postgresql port of the cluster and save it in settings
396 | myynh_retrieve_psql_port
397 | }
398 |
399 | # Remove the database
400 | # usage: myynh_drop_psql_db [--cluster=cluster]
401 | # | arg: -c, --cluster= - the cluster to connect to (default: current cluster)
402 | myynh_drop_psql_db() {
403 | # Declare an array to define the options of this helper.
404 | local legacy_args=sod
405 | local -A args_array=([c]=cluster=)
406 | local cluster
407 | # Manage arguments with getopts
408 | ynh_handle_getopts_args "$@"
409 | cluster="${cluster:-$db_cluster}"
410 |
411 | myynh_execute_psql_as_root --cluster="$cluster" --sql="REVOKE CONNECT ON DATABASE $app FROM public;"
412 | myynh_execute_psql_as_root --cluster="$cluster" --sql="SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity \
413 | WHERE pg_stat_activity.datname = '$app' AND pid <> pg_backend_pid();"
414 | myynh_execute_psql_as_root --cluster="$cluster" --sql="DROP DATABASE $app;"
415 | myynh_execute_psql_as_root --cluster="$cluster" --sql="DROP USER $app;"
416 | }
417 |
418 | # Dump the database
419 | # usage: myynh_dump_psql_db [--cluster=cluster]
420 | # | arg: -c, --cluster= - the cluster to connect to (default: current cluster)
421 | myynh_dump_psql_db() {
422 | # Declare an array to define the options of this helper.
423 | local legacy_args=sod
424 | local -A args_array=([c]=cluster=)
425 | local cluster
426 | # Manage arguments with getopts
427 | ynh_handle_getopts_args "$@"
428 | cluster="${cluster:-$db_cluster}"
429 |
430 | myynh_execute_psql_as_root --tool="pg_dump" --cluster="$cluster" --database="$app" > db.sql
431 | }
432 |
433 | # Restore the database
434 | # usage: myynh_restore_psql_db [--cluster=cluster]
435 | # | arg: -c, --cluster= - the cluster to connect to (default: current cluster)
436 | myynh_restore_psql_db() {
437 | # Declare an array to define the options of this helper.
438 | local legacy_args=sod
439 | local -A args_array=([c]=cluster=)
440 | local cluster
441 | # Manage arguments with getopts
442 | ynh_handle_getopts_args "$@"
443 | cluster="${cluster:-$db_cluster}"
444 |
445 | # Adjust the content cf. https://github.com/immich-app/immich/issues/5630#issuecomment-1866581570
446 | ynh_replace --match="SELECT pg_catalog.set_config('search_path', '', false);" \
447 | --replace="SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);" --file="db.sql"
448 |
449 | # Restore the db
450 | myynh_execute_psql_as_root --cluster="$cluster" --database="$app" < ./db.sql
451 |
452 | # Restore the password
453 | db_pwd="$(ynh_app_setting_get --key=db_pwd)"
454 | myynh_execute_psql_as_root --cluster="$cluster" --sql="ALTER USER $app WITH ENCRYPTED PASSWORD '$db_pwd';" --database="$app"
455 | }
456 |
457 | # Retrieve the postgresql port of the cluster
458 | myynh_retrieve_psql_port() {
459 | # usage: myynh_dump_psql_db [--cluster=cluster]
460 | # | arg: -c, --cluster= - the cluster to connect to (default: current cluster)
461 | # Declare an array to define the options of this helper.
462 | local legacy_args=sod
463 | local -A args_array=([c]=cluster=)
464 | local cluster
465 | # Manage arguments with getopts
466 | ynh_handle_getopts_args "$@"
467 | cluster="${cluster:-$db_cluster}"
468 |
469 | db_port=$(myynh_execute_psql_as_root --cluster="$cluster" --sql="\echo :PORT")
470 | ynh_app_setting_set --key=db_port --value=$db_port
471 | }
472 |
473 | # Set default cluster back to debian and remove autoprovisionned db if not on right cluster
474 | myynh_set_default_psql_cluster_to_debian_default() {
475 | local default_port=5432
476 | local config_file="/etc/postgresql-common/user_clusters"
477 |
478 | # Retrieve informations about default psql cluster
479 | default_db_cluster=$(pg_lsclusters --no-header | grep "$default_port" | cut -d' ' -f1)
480 | default_psql_cluster=$(pg_lsclusters --no-header | grep "$default_port" | cut -d' ' -f2)
481 | default_psql_database=$(pg_lsclusters --no-header | grep "$default_port" | cut -d' ' -f5)
482 |
483 | # Remove non commented lines
484 | sed -i'.bak' -e '/^#/!d' "$config_file"
485 |
486 | # Add new line USER GROUP VERSION CLUSTER DATABASE
487 | echo -e "* * $default_db_cluster $default_psql_cluster $default_psql_database" >> "$config_file"
488 |
489 | # Remove the autoprovisionned db if not on right cluster
490 | myynh_retrieve_psql_port
491 | if [[ $db_port -ne $default_port ]]
492 | then
493 | if ynh_psql_database_exists "$app"
494 | then
495 | ynh_psql_drop_db "$app"
496 | fi
497 | if ynh_psql_user_exists "$app"
498 | then
499 | ynh_psql_drop_user "$app"
500 | fi
501 | fi
502 | }
503 |
504 | # Set permissions
505 | myynh_set_permissions() {
506 | chown -R $app: "$install_dir"
507 | chmod u=rwX,g=rX,o= "$install_dir"
508 | chmod -R o-rwx "$install_dir"
509 |
510 | FILE_LIST=(
511 | "$install_dir/immich/app/start.sh"
512 | "$install_dir/immich/app/bin/start.sh"
513 | "$install_dir/immich/app/machine-learning/start.sh"
514 | "$install_dir/immich/app/machine-learning/ml_start.sh"
515 | )
516 | for file in "${FILE_LIST[@]}"; do
517 | test -f "$file" && chmod +x "$file"
518 | done
519 |
520 | chown -R $app: "$data_dir"
521 | chmod u=rwX,g=rX,o= "$data_dir"
522 | chmod -R o-rwx "$data_dir"
523 | chmod +x "$data_dir/backups/restore_immich_db_backup.sh"
524 |
525 | chown -R $app: "/var/log/$app"
526 | chmod u=rw,g=r,o= "/var/log/$app"
527 |
528 | # Upgade user groups
529 | local user_groups=""
530 | [ -n $(getent group video) ] && adduser --quiet "$app" video 2>&1
531 | [ -n $(getent group render) ] && adduser --quiet "$app" render 2>&1
532 | }
533 |
534 | # Add swap
535 | #
536 | # usage: ynh_add_swap --size=SWAP in Mb
537 | # | arg: -s, --size= - Amount of SWAP to add in Mb.
538 | ynh_add_swap_fixed() {
539 | if systemd-detect-virt --container --quiet; then
540 | ynh_print_warn "You are inside a container/VM. swap will not be added, but that can cause troubles for the app $app. Please make sure you have enough RAM available."
541 | return
542 | fi
543 |
544 | # Declare an array to define the options of this helper.
545 | declare -Ar args_array=([s]=size=)
546 | local size
547 | # Manage arguments with getopts
548 | ynh_handle_getopts_args "$@"
549 |
550 | local swap_max_size=$((size * 1024))
551 |
552 | local free_space=$(df --output=avail / | sed 1d)
553 | # Because we don't want to fill the disk with a swap file, divide by 2 the available space.
554 | local usable_space=$((free_space / 2))
555 |
556 | SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
557 |
558 | # Swap on SD card only if it's is specified
559 | if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]; then
560 | ynh_print_warn "The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
561 | return
562 | fi
563 |
564 | # Compare the available space with the size of the swap.
565 | # And set a acceptable size from the request
566 | if [ $usable_space -ge $swap_max_size ]; then
567 | local swap_size=$swap_max_size
568 | elif [ $usable_space -ge $((swap_max_size / 2)) ]; then
569 | local swap_size=$((swap_max_size / 2))
570 | elif [ $usable_space -ge $((swap_max_size / 3)) ]; then
571 | local swap_size=$((swap_max_size / 3))
572 | elif [ $usable_space -ge $((swap_max_size / 4)) ]; then
573 | local swap_size=$((swap_max_size / 4))
574 | else
575 | echo "Not enough space left for a swap file" >&2
576 | local swap_size=0
577 | fi
578 |
579 | # If there's enough space for a swap, and no existing swap here
580 | if [ $swap_size -ne 0 ] && [ ! -e "/swap_$app" ]; then
581 | # Create file
582 | truncate -s 0 "/swap_$app"
583 |
584 | # try to set the No_COW attribute on the swapfile with chattr (depending of the filesystem type)
585 | if grep -qs ' / .*btrfs' /proc/mounts; then
586 | chattr +C "/swap_$app"
587 | fi
588 |
589 | # Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
590 | if ! fallocate -l ${swap_size}K "/swap_$app"; then
591 | dd if=/dev/zero of="/swap_$app" bs=1024 count=${swap_size}
592 | fi
593 | chmod 0600 "/swap_$app"
594 | # Create the swap
595 | mkswap "/swap_$app"
596 | # And activate it
597 | swapon "/swap_$app"
598 | # Then add an entry in fstab to load this swap at each boot.
599 | echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab
600 | fi
601 | }
602 |
603 | ynh_del_swap_fixed() {
604 | # If there a swap at this place
605 | if [ -e "/swap_$app" ]; then
606 | # Clean the fstab
607 | sed -i "/#Swap added by $app/d" /etc/fstab
608 | # Desactive the swap file if active
609 | if grep -qs "/swap_$app" /proc/swaps; then
610 | swapoff "/swap_$app"
611 | fi
612 | # And remove it
613 | rm "/swap_$app"
614 | fi
615 | }
616 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 |
--------------------------------------------------------------------------------