Skip to content

Commit

Permalink
Merge pull request #111 from copart/main
Browse files Browse the repository at this point in the history
Added new env RUN_IMMEDIATELY bool that will execute the script at do…
  • Loading branch information
Salvoxia authored Jan 21, 2025
2 parents 93357eb + 7d8280e commit ee43acb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ The environment variables are analogous to the script's command line arguments.
| API_KEY | no | The Immich API Key to use. Either `API_KEY` or `API_KEY_FILE` must be specified. The `API_KEY` variable takes precedence for ease of manual execution, but it is recommended to use `API_KEY_FILE`.
| API_KEY_FILE | no | An absolute path (from the root of the container) to a file containing the Immich API Key. The file might be mounted into the container using a volume (e.g. `-v /path/to/api_key.secret:/immich_api_key.secret:ro`). The file must contain only the value. |
| CRON_EXPRESSION | yes | A [crontab-style expression](https://crontab.guru/) (e.g. `0 * * * *`) to perform album creation on a schedule (e.g. every hour). |
| RUN_IMMEDIATELY | no | Set to `true` to run the script right away, after running once the script will automatically run again based on the CRON_EXPRESSION |
| ALBUM_LEVELS | no | Number of sub-folders or range of sub-folder levels below the root path used for album name creation. Positive numbers start from top of the folder structure, negative numbers from the bottom. Cannot be `0`. If a range should be set, the start level and end level must be separated by a comma. <br>Refer to [How it works](#how-it-works) for a detailed explanation and examples. |
| ALBUM_SEPARATOR | no | Separator string to use for compound album names created from nested folders. Only effective if `-a` is set to a value `> 1`(default: "` `") |
| CHUNK_SIZE | no | Maximum number of assets to add to an album with a single API call (default: `2000`) |
Expand Down
6 changes: 5 additions & 1 deletion docker/setup_cron.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env sh

if [ ! -z "$RUN_IMMEDIATELY" ]; then
if [ "$RUN_IMMEDIATELY" = "true" ] || [ "$RUN_IMMEDIATELY" = "1" ]; then
UNATTENDED=1 /script/immich_auto_album.sh > /proc/1/fd/1 2>/proc/1/fd/2 || true
fi
fi
if [ ! -z "$CRON_EXPRESSION" ]; then
CRONTAB="$CRON_EXPRESSION UNATTENDED=1 /script/immich_auto_album.sh > /proc/1/fd/1 2>/proc/1/fd/2"
# Reset crontab
Expand Down

0 comments on commit ee43acb

Please sign in to comment.