StamusNetworks / selks-scripts

SELKS scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade Error

xkill opened this issue · comments

commented

moloch_latest=$(curl https://api.github.com/repos/aol/moloch/tags -s |jq -r '.[0].name' | cut -c 2-)

Curl tries to parse the output of a redirect. Add -L to follow the redirect.

@@ -59,7 +59,7 @@
 /usr/bin/supervisorctl restart scirius 
 
 # Moloch upgrade
-moloch_latest=$(curl  https://api.github.com/repos/aol/moloch/tags  -s |jq -r '.[0].name' | cut -c 2-)
+moloch_latest=$(curl  https://api.github.com/repos/aol/moloch/tags -L -s |jq -r '.[0].name' | cut -c 2-)
 moloch_current=$(dpkg -l |grep moloch | awk '{print $3}')
 
 if dpkg --compare-versions ${moloch_latest} gt ${moloch_current} ; then

More details:

Without -L appears an error:

root@IDS-SELKS:~# curl  https://api.github.com/repos/aol/moloch/tags  -s |jq -r '.[0].name' | cut -c 2-
jq: error (at <stdin>:5): Cannot index object with number

Without -L the content:

root@IDS-SELKS:~# curl  https://api.github.com/repos/aol/moloch/tags  -s 
{
  "message": "Moved Permanently",
  "url": "https://api.github.com/repositories/4927517/tags",
  "documentation_url": "https://docs.github.com/v3/#http-redirects"
}

With -L to follow the redirect:

root@IDS-SELKS:~# curl  https://api.github.com/repos/aol/moloch/tags -L -s |jq -r '.[0].name' | cut -c 2-
2.7.0
root@IDS-SELKS:~# curl  https://api.github.com/repos/aol/moloch/tags -L -s 
[
  {
    "name": "v2.7.0",
    "zipball_url": "https://api.github.com/repos/arkime/arkime/zipball/v2.7.0",
    "tarball_url": "https://api.github.com/repos/arkime/arkime/tarball/v2.7.0",
[...]