-
Notifications
You must be signed in to change notification settings - Fork 25
/
setup-linux
executable file
·56 lines (50 loc) · 1.91 KB
/
setup-linux
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
#!/usr/bin/env node
var childProcess = require('child_process')
childProcess.execSync('npm run gen-env')
var connstring = ' -h 127.0.0.1 -p 5432 -U postgres -w '
console.log("Installing PostgreSQL...")
childProcess.execSync('docker-compose kill db')
childProcess.execSync('docker-compose rm -f db')
childProcess.execSync('docker-compose up -d db')
setTimeout(function() {
try {
childProcess.execSync('./wait-for-pg')
} catch (ex) {
console.fatal("postgres failed to start")
}
console.log("postgres started")
// no need to drop since database is clean on docker-compose up
// try {
// childProcess.execSync('dropdb'+connstring+'ground_control')
// } catch (ex) {
// console.warn("dropdb did not run. This is probably because the database does not already exist, which is fine.")
// }
try {
childProcess.execSync('createdb'+connstring+'ground_control')
} catch(ex) {
console.warn("createdb did not run. This is probably because the database already exists, which is fine.");
}
try {
childProcess.execSync('psql'+connstring+' -c "CREATE ROLE ground_control WITH LOGIN SUPERUSER;" -d ground_control')
} catch (ex) {
console.warn("ground_control role not created. This is probably because the role already exists, which is fine.");
}
try {
childProcess.execSync('psql'+connstring+' -c "CREATE EXTENSION postgis;" -d ground_control')
} catch (ex) {
console.fatal("Unable to install postgis extensions to database, aborting.");
}
try {
console.log("migrating schema...")
childProcess.execSync('npm run migrate')
} catch(ex) {
console.fatal("unable to migrate schema")
}
try {
console.log("seeding data...")
childProcess.execSync('npm run seed')
} catch(ex) {
console.fatal("unable to seed data")
}
console.log("Done!")
}, 20000)