-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdevtools
More file actions
executable file
·92 lines (77 loc) · 2.96 KB
/
devtools
File metadata and controls
executable file
·92 lines (77 loc) · 2.96 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
#!/bin/bash
case "$1" in
main-db)
if [ "$#" -eq 1 ]
then
sqlite3 ~/.local/share/btcmap/btcmap.db
else
sqlite3 ~/.local/share/btcmap/btcmap.db "$2"
fi
;;
image-db)
if [ "$#" -eq 1 ]
then
sqlite3 ~/.local/share/btcmap/btcmap.db
else
sqlite3 ~/.local/share/btcmap/btcmap.db "$2"
fi
;;
log-db)
if [ "$#" -eq 1 ]
then
sqlite3 ~/.local/share/btcmap/log.db
else
sqlite3 ~/.local/share/btcmap/log.db "$2"
fi
;;
fetch-db)
sqlite3_rsync -v --wal-only btcmap-api:.local/share/btcmap/btcmap.db ~/.local/share/btcmap/btcmap.db
sqlite3_rsync -v --wal-only btcmap-api:.local/share/btcmap/images.db ~/.local/share/btcmap/images.db
sqlite3_rsync -v --wal-only btcmap-api:.local/share/btcmap/log.db ~/.local/share/btcmap/log.db
;;
fetch-main-db)
sqlite3_rsync -v --wal-only btcmap-api:.local/share/btcmap/btcmap.db ~/.local/share/btcmap/btcmap.db
;;
fetch-image-db)
sqlite3_rsync -v --wal-only btcmap-api:.local/share/btcmap/images.db ~/.local/share/btcmap/images.db
;;
fetch-log-db)
sqlite3_rsync -v --wal-only btcmap-api:.local/share/btcmap/log.db ~/.local/share/btcmap/log.db
;;
deploy)
cargo test \
&& cargo build --release \
&& rsync -v --progress --stats target/release/btcmap-api btcmap-api:/usr/local/bin/btcmap-api \
&& ssh btcmap-api 'systemctl restart btcmap-api.service'
;;
gen-main-schema)
# Generate schema.sql from migrations using temporary SQLite database
rm -f /tmp/schema_gen.db
for f in $(ls -1 src/db/main/migrations/*.sql | sort -V); do
sqlite3 /tmp/schema_gen.db < "$f" 2>/dev/null
done
sqlite3 /tmp/schema_gen.db ".dump" > src/db/main/schema.sql
rm -f /tmp/schema_gen.db
;;
install-completions)
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ "$(id -u)" -ne 0 ]; then
echo "this command must be run as root (use sudo)" >&2
exit 1
fi
user_home=$(getent passwd "${SUDO_USER:-$USER}" | cut -d: -f6)
if [ ! -L /usr/local/bin/devtools ]; then
ln -s "$script_dir/devtools" /usr/local/bin/devtools
echo "created symlink: /usr/local/bin/devtools -> $script_dir/devtools"
else
echo "symlink already exists: /usr/local/bin/devtools"
fi
completion_dir="$user_home/.bash_completion.d"
mkdir -p "$completion_dir"
cp "$script_dir/devtools_completion.bash" "$completion_dir/devtools"
echo "installed completions to: $completion_dir/devtools"
echo ""
echo "add this to your ~/.bashrc to enable completions:"
echo " source $completion_dir/devtools"
;;
esac