Skip to content

Commit fcc03fc

Browse files
authored
Merge pull request #32 from metabase/add-mb-download
Adds Dan's mb-download script
2 parents 051cfdf + 5c22871 commit fcc03fc

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,17 @@ This stack is to test how Metabase behaves in HA mode, so you'll have a configur
117117
HAProxy is configured to balance requests in a round-robin manner and it checks the health of the application (so you can also simulate a failure)
118118

119119
This will allow you to test how Metabase behaves when it scales horizontally, both on the FE (showing things like the process picker in the troubleshooting -> logs section) and on the backend (health checks, queues, settings, etc). All configs in the LB can be changed from the config in stacks/ha/config/haproxy.cfg
120+
121+
# Downloading Jars
122+
123+
`mb-download` will let you download a jar to a given path or straight into `$JARS`.
124+
125+
``` bash
126+
$ ./mb-download -h
127+
Usage: mb-download 0.42.2
128+
Usage: mb-download 1.45.2
129+
Usage: mb-download 1.45.2 ~/path/to/my/jars
130+
131+
protip: this script will read from $JARS, and use that as your jar directory.
132+
```
133+

mb-download

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bb
2+
3+
(require '[babashka.curl :as curl])
4+
(require '[clojure.java.io :as io])
5+
(require '[clojure.repl :refer [pst]])
6+
(require '[clojure.string :as str])
7+
8+
(defn url [version]
9+
(str "https://downloads.metabase.com"
10+
(when (str/starts-with? version "1") "/enterprise")
11+
"/v"
12+
version "/metabase.jar"))
13+
14+
15+
16+
(defn download [version dir]
17+
(io/copy
18+
(:body (curl/get (url version) {:as :stream}))
19+
(io/file (str dir "/" version ".jar"))))
20+
21+
(defn download-jar! [version dir]
22+
(try
23+
(println (str "Downloading from " (url version)))
24+
(download version dir)
25+
(println (str "Downloaded " version ".jar to " dir))
26+
(catch Exception e
27+
(println (str "Error downloading version " version))
28+
(pst e))))
29+
30+
(defn without-slash [s] (str/replace s #"/$" ""))
31+
32+
(defn main []
33+
(let [[version dir] *command-line-args*
34+
dir (some-> (or dir (System/getenv "JARS"))
35+
without-slash)]
36+
(if (or (nil? version)
37+
(nil? dir)
38+
(#{"help" "--help" "-h"} version))
39+
(do (println "Usage: mb-download 0.42.2")
40+
(println "Usage: mb-download 1.45.2")
41+
(println "Usage: mb-download 1.45.2 ~/path/to/my/jars")
42+
(println "")
43+
(println "protip: this script will read from $JARS, and use that as your jar directory."))
44+
(download-jar! version dir))))
45+
46+
(main)

0 commit comments

Comments
 (0)