Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

hassbian-scripts: Added --beta to upgrade to prerelease. #151

Merged
merged 3 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/hassbian_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ $ sudo apt install -y ./hassbian*
$ sudo hassbian-config upgrade hassbian-script
```

## Upgrade to prerelease
```
$ sudo hassbian-config upgrade hassbian-script --beta
```

## Upgrade to dev branch
```
$ sudo hassbian-config upgrade hassbian-script --dev
Expand Down
25 changes: 21 additions & 4 deletions package/opt/hassbian/suites/hassbian-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,31 @@ else
cd /tmp || exit

echo "Downloading latest release"
curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi -
if [ "$BETA" == "true" ]; then
echo "Checking if there is an prerelease available..."
prerelease=$(curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases | grep '"prerelease": true')
if [ ! -z "${prerelease}" ]; then
echo "Prerelease found..."
curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases | grep "browser_download_url.*deb" | head -1 | cut -d : -f 2,3 | tr -d \" | wget -qi -
else
echo "Prerelease not found..."
echo "Downloading latest stable version..."
curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi -
fi
else
curl https://api.github.com/repos/home-assistant/hassbian-scripts/releases/latest | grep "browser_download_url.*deb" | cut -d : -f 2,3 | tr -d \" | wget -qi -
fi

# Setting package name
HASSBIAN_PACKAGE=$(echo hassbian*.deb)

echo "Installing latest release"
sudo apt install -y /tmp/"$HASSBIAN_PACKAGE"

downloadedversion=$(echo $HASSBIAN_PACKAGE | awk -F'_' '{print $2}' | cut -d . -f 1,2,3)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double quote to prevent globbing and word splitting.

currentversion=$(hassbian-config -V)
if [ "$currentversion" > "$downloadedversion" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Escape > to prevent it redirecting (or switch to [[ .. ]]).

apt install -y /tmp/"$HASSBIAN_PACKAGE" --allow-downgrades
else
apt install -y /tmp/"$HASSBIAN_PACKAGE" --reinstall
fi
echo "Cleanup"
rm "$HASSBIAN_PACKAGE"
fi
Expand Down