Skip to content

Instantly share code, notes, and snippets.

@iethree
Created October 5, 2023 15:44
Show Gist options
  • Save iethree/157c50a7dbbf2ebd1a6db03c9c1a3968 to your computer and use it in GitHub Desktop.
Save iethree/157c50a7dbbf2ebd1a6db03c9c1a3968 to your computer and use it in GitHub Desktop.
Metabase jar helper

Metabase jar helper

Installation

you'll need to install google's zx command line tool and be running node 16 or later

npm i -g zx

Save this script in its own directory somewhere like

mb-jars/
  mb-jars.mjs

Then add an alias to your .zshrc or .bashrc or whatever

alias mb-jar="cd ~/projects/mb-jars && zx mb-jars.mjs"

Usage

Simply give it the version you want to run and it will download and run that jar

mb-jar 47.2

Will download and run the enterprise 47.2 jar on port 3472, and create a database for metabase v47

mb-jar 46.8 oss

Will download and run the oss 46.8 jar on port 3468, and create a database for metabase v46

const version = process.argv[3];
const edition = process.argv[4] === 'oss' ? 'oss' : 'ee';
const [major, minor] = version.split('.');
const jarName = `metabase-${edition}-${version}.jar`;
const fileExists = fs.existsSync(jarName);
if (!fileExists) {
console.log(chalk.blue(`Metabase ${edition} ${version} does not exist, downloading...`));
const downloadPath = edition === 'oss'
? `http://downloads.metabase.com/v0.${version}/metabase.jar`
: `http://downloads.metabase.com/enterprise/v1.${version}/metabase.jar`;
await $`curl -L -o ${jarName} ${downloadPath}`;
console.log(`Downloaded Metabase ${version}`);
}
const port = `3${major}${minor || 0}`;
console.log(chalk.blue(`Starting Metabase ${edition} ${version} on port ${port}`));
await $`MB_JETTY_PORT=${port} MB_DB_TYPE=h2 MB_DB_FILE=metabase-${major}.db java -jar ${jarName}`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment