Skip to content

Instantly share code, notes, and snippets.

@che-wf
Created May 5, 2019 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save che-wf/3fd241f78fa4a802ec5fdb7e1da0d97d to your computer and use it in GitHub Desktop.
Save che-wf/3fd241f78fa4a802ec5fdb7e1da0d97d to your computer and use it in GitHub Desktop.
Bash script to update Mozilla Things Gateway for those who installed it by the package instead of by the image
#!/bin/bash
# fetch your URLs
answer=`curl -s https://api.github.com/repos/mozilla-iot/gateway/releases/latest | grep "browser_download_url.*tar.gz" | cut -d : -f 2,3 | tr -d \"`
# get download names
# main gateway directory
core_file=`echo "$answer" | grep -Eo '.+?\.tar\.gz' | head -n1 | tr -d " "`
node_modules_file=`echo "$answer" | grep -Eo '.+?\.tar\.gz' | head -n2 | tail -1 | tr -d " "`
# node_modules directory
core_file_name=`echo "$answer" | grep -Eo '[^/]+?\.tar\.gz' | head -n1 `
node_modules_file_name=`echo "$answer" | grep -Eo '[^/]+?\.tar\.gz' | head -n2 | tail -1`
# assuming you need to need to up a directory to your main directory
cd ..
# download, extract, and delete main directory
wget "$core_file"
tar -xzf "$core_file_name"
rm "$core_file_name"
# download, extract, and delete node_modules
cd "gateway"
wget "$node_modules_file"
tar -xzf "$node_modules_file_name"
rm "$node_modules_file_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment