-
Notifications
You must be signed in to change notification settings - Fork 9
/
Taskfile.yml
55 lines (48 loc) · 2.33 KB
/
Taskfile.yml
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
version: '2'
vars:
INSTALL_DIR: "{{env \"HOME\"}}/cmswww"
DATA_DIR: "{{env \"HOME\"}}/.cmswww/data/{{.NAME}}/cockroachdb/data"
# Name is used to give an identity for where to create persistent storage
# items, and has been set in this instance to the name of the network we
# connect to
NAME: testnet3
tasks:
dataload:
desc: Runs cmswwwdataload to fill out database with some sample data
cmds:
- cmswwwdataload --verbose --deletedata
init_cdb:
desc: Deletes (if necessary) and (re)creates database ready for use
cmds:
- task: quit_cdb
- task: reset_cdb
- rm -rf ~/.cmswww/data/{{.NAME}}/cockroachdb
- mkdir -p ~/.cmswww/data/{{.NAME}}/cockroachdb
- mkdir -p {{.INSTALL_DIR}}
- cockroach cert create-ca --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" --ca-key="{{.INSTALL_DIR}}/ca.key" --allow-ca-key-reuse
- cockroach cert create-client root --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" --ca-key="{{.INSTALL_DIR}}/ca.key"
- cockroach cert create-node localhost --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" --ca-key="{{.INSTALL_DIR}}/ca.key"
- task: start_cdb
- sleep 1
- cockroach user set cmswwwuser --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb"
- cockroach cert create-client cmswwwuser --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" --ca-key="{{.INSTALL_DIR}}/ca.key"
- cockroach sql --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" -e 'CREATE DATABASE cmswww'
- cockroach sql --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" -e 'GRANT ALL ON DATABASE cmswww TO cmswwwuser'
- cockroach sql --user=cmswwwuser --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" -e 'GRANT ALL ON DATABASE cmswww TO cmswwwuser'
start_cdb:
desc: Start database
cmds:
- cockroach start --background --store={{.DATA_DIR}} --host=localhost --http-host=localhost --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb" &
quit_cdb:
desc: Stops database
cmds:
- cmd: cockroach quit --certs-dir="$(echo ~)/.cmswww/data/{{.NAME}}/cockroachdb"
ignore_error: true
reset_cdb:
desc: Deletes database data from system
cmds:
- rm -rf {{.DATA_DIR}}
vendor:
desc: Vendor go modules
cmds:
- GO111MODULE=on go mod vendor