[osm-tile-server] 51/117: Keep track of whether file has been downloaded and imported

Ruben Undheim rubund-guest at moszumanska.debian.org
Tue Nov 3 23:18:19 UTC 2015


This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch master
in repository osm-tile-server.

commit bd1fba323db134bedcba8f8fd5a6581bee6ad988
Author: Ruben Undheim <ruben.undheim at gmail.com>
Date:   Fri Sep 4 00:49:16 2015 +0200

    Keep track of whether file has been downloaded and imported
---
 debian/osm-tile-server-base.postinst | 14 ++++++++++++--
 src/Makefile                         |  8 ++++++--
 src/osm-tile-server-status.c         | 37 ++++++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/debian/osm-tile-server-base.postinst b/debian/osm-tile-server-base.postinst
index 6966e75..4a9a769 100644
--- a/debian/osm-tile-server-base.postinst
+++ b/debian/osm-tile-server-base.postinst
@@ -29,6 +29,10 @@ case "$1" in
         db_get osm-tile-server/import-sample
         IMPORTSAMPLE=$RET
         db_set osm-tile-server/import-sample false
+
+        db_get osm-tile-server/action-now
+        ACTIONNOW=$RET
+
         db_get osm-tile-server/do_it_now
         PROCESSNOW=$RET
         db_set osm-tile-server/do_it_now "Later"
@@ -86,6 +90,8 @@ case "$1" in
         chmod 4554 /usr/bin/osm-tile-server-import
         chown $DBUSER:$DBUSER /usr/bin/osm-tile-server-download
         chmod 4554 /usr/bin/osm-tile-server-download
+        chown $DBUSER:$DBUSER /usr/bin/osm-tile-server-status
+        chmod 4554 /usr/bin/osm-tile-server-status
         
         chown $DBUSER:$DBUSER /var/cache/osm-tile-server-base
 
@@ -94,8 +100,12 @@ case "$1" in
             su $DBUSER -c "osm2pgsql --slim -d $DBNAME --cache-strategy sparse -C 100 --hstore -S /usr/share/osm2pgsql/default.style /usr/share/osm-tile-server-base/samples/liechtenstein-latest.osm.pbf"
         fi
 
-        if [ "$PROCESSNOW" = "Now; will take some time" ] ; then
-            osm-tile-server-process
+        if [ "$ACTIONNOW" = "true" ] ; then
+            su $DBUSER -c "echo \"\" > /var/cache/osm-tile-server-base/status.txt"
+            if [ "$PROCESSNOW" = "Now; will take some time" ] ; then
+                osm-tile-server-process
+                su $DBUSER -c "echo \"DONE\" > /var/cache/osm-tile-server-base/status.txt"
+            fi
         fi
 
     ;;
diff --git a/src/Makefile b/src/Makefile
index bef17e0..8cdc9d2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,11 +1,12 @@
 
 
-default: osm-tile-server-import osm-tile-server-download
+default: osm-tile-server-import osm-tile-server-download osm-tile-server-status
 
 install: default
 	mkdir -p ${DESTDIR}/usr/bin
 	install osm-tile-server-import ${DESTDIR}/usr/bin/
 	install osm-tile-server-download ${DESTDIR}/usr/bin/
+	install osm-tile-server-status ${DESTDIR}/usr/bin/
 
 osm-tile-server-import: osm-tile-server-import.o parse-settings.o
 	${CC} ${LDFLAGS} -o osm-tile-server-import osm-tile-server-import.o parse-settings.o
@@ -13,5 +14,8 @@ osm-tile-server-import: osm-tile-server-import.o parse-settings.o
 osm-tile-server-download: osm-tile-server-download.o parse-settings.o
 	${CC} ${LDFLAGS} -o osm-tile-server-download osm-tile-server-download.o parse-settings.o
 
+osm-tile-server-status: osm-tile-server-status.o parse-settings.o
+	${CC} ${LDFLAGS} -o osm-tile-server-status osm-tile-server-status.o parse-settings.o
+
 clean:
-	${RM} *.o osm-tile-server-import osm-tile-server-download
+	${RM} *.o osm-tile-server-import osm-tile-server-download osm-tile-server-status
diff --git a/src/osm-tile-server-status.c b/src/osm-tile-server-status.c
new file mode 100644
index 0000000..54ec14c
--- /dev/null
+++ b/src/osm-tile-server-status.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "parse-settings.h"
+
+int main(int argc, char **argv)
+{
+	char command[256];
+	char *cmd;
+
+	if(argc != 2){
+		fprintf(stderr,"Usage: %s <command>\n",argv[0]);
+		return -1;
+	}
+
+	parse_settings();
+
+	cmd = argv[1];
+
+	FILE *wfile;
+
+	if(strncmp(cmd,"done",4) == 0) {
+		wfile = fopen("/var/cache/osm-tile-server-base/status.txt","w");
+		fprintf(wfile,"DONE");
+		fclose(wfile);
+	}
+
+	//snprintf(command,255,"osm2pgsql --slim -d %s --cache-strategy sparse -C 100 --hstore -S /usr/share/osm2pgsql/default.style %s",dbname,pbffile);
+	//printf("Importing to database with this command:\n\n");
+	//printf(" %s\n\n",command);
+	//system(command);
+
+	return 0;
+
+}
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osm-tile-server.git



More information about the Pkg-grass-devel mailing list