From 6f96db42ace1ec2dae106d627ed652340fb4d2aa Mon Sep 17 00:00:00 2001 From: Moul Date: Sat, 20 Aug 2016 01:35:46 +0200 Subject: [PATCH] [enh] #14: automatically retrieve last version - retrive last version available for x64 or for armel architectures - upgrade enable set -u --- conf/upstream_version | 1 - scripts/install | 7 +++++-- scripts/upgrade | 14 ++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 conf/upstream_version diff --git a/conf/upstream_version b/conf/upstream_version deleted file mode 100644 index 9388ecb..0000000 --- a/conf/upstream_version +++ /dev/null @@ -1 +0,0 @@ -v0.30.0 diff --git a/scripts/install b/scripts/install index eeee9f6..083b75d 100755 --- a/scripts/install +++ b/scripts/install @@ -13,7 +13,6 @@ sync_port=$YNH_APP_ARG_SYNC_PORT salt=$YNH_APP_ARG_SALT password=$YNH_APP_ARG_PASSWORD admin=$YNH_APP_ARG_ADMIN -version=$(cat ../conf/upstream_version) # Source app helpers source /usr/share/yunohost/helpers @@ -60,8 +59,12 @@ ynh_app_setting_set $app port $port ynh_app_setting_set $app arch $arch ynh_app_setting_set "$app" admin "$admin" +# Retrieve url of last version and version number +url=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | head -1 | cut -d\" -f4) +version=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | head -1 | cut -d/ -f8) + # Retrieve debian package and install it -wget -nc --quiet https://github.com/duniter/duniter/releases/download/$version/duniter-$version-linux-$arch.deb -P /tmp +wget -nc --quiet $url -P /tmp sudo dpkg -i /tmp/duniter-$version-linux-$arch.deb #sudo rm -f /tmp/duniter-$version-linux-$arch.deb diff --git a/scripts/upgrade b/scripts/upgrade index 6d8f2a3..524b9fe 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,8 +1,7 @@ #!/bin/bash # Exit on command errors and treat unset variables as an error -set -e -#u +set -eu # Source app helpers source /usr/share/yunohost/helpers @@ -14,7 +13,6 @@ path=$(ynh_app_setting_get "$app" path) port=$(ynh_app_setting_get "$app" port) arch=$(ynh_app_setting_get "$app" arch) admin=$(ynh_app_setting_get "$app" admin) -version=$(cat ../conf/upstream_version) # Check CPU arch if [[ $arch != "x64" && $arch != "armv7l" ]]; then @@ -27,10 +25,14 @@ sudo $app stop # Remove Duniter package sudo dpkg -r duniter -# Retrive Duniter package and install it -wget -nc --quiet https://github.com/duniter/duniter/releases/download/$version/duniter-$version-linux-$arch.deb -P /tmp +# Retrieve url of latest version and number +url=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | head -1 | cut -d\" -f4) +version=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | head -1 | cut -d/ -f8) + +# Retrieve Debian package and install it +wget -nc --quiet $url -P /tmp sudo dpkg -i /tmp/duniter-$version-linux-$arch.deb -#sudo rm -f /tmp/duniter-$version-linux-$arch.deb +sudo rm -f /tmp/duniter-$version-linux-$arch.deb # Start duniter daemon sudo $app webstart