2024-02-24 14:15:57 +01:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2024-08-05 19:56:44 +02:00
|
|
|
# parse comma separated root paths and wrap in quotes
|
|
|
|
oldIFS=$IFS
|
|
|
|
IFS=','
|
|
|
|
# disable globbing
|
|
|
|
set -f
|
2024-08-16 20:52:33 +02:00
|
|
|
# parse ROOT_PATH CSV
|
2024-04-09 21:16:38 +02:00
|
|
|
main_root_path=""
|
|
|
|
additional_root_paths=""
|
2024-08-05 19:56:44 +02:00
|
|
|
for path in ${ROOT_PATH}; do
|
2024-04-09 21:16:38 +02:00
|
|
|
if [ -z "$main_root_path" ]; then
|
2024-08-05 19:56:44 +02:00
|
|
|
main_root_path="\"$path\""
|
2024-04-09 21:16:38 +02:00
|
|
|
else
|
2024-08-05 19:56:44 +02:00
|
|
|
additional_root_paths="-r \"$path\" $additional_root_paths"
|
2024-04-09 21:16:38 +02:00
|
|
|
fi
|
|
|
|
done
|
2024-08-16 21:00:46 +02:00
|
|
|
IFS=$oldIFS
|
2024-08-16 20:52:33 +02:00
|
|
|
|
2024-08-16 21:00:46 +02:00
|
|
|
# parse semicolon separated root paths and wrap in quotes
|
|
|
|
oldIFS=$IFS
|
|
|
|
IFS=':'
|
2024-08-16 20:52:33 +02:00
|
|
|
# parse SHARE_WITH CSV
|
|
|
|
share_with_list=""
|
|
|
|
for share_user in ${SHARE_WITH}; do
|
|
|
|
share_with_list="-x \"$share_user\" $share_with_list"
|
|
|
|
done
|
|
|
|
# reset IFS
|
2024-08-05 19:56:44 +02:00
|
|
|
IFS=$oldIFS
|
2024-04-09 21:16:38 +02:00
|
|
|
|
2024-08-02 19:36:05 +02:00
|
|
|
unattended=
|
|
|
|
if [ ! -z "$UNATTENDED" ]; then
|
|
|
|
unattended="-u"
|
|
|
|
fi
|
|
|
|
|
|
|
|
args="$unattended $main_root_path $API_URL $API_KEY"
|
2024-04-09 21:16:38 +02:00
|
|
|
|
|
|
|
if [ ! -z "$additional_root_paths" ]; then
|
|
|
|
args="$additional_root_paths $args"
|
|
|
|
fi
|
2024-03-03 18:52:35 +01:00
|
|
|
|
|
|
|
if [ ! -z "$ALBUM_LEVELS" ]; then
|
|
|
|
args="-a $ALBUM_LEVELS $args"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$ALBUM_SEPARATOR" ]; then
|
|
|
|
args="-s \"$ALBUM_SEPARATOR\" $args"
|
|
|
|
fi
|
2024-02-24 14:15:57 +01:00
|
|
|
|
|
|
|
if [ ! -z "$FETCH_CHUNK_SIZE" ]; then
|
2024-03-03 18:52:35 +01:00
|
|
|
args="-C $FETCH_CHUNK_SIZE $args"
|
2024-02-24 14:15:57 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$CHUNK_SIZE" ]; then
|
2024-03-03 18:52:35 +01:00
|
|
|
args="-c $CHUNK_SIZE $args"
|
2024-02-24 14:15:57 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$LOG_LEVEL" ]; then
|
2024-03-03 18:52:35 +01:00
|
|
|
args="-l $LOG_LEVEL $args"
|
2024-02-24 14:15:57 +01:00
|
|
|
fi
|
|
|
|
|
2024-07-30 20:40:20 +02:00
|
|
|
if [ "$INSECURE" = "true" ]; then
|
|
|
|
args="-k $args"
|
|
|
|
fi
|
|
|
|
|
2024-07-30 21:11:17 +02:00
|
|
|
if [ ! -z "$IGNORE" ]; then
|
|
|
|
args="-i \"$IGNORE\" $args"
|
|
|
|
fi
|
|
|
|
|
2024-08-02 19:36:05 +02:00
|
|
|
if [ ! -z "$MODE" ]; then
|
|
|
|
args="-m \"$MODE\" $args"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$DELETE_CONFIRM" ]; then
|
|
|
|
args="-d $args"
|
|
|
|
fi
|
2024-03-03 18:52:35 +01:00
|
|
|
|
2024-08-16 20:52:33 +02:00
|
|
|
if [ ! -z "$share_with_list" ]; then
|
|
|
|
args="$share_with_list $args"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "$SHARE_ROLE" ]; then
|
|
|
|
args="-o $SHARE_ROLE $args"
|
|
|
|
fi
|
|
|
|
|
2024-08-18 11:23:51 +02:00
|
|
|
if [ ! -z "$SYNC_MODE" ]; then
|
|
|
|
args="-S $SYNC_MODE $args"
|
|
|
|
fi
|
|
|
|
|
2024-08-21 14:43:59 +02:00
|
|
|
if [ ! -z "$ALBUM_ORDER" ]; then
|
|
|
|
args="-O $ALBUM_ORDER $args"
|
|
|
|
fi
|
|
|
|
|
2024-09-07 16:24:13 +02:00
|
|
|
if [ ! -z "$FIND_ASSETS_IN_ALBUMS" ]; then
|
|
|
|
args="-A $args"
|
|
|
|
fi
|
|
|
|
|
2024-09-08 15:05:23 +02:00
|
|
|
if [ ! -z "$PATH_FILTER" ]; then
|
|
|
|
args="-f \"$PATH_FILTER\" $args"
|
|
|
|
fi
|
|
|
|
|
2024-02-24 14:15:57 +01:00
|
|
|
BASEDIR=$(dirname "$0")
|
2024-03-03 18:52:35 +01:00
|
|
|
echo $args | xargs python3 -u $BASEDIR/immich_auto_album.py
|