-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4202ceb
commit 9fb16df
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
project="DominikBi/LedAnimation" | ||
folder="/home/$(whoami)/.LedAnimation" | ||
txt="${folder}/version.txt" | ||
|
||
if [[ ! -e "${txt}" ]]; then | ||
mkdir -p "${folder}" | ||
touch "${txt}" | ||
fi | ||
|
||
rm -f "${folder}/bin.zip" | ||
|
||
current=$(cat ${txt}) | ||
echo "Currently installed version is: ${current:-No Version installed locally}" | ||
|
||
latest=$(curl -s "https://api.github.com/repos/${project}/releases/latest" \ | ||
| grep "tag_name" \ | ||
| cut -d : -f 2,3 \ | ||
| tr -d " " \ | ||
| tr -d "\"" \ | ||
| tr -d ",") | ||
if [[ "$latest" = "" ]]; then | ||
echo Failed fetching latest version | ||
elif [[ ${latest} != ${current} ]]; then | ||
echo "Latest version is ${latest}" | ||
if [[ "$current" = "" ]]; then | ||
echo "No local version installed! Installing version ${latest}" | ||
else | ||
echo "Upgrading to version ${latest}" | ||
fi | ||
url="https://api.github.com/repos/${project}/releases/tags/${latest}" | ||
echo "Downloading from ${url}..." | ||
binary=$(curl -s ${url} \ | ||
| grep "browser_download_url.*zip" \ | ||
| cut -d : -f 2,3 \ | ||
| tr -d " " \ | ||
| tr -d "\"") | ||
echo "Downloading binary from ${binary}..." | ||
if ! wget -q -P "${folder}" ${binary}; then | ||
echo "Download failed" | ||
exit 1 | ||
fi | ||
echo ${latest} >> ${txt} | ||
|
||
rm -fv "${folder}/app.jar" | ||
rm -rfv "${folder}/bin/" | ||
rm -rfv "${folder}/web/" | ||
|
||
echo "Unpacking archive..." | ||
unzip -uq -d ${folder} "${folder}/bin.zip" | ||
rm "${folder}/bin.zip" | ||
|
||
echo "Successfully installed version ${latest}" | ||
fi | ||
echo "Starting Java Application" | ||
java -Dmosaik.appname="LedAnimation" -jar "${folder}/app.jar" |