Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node-Red - add support for node-red-contrib-generic-ble #70

Merged
merged 3 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .templates/nodered/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ node_selection=$(whiptail --title "Node-RED nodes" --checklist --separate-output
"node-red-contrib-alexa-local" " " "OFF" \
"node-red-contrib-heater-controller" " " "OFF" \
"node-red-contrib-deconz" " " "OFF" \
"node-red-contrib-generic-ble" " " "OFF" \
3>&1 1>&2 2>&3)

##echo "$check_selection"
Expand All @@ -51,6 +52,12 @@ sqliteflag=0

touch $nr_dfile
echo "FROM nodered/node-red:latest" >$nr_dfile

echo "USER root" >>$nr_dfile
echo "RUN apk update" >>$nr_dfile
echo "RUN apk upgrade" >>$nr_dfile
echo "RUN apk add --no-cache eudev-dev" >>$nr_dfile

#node red install script inspired from https://tech.scargill.net/the-script/
echo "RUN for addonnodes in \\" >>$nr_dfile
for checked in "${checked_nodes[@]}"; do
Expand Down
6 changes: 6 additions & 0 deletions .templates/nodered/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
- 1880:1880
volumes:
- ./volumes/nodered/data:/data
- /var/run/docker.sock:/var/run/docker.sock
- /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
devices:
- "/dev/ttyAMA0:/dev/ttyAMA0"
- "/dev/vcio:/dev/vcio"
- "/dev/gpiomem:/dev/gpiomem"
40 changes: 37 additions & 3 deletions menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare -a armhf_keys=(
"adminer"
"openhab"
"zigbee2mqtt"
"deconz"
"deconz"
"pihole"
"plex"
"tasmoadmin"
Expand Down Expand Up @@ -120,6 +120,18 @@ function command_exists() {
command -v "$@" > /dev/null 2>&1
}

function user_in_group()
{
# see if the group exists
grep -q "^$1:" /etc/group;

# sense that the group does not exist
if [ $? -ne 0 ]; then return 0; fi

# group exists - now check that the user is a member
groups | grep -q "\b$1\b"
}

function minimum_version_check() {
# minimum_version_check required_version current_major current_minor current_build
# minimum_version_check "1.2.3" 1 2 3
Expand Down Expand Up @@ -342,8 +354,29 @@ if command_exists docker; then
sudo apt upgrade docker docker-compose
fi
fi

requestRebootflag=0

for G in docker bluetooth ; do

if user_in_group $G ; then
echo "checked membership of $G group."
else
echo "user is NOT a member of the $G group. Setting it now."
sudo usermod -G $G -a $USER
requestRebootflag=1
fi

done

if [ $requestRebootflag = 1 ] ; then
if (whiptail --title "Restart Required" --yesno "It is recommended that you restart your device now. Select yes to do so now" 20 78); then
sudo reboot
fi
fi

else
echo "docker not installed"
echo "docker not installed - you must choose Install Docker"
fi

#---------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -371,7 +404,8 @@ case $mainmenu_selection in
else
echo "Install Docker"
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
sudo usermod -G docker -a $USER
sudo usermod -G bluetooth -a $USER
fi

if command_exists docker-compose; then
Expand Down