-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·97 lines (83 loc) · 1.9 KB
/
setup
File metadata and controls
executable file
·97 lines (83 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#
# Import de la base OSM avec imposm3
#
# setup create_db
# setup import_db
# setup update_pbf
GITDIR=/srv/data/style-osm-geopicardie
GITBRANCH=imposm3-mapping
MYPGDIR=/var/lib/postgresql/9.5
DATADIR=/srv/data
PBF=$DATADIR/data.osm.pbf
STATUS=$DATADIR/etat
REPOSITORY=https://github.com/bchartier/style-osm-geopicardie
#TODO ajouter le git clone
no_start_db=0
start_db=1
function import_db_osm {
START_DB=$1
/etc/init.d/postgresql start
if [ ! -d $GITDIR ]; then
git clone $REPOSITORY $GITDIR
fi
cd $GITDIR; git checkout $GITBRANCH
if [ ! -f $GITDIR/imposm/imposm3-mapping.json ]; then
echo "ERR pas de mapping" 1>&2
exit 1
else
echo "OK trouvé fichier de mapping" 1>&2
fi
if [ ! -f $PBF ]; then
wget -O $PBF $OSM_PBF
fi
echo "Lance imposm" 1>&2
TMPDIR="$(dirname $PBF)/tmp_$(hostname)/"
mkdir -p $TMPDIR
/tmp/bin/imposm3 import \
-connection postgis://osm:osm@localhost/osm \
-mapping $GITDIR/imposm/imposm3-mapping.json \
-read $PBF \
-write \
-overwritecache \
-deployproduction \
-cachedir $TMPDIR
cd $GITDIR/post_imposm;
if [[ $START_DB == $start_db ]]; then
export PGPASSFILE=/tmp/pg_pass
echo "$(hostname):5432:osm:osm:osm" > $PGPASSFILE
chmod 0600 $PGPASSFILE
psql -w -h $(hostname) -p 5432 osm osm -f 0_run_all_post_install_scripts.sql
rm $PGPASSFILE
/etc/init.d/postgresql stop
fi
}
if [ ! -f $STATUS ]; then
echo "pret" > $STATUS
fi
case "$1" in
create_db)
echo "create_db" > $STATUS
if [ -d $MYPGDIR/main ]; then
echo "la base existe déjà" 1>&2
exit 0;
else
chown postgres /var/lib/postgresql
su postgres -c /usr/local/bin/install_db
import_db_osm $start_db
fi
echo "pret" > $STATUS
;;
import_db)
echo "import" > $STATUS
import_db_osm $no_start_db
echo "pret" > $STATUS
;;
update_db)
echo "import" > $STATUS
rm $PBF
wget -O $PBF $OSM_PBF
import_db_osm $no_start_db
echo "pret" > $STATUS
;;
esac