Last active
April 23, 2017 21:22
-
-
Save koter84/9a9f991e1c6c0609757abf2e9063282d to your computer and use it in GitHub Desktop.
updater for MQTTfx
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
#!/bin/bash | |
# get current dir | |
prog_dir="/opt/$(ls /opt/ | grep MQTTfx)" | |
echo "DIR: $prog_dir" | |
prog_dir_version=$(grep 'app\.version' /opt/MQTTfx/app/MQTTfx.cfg | sed s/app.version=//) | |
echo "DIR Version: $prog_dir_version" | |
# get current url | |
prog_url=$(curl -s http://mqttfx.jensd.de/index.php/download | sed 's/<a/\n<a/g' | grep '^<a' | grep Version | head -n1 | sed 's/.*http/http/g' | cut -d'"' -f1) | |
prog_url_extra=$(curl -s $prog_url/ | sed 's/<a/\n<a/g' | grep '^<a' | grep x86_64 | cut -d'"' -f2) | |
prog_url="$prog_url/$prog_url_extra" | |
echo "URL: $prog_url" | |
prog_url_version=$(echo $prog_url | awk -F/ '{print $(NF-1)}') | |
echo "URL Version: $prog_url_version" | |
# check that a current version is found | |
if [ "$prog_dir_version" == "" ] | |
then | |
echo "New Installation! (no old version found)" | |
new_install="1" | |
fi | |
# check that a new version and url are found | |
if [ "$prog_url" == "" ] || [ "$prog_url_version" == "" ] | |
then | |
echo "couldn't find url for new version" | |
exit | |
fi | |
# check current dir version with current url version | |
if [ "$prog_dir_version" != "$prog_url_version" ] | |
then | |
if [ "$new_install" != "1" ] | |
then | |
echo "New Version Found!" | |
fi | |
cd /tmp/ | |
# download | |
wget --quiet --show-progress -O mqttfx.rpm $prog_url | |
# upgrade/install rpm | |
if [ "$new_install" != "1" ] | |
then | |
sudo rpm --upgrade mqttfx.rpm | |
else | |
sudo rpm --install mqttfx.rpm | |
fi | |
# remove download | |
rm mqttfx.rpm | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment