Skip to content

Commit

Permalink
Fix downloading latest file for minecraft jargroup
Browse files Browse the repository at this point in the history
- Use 'jq' as json interpreter instead of grep regex
- Use latest package format
  • Loading branch information
pflueg committed Oct 1, 2018
1 parent 2f1796b commit dc29058
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions init/msm
Original file line number Diff line number Diff line change
Expand Up @@ -1110,13 +1110,13 @@ jargroup_getlatest() {
local versions_url="https://launchermeta.mojang.com/mc/game/version_manifest.json"
local versions_file="/tmp/minecraft_versions.json"
as_user "$SETTINGS_USERNAME" "wget --quiet $wget_opts --no-check-certificate -O '$versions_file' '$versions_url'"
local latest_package_url=$(as_user "$SETTINGS_USERNAME" "egrep -o "\""(\{[^}]*\\"\"type\\"\"\:\\"\"${versions_target}\\"\"[^}]*\})"\"" $versions_file | egrep -o -m1 'https\\:\\/\\/launchermeta\\.mojang\\.com[^\"]*'")
local latest_package_url=$(as_user "$SETTINGS_USERNAME" "cat $versions_file | jq -r '.versions | sort_by(.releaseTime) | map(select(.type | contains ("\""release"\""))) | last | .url'")
local latest_version=$(as_user "$SETTINGS_USERNAME" "echo ${latest_package_url##*/} | sed s/.json//")

if [[ -n "$latest_package_url" ]]; then
local package_file="/tmp/minecraft_package.json"
as_user "$SETTINGS_USERNAME" "wget --quiet $wget_opts --no-check-certificate -O '$package_file' '$latest_package_url'"
local jar_url=$(as_user "$SETTINGS_USERNAME" "egrep -o -m1 'https.*server\\.jar' $package_file")
if [[ -n "$latest_package_url" ]]; then
local package_file="/tmp/minecraft_package.json"
as_user "$SETTINGS_USERNAME" "wget --quiet $wget_opts --no-check-certificate -O '$package_file' '$latest_package_url'"
local jar_url=$(as_user "$SETTINGS_USERNAME" "cat $package_file | jq -r '.downloads.server.url'")
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion installers/arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function update_system_packages() {

function install_dependencies() {
install_log "Installing required packages"
sudo pacman --noconfirm -S screen rsync zip wget || install_error "Couldn't install dependencies"
sudo pacman --noconfirm -S screen rsync zip wget jq || install_error "Couldn't install dependencies"
}

function enable_init() {
Expand Down
4 changes: 3 additions & 1 deletion installers/debian.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

UPDATE_URL="https://raw.githubusercontent.com/msmhq/msm/master"
wget -q ${UPDATE_URL}/installers/common.sh -O /tmp/msmcommon.sh
source /tmp/msmcommon.sh && rm -f /tmp/msmcommon.sh
Expand All @@ -10,7 +12,7 @@ function update_system_packages() {

function install_dependencies() {
install_log "Installing required packages"
sudo apt-get install screen rsync zip || install_error "Couldn't install dependencies"
sudo apt-get install screen rsync zip jq || install_error "Couldn't install dependencies"
}

function enable_init() {
Expand Down
2 changes: 1 addition & 1 deletion installers/redhat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function update_system_packages() {

function install_dependencies() {
install_log "Installing required packages"
sudo yum install screen rsync zip java || install_error "Couldn't install dependencies"
sudo yum install screen rsync zip java jq || install_error "Couldn't install dependencies"
}

function enable_init() {
Expand Down

0 comments on commit dc29058

Please sign in to comment.