Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from haakemon/update-0.15.89752-2
Browse files Browse the repository at this point in the history
  • Loading branch information
haakemon committed Aug 28, 2023
2 parents b31b10b + 1c8f74c commit aee887f
Showing 1 changed file with 40 additions and 7 deletions.
47 changes: 40 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,49 @@ while :; do
sleep 1
done

echo "Adding backups"

for dir in /backup/*; do if [ -d "${dir}" ]; then set +e && jotta-cli add /$dir && set -e; fi; done
remove_ignores() {
local output
local trimmed_entries

# Capture output of the ignores list command, it pipes to stderr for some reason
output=$(jotta-cli ignores list 2>&1 >/dev/null)

# Extract lines starting with " > ", trim them, and remove duplicates
trimmed_entries=$(echo "$output" | grep -o ' > .*' | sed 's/^ > //g' | sort -u)

# Loop through each trimmed entry and execute your desired command
while IFS= read -r entry; do
echo "Removing ignore pattern: $entry"
jotta-cli ignores rem --pattern $entry
done <<<"$trimmed_entries"
}

add_ignores() {
for i in ${GLOBAL_IGNORE//,/ }; do
echo "Adding ignore pattern: $i"
jotta-cli ignores add --pattern $i
done
}

add_backups() {
echo "Adding backups"
for dir in /backup/*; do
if [ -d "${dir}" ]; then
set +e
jotta-cli add "/$dir"
set -e
fi
done
}

# Because we have no good way of removing stuff from the GLOBAL_IGNORE list,
# we remove all current ignored entries and re-add them using the GLOBAL_IGNORE list.
# That way we should just be left with stuff we actually want to ignore.
jotta-cli ignores use-version-2
remove_ignores
add_ignores

for i in ${GLOBAL_IGNORE//,/ }; do
echo "Adding $i to global ignore"
jotta-cli ignores add --pattern $i
done
add_backups

echo "Setting scan interval"
jotta-cli config set scaninterval $JOTTA_SCANINTERVAL
Expand Down

0 comments on commit aee887f

Please sign in to comment.