diff --git a/addon_installer/etc/www/update-check.cgi b/addon_installer/etc/www/update-check.cgi index b1240f0..b774951 100644 --- a/addon_installer/etc/www/update-check.cgi +++ b/addon_installer/etc/www/update-check.cgi @@ -3,12 +3,27 @@ set version_url "https://raw.githubusercontent.com/thkl/hap-homematic/master/addon_installer/VERSION" set package_url "https://github.com/thkl/hap-homematic/releases/latest" -set cmd "" -if {[info exists env(QUERY_STRING)]} { - regexp {cmd=([^&]+)} $env(QUERY_STRING) match cmd +catch { + set input $env(QUERY_STRING) + set pairs [split $input &] + foreach pair $pairs { + if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} { + set $varname $val + } + } } -if {$cmd == "download"} { - puts "${package_url}" + +if { [info exists cmd ] && $cmd == "download"} { + puts -nonewline "Content-Type: text/html; charset=utf-8\r\n\r\n" + puts -nonewline "" } else { - puts [exec /usr/bin/wget -q --no-check-certificate -O- "${version_url}"] -} \ No newline at end of file + puts -nonewline "Content-Type: text/plain; charset=utf-8\r\n\r\n" + catch { + set newversion [ exec /usr/bin/wget -qO- --no-check-certificate $version_url ] + } + if { [info exists newversion] } { + puts $newversion + } else { + puts "n/a" + } +}