Add documentation on how to get this running on a psql setup
[gpx-import.git] / settings.sh
1 #!/bin/sh
2
3 # This script configures the environment to use the OSM db
4 # so that the gpx-import program can find it.
5
6 setting () {
7   S_N=GPX_$1
8   shift
9   eval "${S_N}='$*'"
10   export ${S_N}
11 }
12
13 # General settings
14 setting SLEEP_TIME 1
15
16 # Paths (can be relative from invocation path if appropriate)
17 setting PATH_TRACES /home/osm/traces
18 setting PATH_IMAGES /home/osm/images
19 setting PATH_TEMPLATES templates/
20
21 # PostgreSQL connection
22 #setting PGSQL_HOST localhost
23 #setting PGSQL_USER openstreetmap
24 #setting PGSQL_DB openstreetmap
25 #setting PGSQL_PASS openstreetmap
26
27 # MySQL connection
28 setting MYSQL_HOST localhost
29 setting MYSQL_USER openstreetmap
30 setting MYSQL_DB openstreetmap
31 setting MYSQL_PASS openstreetmap
32
33 # Logging, pidfiles etc
34 # If you comment out the LOGFILE then it will log to stdout
35 setting LOG_FILE /home/osm/gpx-import.log
36 # If you comment out the PIDFILE then it will not daemonise
37 setting PID_FILE /home/osm/gpx-import.pid
38
39 # Optional debug statements
40 #setting INTERPOLATE_STDOUT 1
41
42 CMD=$1
43 shift
44
45 case "$CMD" in
46     start)
47         if test "x$GPX_PID_FILE" = "x"; then
48             exec "$@"
49         else
50             "$@"
51             $0 check
52         fi
53         ;;
54     stop)
55         if test -r $GPX_PID_FILE; then
56             PID=$(cat $GPX_PID_FILE)
57             if test "x$PID" != "x"; then
58                 if kill -0 $PID; then
59                     kill -TERM $PID
60                     for TRY in $(seq 1 10); do
61                         sleep 1
62                         if ! kill -0 $PID; then
63                             echo "GPX daemon killed"
64                             rm -f $GPX_PID_FILE
65                             exit 0
66                         else
67                             echo "Still running?"
68                         fi
69                     done
70                     echo "GPX daemon still running?"
71                     exit 1
72                 else
73                     echo "GPX daemon is not running, pid ?= $PID"
74                     exit 1
75                 fi
76             else
77                 echo "GPX daemon pidfile is empty"
78                 exit 1
79             fi
80         else
81             echo "GPX daemon pidfile is missing"
82             exit 1
83         fi
84         ;;
85     rotated)
86         if test -r $GPX_PID_FILE; then
87             PID=$(cat $GPX_PID_FILE)
88             if test "x$PID" != "x"; then
89                 if kill -0 $PID; then
90                     kill -HUP $PID
91                     echo "GPX daemon sent HUP"
92                     sleep 0.5
93                     $0 check
94                 else
95                     echo "GPX daemon is not running, pid ?= $PID"
96                 fi
97             else
98                 echo "GPX daemon pidfile is empty"
99             fi
100         else
101             echo "GPX daemon pidfile is missing"
102         fi
103         ;;
104     check)
105         if test -r $GPX_PID_FILE; then
106             PID=$(cat $GPX_PID_FILE)
107             if test "x$PID" != "x"; then
108                 if kill -0 $PID; then
109                     echo "GPX daemon is running, pid = $PID"
110                 else
111                     echo "GPX daemon is not running, pid ?= $PID"
112                     exit 1
113                 fi
114             else
115                 echo "GPX daemon pidfile is empty"
116                 exit 1
117             fi
118         else
119             echo "GPX daemon pidfile is missing"
120             exit 1
121         fi
122         ;;
123     *)
124         echo "usage: $0 [start|stop|rotated|check] path/to/gpx-import"
125         ;;
126 esac