31 lines
822 B
Bash
31 lines
822 B
Bash
#!/bin/bash
|
|
|
|
import_images() {
|
|
local starttime=$(date +%s) imagetime timestamp elapsed
|
|
exec >> images.log
|
|
exec 2>> images.log
|
|
declare -r oldIFS="$IFS"
|
|
[[ -r .importing ]] && return 2
|
|
[[ -w "$rrdfile" ]] || rrdcreate
|
|
readlast
|
|
for file in dav/*
|
|
do
|
|
[[ -r "$file" ]] || continue
|
|
IFS=_.
|
|
read junk date time junk <<<"$file"
|
|
IFS="$oldIFS"
|
|
if (( $(date '+%Y%m%d%H%M%S' -d @${last[time]}) < $date$time ))
|
|
then
|
|
[[ -r .importing ]] && return 2
|
|
touch .importing
|
|
imagetime="${date:0:4}/${date:4:2}/${date:6:2} ${time:0:2}:${time:2:2}:${time:4:2}"
|
|
echo "$(date +"%Y/%m/%d:%H:%M:%S") - $file: $imagetime"
|
|
timestamp=$(date +%s -d "$imagetime")
|
|
image "$file" $timestamp
|
|
fi
|
|
done
|
|
elapsed=$(( $(date +%s) - starttime ))
|
|
echo "$(date +"%Y/%m/%d:%H:%M:%S"): Spent $elapsed seconds"
|
|
rm .importing
|
|
}
|