forked from tronbyt/apps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_intervals_script.sh
More file actions
executable file
·32 lines (29 loc) · 1.34 KB
/
update_intervals_script.sh
File metadata and controls
executable file
·32 lines (29 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# This script will insert or update the recommendedInterval line in the manifest.yaml for each app
# according to the update_intervals.txt file
# recommendedInterval will be used as the default update interval when adding app to tronbyt.
while IFS=': ' read -r app interval || [[ -n "$app" ]]; do
if [[ $app =~ ^#.* ]] || [[ -z "$app" ]] || [[ -z "$interval" ]]; then
continue
fi
app_dir="apps/${app}"
manifest_file="${app_dir}/manifest.yaml"
if [[ -f "$manifest_file" ]]; then
# Check if recommendedInterval already exists
if grep -q "recommendedInterval:" "$manifest_file"; then
# Update existing recommendedInterval
sed -i.bak "s/recommendedInterval:.*$/recommendedInterval: $interval/" "$manifest_file" && rm -f "${manifest_file}.bak"
else
# Add recommendedInterval before the first blank line or at the end of file
awk -v interval="$interval" \
' \
/^$/ && !added { print "recommendedInterval: " interval; added=1; print ""; next } \
END { if(!added) { print "recommendedInterval: " interval; } } \
{ print } \
' "$manifest_file" > "${manifest_file}.tmp" && mv "${manifest_file}.tmp" "$manifest_file"
fi
echo "Updated $manifest_file with interval $interval"
else
echo "Warning: Manifest file not found for $app"
fi
done < update_intervals.txt