Correct type of zlib file handle
[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 # Memcache caches
34 #setting MEMCACHE_SERVERS localhost
35
36 # Logging, pidfiles etc
37 # If you comment out the LOGFILE then it will log to stdout
38 setting LOG_FILE /home/osm/gpx-import.log
39 # If you comment out the PIDFILE then it will not daemonise
40 setting PID_FILE /home/osm/gpx-import.pid
41
42 # Mail notifications
43 #setting MAIL_SENDER example@example.com
44
45 # Optional debug statements
46 #setting INTERPOLATE_STDOUT 1
47
48 CMD=$1
49 shift
50
51 case "$CMD" in
52     start)
53         if test "x$GPX_PID_FILE" = "x"; then
54             exec "$@"
55         else
56             "$@"
57             $0 check
58         fi
59         ;;
60     stop)
61         if test -r $GPX_PID_FILE; then
62             PID=$(cat $GPX_PID_FILE)
63             if test "x$PID" != "x"; then
64                 if kill -0 $PID; then
65                     kill -TERM $PID
66                     for TRY in $(seq 1 10); do
67                         sleep 1
68                         if ! kill -0 $PID; then
69                             echo "GPX daemon killed"
70                             rm -f $GPX_PID_FILE
71                             exit 0
72                         else
73                             echo "Still running?"
74                         fi
75                     done
76                     echo "GPX daemon still running?"
77                     exit 1
78                 else
79                     echo "GPX daemon is not running, pid ?= $PID"
80                     exit 1
81                 fi
82             else
83                 echo "GPX daemon pidfile is empty"
84                 exit 1
85             fi
86         else
87             echo "GPX daemon pidfile is missing"
88             exit 1
89         fi
90         ;;
91     rotated)
92         if test -r $GPX_PID_FILE; then
93             PID=$(cat $GPX_PID_FILE)
94             if test "x$PID" != "x"; then
95                 if kill -0 $PID; then
96                     kill -HUP $PID
97                     sleep 0.5
98                     $0 check > /dev/null || echo "GPX daemon is not running, pid ?= $PID"
99                 else
100                     echo "GPX daemon is not running, pid ?= $PID"
101                 fi
102             else
103                 echo "GPX daemon pidfile is empty"
104             fi
105         else
106             echo "GPX daemon pidfile is missing"
107         fi
108         ;;
109     check)
110         if test -r $GPX_PID_FILE; then
111             PID=$(cat $GPX_PID_FILE)
112             if test "x$PID" != "x"; then
113                 if kill -0 $PID; then
114                     echo "GPX daemon is running, pid = $PID"
115                 else
116                     echo "GPX daemon is not running, pid ?= $PID"
117                     exit 1
118                 fi
119             else
120                 echo "GPX daemon pidfile is empty"
121                 exit 1
122             fi
123         else
124             echo "GPX daemon pidfile is missing"
125             exit 1
126         fi
127         ;;
128     *)
129         echo "usage: $0 [start|stop|rotated|check] path/to/gpx-import"
130         ;;
131 esac