forked from cockroachdb/sqlalchemy-cockroachdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcockroach_helper.sh
More file actions
executable file
·22 lines (20 loc) · 920 Bytes
/
cockroach_helper.sh
File metadata and controls
executable file
·22 lines (20 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
COCKROACHDB=cockroach-v23.1.13.linux-amd64
CROACHDB=~/.cache/$COCKROACHDB/cockroach
quit_cockroachdb() {
OLDPIDNS=$(ps -o pidns -C cockroach | awk 'NR==2 {print $0}')
if [ -n "$OLDPIDNS" ]; then
pkill --ns $$ $OLDPIDNS
fi
return 0
}
[ -n "$HOST" ] || HOST=localhost
mkdir -p $(dirname $CROACHDB)
[[ -f "$CROACHDB" ]] || wget -qO- https://binaries.cockroachdb.com/$COCKROACHDB.tgz | tar xvz --directory ~/.cache
if [ $1 == "start" ]; then
quit_cockroachdb
$CROACHDB start-single-node --background --insecure --store=type=mem,size=10% --log-dir /tmp/ --listen-addr=$HOST:26257 --http-addr=$HOST:26301
#$CROACHDB sql --host=$HOST:26257 --insecure -e "set sql_safe_updates=false; drop database if exists apibuilder; create database if not exists apibuilder; create user if not exists apibuilder; grant all on database apibuilder to apibuilder;"
else
quit_cockroachdb
fi