Skip to content

Commit

Permalink
reorganize directory structure
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jun 8, 2018
1 parent d12e96e commit c4fffed
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export NO_UPDATE_NOTIFIER=true
RED_DIR=$ADDON_DIR/lib/node_modules/node-red
RED=$RED_DIR/red.js

SETTINGS=$ADDON_DIR/settings.js
SETTINGS=$ADDON_DIR/lib/settings.js

Stop () {
PSPID=`ps -o pid,comm,args | awk '{if($3 == "node-red" || $4 ~ /node-red/){print $1}}'`
Expand Down Expand Up @@ -68,18 +68,12 @@ case "$1" in

uninstall)
Stop
$ADDON_DIR/update_addon node-red
$ADDON_DIR/update_addon node-red-dashboard
$ADDON_DIR/bin/update_addon node-red
$ADDON_DIR/bin/update_addon node-red-dashboard
rm -r $ADDON_DIR
rm -r $WWW_DIR
rm $CONF_DIR/lighttpd/redmatic.conf
rm $CONF_DIR/rc.d/redmatic

# migration
if [ -f $CONF_DIR/addons/www/check_update_node_red.cgi ]; then
rm $CONF_DIR/addons/www/check_update_node_red.cgi
fi

;;

*)
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions addon_files/redmatic/etc/default-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"uiPort": 1880,
"uiHost": "127.0.0.1",
"flowFile": "flows.json",
"userDir": "/usr/local/addons/redmatic/var",
"httpRoot": "/addons/red",
"logging": {
"console": {
"level": "info",
"metrics": false,
"audit": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ url.redirect = ("^/addons/red$" => "/addons/red/")
$HTTP["url"] =~ "^/(addons/red/).*" {
proxy.server = ("/addons/red/" => (( "host" => "127.0.0.1", "port" => 1880 )))
proxy.header = ( "upgrade" => "enable")
server.errorfile-prefix = "/usr/local/addons/redmatic/lighttpd-error-"
server.errorfile-prefix = "/usr/local/addons/redmatic/www/lighttpd-error-"
}
4 changes: 4 additions & 0 deletions addon_files/redmatic/lib/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = Object.assign(
require('/usr/local/addons/redmatic/lib/node_modules/node-red/settings.js'),
require('/usr/local/addons/redmatic/etc/settings.json')
);
237 changes: 0 additions & 237 deletions addon_files/redmatic/settings.js

This file was deleted.

2 changes: 1 addition & 1 deletion addon_files/update_addon
62 changes: 44 additions & 18 deletions addon_files/update_script
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ fi

mkdir -p $ADDONS_DIR && chmod 755 $ADDONS_DIR
mkdir -p $WWW_DIR && chmod 755 $WWW_DIR
mkdir -p $CONF_DIR/lighttpd && chmod 755 $CONF_DIR/lighttpd

#
# Stop service on update
#
if [ -f $CONF_DIR/rc.d/redmatic ]; then
$CONF_DIR/rc.d/redmatic stop
fi

if [ -f $RED_DIR/settings.js ]; then
cp $RED_DIR/settings.js $RED_DIR/settings.js.old
fi

#
# Install addon files
#
cp -af redmatic $ADDONS_DIR/


# migration
#
# Migration from <= 1.0.0-beta.7
#
if [ -d $ADDONS_DIR/node-red ]; then

if [ -f $CONF_DIR/rc.d/node-red ]; then
Expand All @@ -38,32 +42,54 @@ if [ -d $ADDONS_DIR/node-red ]; then
fi

cp $ADDONS_DIR/node-red/var/flows.json $RED_DIR/var/flows.json
cp $ADDONS_DIR/node-red/settings.js $RED_DIR/var/settings.js.old

rm -rf $ADDONS_DIR/node-red
fi

mkdir -p $CONF_DIR/lighttpd
ln -sf $RED_DIR/lighttpd.conf $CONF_DIR/lighttpd/redmatic.conf
#
# Migration from <= 1.0.0-beta.9
#
if [ -d $WWW_DIR ]; then
rm -rf $WWW_DIR
fi
if [ -f $RED_DIR/lighttpd-error-503.html ]; then
rm $RED_DIR/lighttpd-error-503.html
fi
if [ -f $RED_DIR/lighttpd.conf ]; then
rm $RED_DIR/lighttpd.conf
fi
if [ -f $RED_DIR/logo-w-200.png ]; then
rm $RED_DIR/logo-w-200.png
fi

chmod a+x $RED_DIR/node-red
ln -sf $RED_DIR/redmatic $CONF_DIR/rc.d/redmatic

if [ ! -f $RED_DIR/var/flows.json ]; then
mv $RED_DIR/var/example-flows.json $RED_DIR/var/flows.json
#
# Create default config on first install
#
if [ ! -f $RED_DIR/etc/settings.json ]; then
mv $RED_DIR/etc/default-settings.json $RED_DIR/etc/settings.json
fi

if [ -d $WWW_DIR/redmatic ]; then
rm -rf $WWW_DIR/redmatic
#
# Create example flows on first install
#
if [ ! -f $RED_DIR/var/flows.json ]; then
mv $RED_DIR/var/example-flows.json $RED_DIR/var/flows.json
fi

ln -sf $RED_DIR/www $WWW_DIR/redmatic
#
# Create Links
#
ln -sf $RED_DIR/www $WWW_DIR
ln -sf $RED_DIR/bin/redmatic $CONF_DIR/rc.d/redmatic
ln -sf $RED_DIR/etc/lighttpd.conf $CONF_DIR/lighttpd/redmatic.conf

#
# Create Buttons in Homematic WebUI
#
touch $CONF_DIR/hm_addons.cfg

./update_addon node-red node-red.cfg
./update_addon node-red-dashboard node-red-dashboard.cfg

sync

exit 0

0 comments on commit c4fffed

Please sign in to comment.