| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# Copyright (c) 2007 - 2023 by mod_tile contributors (see AUTHORS file) |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or |
| 6 |
# modify it under the terms of the GNU General Public License |
| 7 |
# as published by the Free Software Foundation; either version 2 |
| 8 |
# of the License, or (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; If not, see http://www.gnu.org/licenses/. |
| 17 |
|
| 18 |
STATE=/var/cache/renderd/tiles/.osmosis/state.txt |
| 19 |
|
| 20 |
rep=$(cat ${STATE} | |
| 21 |
grep 'timestamp' | |
| 22 |
awk '{split($0, a, "="); print a[2]}' | |
| 23 |
tr 'T' ' ' | |
| 24 |
xargs -I{} ${BINPATH}date --utc --date "{}" +%s) |
| 25 |
is=$(date --utc +%s) |
| 26 |
|
| 27 |
lag=$(($is - $rep)) |
| 28 |
|
| 29 |
if [ "$1" = "-h" ]; then |
| 30 |
|
| 31 |
if [ $lag -gt 86400 ]; then |
| 32 |
echo $(($lag / 86400)) "day(s) and" $((($lag % 86400) / 3600)) "hour(s)" |
| 33 |
elif [ $lag -gt 3600 ]; then |
| 34 |
echo $(($lag / 3600)) "hour(s)" |
| 35 |
elif [ $lag -gt 60 ]; then |
| 36 |
echo $(($lag / 60)) "minute(s)" |
| 37 |
else |
| 38 |
echo $lag "second(s)" |
| 39 |
fi |
| 40 |
|
| 41 |
else |
| 42 |
|
| 43 |
echo $lag |
| 44 |
|
| 45 |
fi |