Skip to content
Snippets Groups Projects
Commit 960f988b authored by Cam Saül's avatar Cam Saül
Browse files

Merge pull request #435 from metabase/browse_to_setup_url

automatically open setup URL when installing metabase :heart_eyes_cat:
parents c8fd0002 cf88eb23
No related branches found
No related tags found
No related merge requests found
(ns metabase.core
(:gen-class)
(:require [clojure.tools.logging :as log]
[clojure.java.browse :refer [browse-url]]
[colorize.core :as color]
[medley.core :as medley]
[metabase.config :as config]
[metabase.db :as db]
......@@ -37,6 +39,23 @@
wrap-session ; reads in current HTTP session and sets :session/key
wrap-gzip)) ; GZIP response if client can handle it
(defn- -init-create-setup-token
"Create and set a new setup token, and open the setup URL on the user's system."
[]
(let [setup-token (setup/token-create)
hostname (or (config/config-str :mb-jetty-host) "localhost")
port (config/config-int :mb-jetty-port)
setup-url (str "http://"
(or hostname "localhost")
(when-not (= 80 port) (str ":" port))
"/setup/init/"
setup-token)]
(log/info (color/green "Please use the following url to setup your Metabase installation:\n\n"
setup-url
"\n\n"))
;; Attempt to browse URL on user's system; this will just fail silently if we can't do it
(browse-url setup-url)))
(defn init
"General application initialization function which should be run once at application startup."
......@@ -51,17 +70,7 @@
;; the test we are using is if there is at least 1 User in the database
(when-not (db/sel :one :fields [User :id])
(log/info "Looks like this is a new installation ... preparing setup wizard")
(let [setup-token (setup/token-create)
hostname (or (config/config-str :mb-jetty-host) "localhost")
port (config/config-int :mb-jetty-port)
setup-url (str "http://"
(or hostname "localhost")
(when-not (= 80 port) (str ":" port))
"/setup/init/"
setup-token)]
(log/info (str "Please use the following url to setup your Metabase installation:\n\n"
setup-url
"\n\n"))))
(-init-create-setup-token))
;; Now start the task runner
(task/start-task-runner!)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment