Back How to upgrade Looker via bash

May 24

Cherre uses looker as part of its services.

Gripes first:

  • We’re still frustrated that Looker does not support docker. Which means we can not run it on Kubernetes. We’ve made some valiant attempts, several requests, but it seems like looker have something against docker. Brave warriors tried before us.
  • Looker are trying to tightly control their binary. Probably because they have no other mechanism to police licensing (why not use a license file?). I first moaned about it here.

For this reason, Looker came up with an awkward solution.

An API to give you the URL which will give you URL to the binary.

Assumptions:

  • You host your own looker server, using a standard setup. specifically, your looker folder is /home/looker/looker.
  • You made a backup of your machine, and you know what you’re doing. The author takes no responsibility.
  • You’re running in a linux environment. If you’re not, you might want to tweak the link. you have curl, jq and off course, bash.

In this case, you can copy the script below and save it as some file, for example upgrade.sh

  1. before you run this script, run sudo su — looker
  2. You can then run it by typing bash upgrade.sh

#!/bin/bash
set -euo pipefail

# this script will download looker
# you might want to move the following variables outside the script

EMAIL=your@email.com
LICENSE=123456789_YOUR_LOOKER_LICENSE_1234567989

echo "INFO: 'sudo su - looker' must be run before this script"
cd /home/looker/looker

#call API in order to obtain the URL and MD5

CURL_RESPONSE=$(curl --silent -X POST -H 'Content-Type: application/json' -d '{"lic": "B5E5D289DBC2EA58C530", "email": "
your@email.com", "latest":"latest"}' https:$

URL_TO_DOWNLOAD=$(echo $CURL_RESPONSE| jq -r '.url')
MD5SUM_EXPECTED=$(echo $CURL_RESPONSE| jq -r '.md5')
curl -o looker-latest.jar $URL_TO_DOWNLOAD
#validate file

echo "$MD5SUM_EXPECTED looker-latest.jar" |md5sum -c -

#should return 'looker-latest.jar: OK'
#show downloaded version
LOOKER_PREUPGRADE_VERSION=$(java -jar looker.jar version)
echo "looker version before upgrade $LOOKER_PREUPGRADE_VERSION"
LOOKER_NEW_VERSION=$(java -jar looker-latest.jar version)
echo "looker version after upgrade will be $LOOKER_NEW_VERSION"

echo "looker will now be stopped"
/home/looker/looker stop

echo "looker files will now be swapped"
mv -v looker.jar looker-$LOOKER_PREUPGRADE_VERSION.jar
mv -v looker-latest.jar looker.jar

echo "looker will now be started"
/home/looker/looker start

-Ben

No comments