New step "updatecheck" to check if a new version is available

This commit is contained in:
2020-09-30 21:48:19 +02:00
parent 5aba72ee49
commit d714c6b7f9

View File

@@ -19,6 +19,28 @@ step_config() {
fi
}
step_18_info() { echo "Check for updates"; }
step_18_alias() { ALIAS="updatecheck"; }
step_18() {
shift
local latestVersion=
if [ ! -z $1 ] ; then
latestVersion="$1"
else
latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
fi
local isInstalled=$(grep -E "${latestVersion}" "${ELEMENT_WEB_LOC}/version" >>/dev/null && echo "1" || echo "0")
if [ $isInstalled -eq 1 ] ; then
echo " [I] Version $latestVersion is already installed"
return 1
else
echo " [I] Update to $latestVersion available"
fi
return 0
}
step_20_info() {
echo -n "Create a backup [ELEMENT WEB ROOT]"
if [ $CONFIG -ne 0 ] ; then