--- utils/osmosis-db_replag~ 2024-12-26 18:40:12 +++ utils/osmosis-db_replag 2024-12-26 18:49:23 @@ -15,15 +15,27 @@ # You should have received a copy of the GNU General Public License # along with this program; If not, see http://www.gnu.org/licenses/. -STATE=/var/cache/renderd/tiles/.osmosis/state.txt +STATE=@PREFIX@/var/lib/mod_tile/.osmosis/state.txt -rep=$(cat ${STATE} | - grep 'timestamp' | - awk '{split($0, a, "="); print a[2]}' | - tr 'T' ' ' | - xargs -I{} ${BINPATH}date --utc --date "{}" +%s) -is=$(date --utc +%s) +if [ ! -r "$STATE" ]; then + echo "-1 seconds" + exit 0 +fi +if [[ "$OSTYPE" != "darwin"* ]]; then + rep=$(cat ${STATE} | + grep 'timestamp' | + awk '{split($0, a, "="); print a[2]}' | + tr 'T' ' ' | + xargs -I{} ${BINPATH}date --utc --date "{}" +%s) + is=$(date --utc +%s) +else + rep=$(cat ${STATE} |\ + awk '/timestamp=/{d = substr($1, 11, 10);t = substr($1, 22, 10); z = substr($1, 32); if (z = "Z") {z = "UTC";}; print d " " t z;}' |\ + xargs -I{} ${BINPATH}date -ju -f "%Y-%m-%d %H:%M:%S%Z" "{}" +%s) + is=$(date --utc +%s) +fi + lag=$(($is - $rep)) if [ "$1" = "-h" ]; then