Created
May 5, 2019 05:34
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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