50 lines
1.7 KiB
Bash
50 lines
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
|
# Copyright (C) 2014-2015 Vincent Riquer
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import_images() {
|
|
local starttime=$(date +%s) imagetime timestamp elapsed lasttime now
|
|
exec >> images.log
|
|
exec 2>> images.log
|
|
declare -r oldIFS="$IFS"
|
|
[[ -r .importing ]] && return 2
|
|
[[ -w "$rrdfile" ]] || rrdcreate
|
|
readlast
|
|
for file in dav/profile_*.png
|
|
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
|
|
(( count++ ))
|
|
lasttime=${now:-$starttime}
|
|
echo "${file##*/}" > .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
|
|
now=$(date +%s)
|
|
echo $'\tDuration: '$(( now - lasttime ))
|
|
fi
|
|
done
|
|
elapsed=$(( $(date +%s) - starttime ))
|
|
(( count )) && echo "$(date +"%Y/%m/%d:%H:%M:%S"): Imported $count file(s) in $elapsed seconds."
|
|
rm -f .importing
|
|
}
|