Skip to content

Commit

Permalink
limit the update-check.cgi to parse for cmd=download and not parse ar…
Browse files Browse the repository at this point in the history
…bitrary query string options.
  • Loading branch information
jens-maus committed Jun 18, 2022
1 parent 5766ab1 commit 167b5ae
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 33 deletions.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.5.8+4
4 changes: 2 additions & 2 deletions addon_files/mosquitto/rc.d/mosquitto
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ case "$1" in
info)
echo "Info: <center><a href=\"https://mosquitto.org/\" target=\"_blank\"><img width=\"240\" src="/addons/mosquitto/mosquitto-text-side-28.png"></a></center>"
echo "Name: Mosquitto"
echo "Version: 1.5.8+3"
echo "Update: /addons/mosquitto/update_check.cgi"
echo "Version: $(cat ${ADDON_DIR}/VERSION)"
echo "Update: /addons/mosquitto/update-check.cgi"
echo "Operations: uninstall restart"
;;

Expand Down
30 changes: 30 additions & 0 deletions addon_files/mosquitto/www/update-check.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/tclsh

set checkURL "https://raw.githubusercontent.com/homematic-community/ccu-addon-mosquitto/master/VERSION"
set downloadURL "https://github.com/homematic-community/ccu-addon-mosquitto/releases/latest"

catch {
set input $env(QUERY_STRING)
set pairs [split $input &]
foreach pair $pairs {
if {$pair == "cmd=download"} {
set cmd "download"
break
}
}
}

if { [info exists cmd ] && $cmd == "download"} {
puts -nonewline "Content-Type: text/html; charset=utf-8\r\n\r\n"
puts -nonewline "<html><head><meta http-equiv='refresh' content='0; url=$downloadURL' /></head><body></body></html>"
} else {
puts -nonewline "Content-Type: text/plain; charset=utf-8\r\n\r\n"
catch {
set newversion [ exec /usr/bin/wget -qO- --no-check-certificate $checkURL ]
}
if { [info exists newversion] } {
puts $newversion
} else {
puts "n/a"
}
}
27 changes: 0 additions & 27 deletions addon_files/mosquitto/www/update_check.cgi

This file was deleted.

9 changes: 5 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ BUILD_DIR=`cd ${0%/*} && pwd -P`
ADDON_FILES=$BUILD_DIR/addon_files
ADDON_TMP=$BUILD_DIR/addon_tmp

mkdir $ADDON_TMP 2> /dev/null || rm -r $ADDON_TMP/*
rm -rf $ADDON_TMP
mkdir $ADDON_TMP

echo "copying files to tmp dir..."
cp -r $ADDON_FILES/* $ADDON_TMP/
cp VERSION $ADDON_TMP/mosquitto/

cd $BUILD_DIR


ADDON_FILE=mosquitto-1.5.8+3.tar.gz
ADDON_FILE=mosquitto-$(cat VERSION).tar.gz
echo "compressing addon package $ADDON_FILE ..."

mkdir $BUILD_DIR/dist 2> /dev/null
cd $ADDON_TMP
cd $ADDON_TMP
if [[ "$OSTYPE" == "darwin"* ]]; then
if [[ -f /usr/local/bin/gtar ]]; then
gtar --exclude=.DS_Store --owner=root --group=root -czf $BUILD_DIR/dist/$ADDON_FILE *
Expand All @@ -29,5 +29,6 @@ else
tar --owner=root --group=root -czf $BUILD_DIR/dist/$ADDON_FILE *
fi
cd $BUILD_DIR
rm -r $ADDON_TMP

echo "done."

0 comments on commit 167b5ae

Please sign in to comment.