Skip to content

Commit 27d2c5f

Browse files
committed
addon update check
1 parent 8793e52 commit 27d2c5f

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

addon_files/node-red/node-red

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ case "$1" in
6565
echo "Info: <ul><li><a href="https://github.com/hobbyquaker/ccu-addon-node-red">ccu-addon-node-red on Github</a></li></ul>"
6666
echo "Name: Node-RED"
6767
echo "Version: $ADDON_VERSION"
68+
echo "Update: /addons/check_update_node_red.cgi"
6869
echo "Operations: restart uninstall"
6970
;;
7071

@@ -75,6 +76,7 @@ case "$1" in
7576
rm $CONF_DIR/lighttpd/node-red.conf
7677
rm $CONF_DIR/rc.d/node-red
7778
rm /usr/local/bin/node-red-admin
79+
rm /usr/local/etc/config/addons/www/check_update_node_red.cgi
7880
;;
7981

8082
*)

addon_files/node-red/update_check.tcl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env tclsh
2+
3+
set checkURL "https://api.github.com/repos/hobbyquaker/ccu-addon-node-red/releases/latest"
4+
set downloadURL "https://github.com/hobbyquaker/ccu-addon-node-red/releases/latest"
5+
6+
catch {
7+
set input $env(QUERY_STRING)
8+
set pairs [split $input &]
9+
foreach pair $pairs {
10+
if {0 != [regexp "^(\[^=]*)=(.*)$" $pair dummy varname val]} {
11+
set $varname $val
12+
}
13+
}
14+
}
15+
16+
if { [info exists cmd ] && $cmd == "download"} {
17+
puts "<html><head><meta http-equiv='refresh' content='0; url=$downloadURL' /></head></html>"
18+
} else {
19+
catch {
20+
[regexp "tag_name\": \"v(\[0-9\]+\.\[0-9\]+\.\[0-9\]+)" [ exec /usr/bin/env wget -qO- --no-check-certificate $checkURL ] dummy newversion]
21+
}
22+
if { [info exists newversion] } {
23+
puts -nonewline $newversion
24+
} else {
25+
puts -nonewline "n/a"
26+
}
27+
}

addon_files/update_script

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ if [ ! -f $RED_DIR/var/flows.json ]; then
3333
mv $RED_DIR/var/example-flows.json $RED_DIR/var/flows.json
3434
fi
3535

36+
ln -s $RED_DIR/update_check.tcl /usr/local/etc/config/addons/www/check_update_node_red.cgi
37+
3638
touch $CONF_DIR/hm_addons.cfg
3739
sed -i '/node-red/d' $CONF_DIR/hm_addons.cfg
3840
x=$(tail -c 1 $CONF_DIR/hm_addons.cfg)

0 commit comments

Comments
 (0)