mirror of
https://github.com/richb-hanover/OpenWrtScripts.git
synced 2026-03-30 10:44:32 +02:00
Improve logic around caching IPK so don't run opkg update multiple times.
This commit is contained in:
parent
953c80e2cf
commit
f0cb22206c
1 changed files with 15 additions and 1 deletions
|
|
@ -173,7 +173,21 @@ if [ $COMMAND = "cache-ipks" ] ; then
|
|||
echo "Running opkg update..."
|
||||
fi
|
||||
|
||||
opkg update
|
||||
# Only update if lists are older than 5 minutes
|
||||
CACHE_AGE_LIMIT=300 # seconds
|
||||
needs_update=false
|
||||
for list in /var/opkg-lists/*; do
|
||||
if [ ! -f "$list" ] || [ "$(($(date +%s) - $(stat -c %Y "$list")))" -gt "$CACHE_AGE_LIMIT" ]; then
|
||||
needs_update=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if $needs_update; then
|
||||
opkg update
|
||||
else
|
||||
echo "Skipping opkg update: cache is fresh"
|
||||
fi
|
||||
|
||||
if $VERBOSE; then
|
||||
echo "Finished opkg update"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue