Skip to content

Commit

Permalink
Add support for FIND3 and remove FIND (#1059)
Browse files Browse the repository at this point in the history
Fixes #632

Signed-off-by: Ethan Dye <[email protected]>

Co-authored-by: Ethan Dye <[email protected]>
  • Loading branch information
mstormi and ecdye authored Jul 28, 2020
1 parent fc4e8e0 commit fdc243a
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 57 deletions.
274 changes: 274 additions & 0 deletions functions/find.bash

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions functions/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ get_public_ip() {
fi
}

## Enable or disable the RPi WiFi module
## Valid arguments: "enable" or "disable"
##
## enable_disable_wifi(String option)
##
enable_disable_wifi() {
if ! is_pi; then return 0; fi

if [[ $1 == "enable" ]]; then
echo -n "$(timestamp) [openHABian] Enabling WiFi... "
if grep -qsE "^[[:space:]]*dtoverlay=(pi3-)?disable-wifi" /boot/config.txt; then
if sed -i -E '/^[[:space:]]*dtoverlay=(pi3-)?disable-wifi/d' /boot/config.txt; then echo "OK (Reboot needed)"; else echo "FAILED"; return 1; fi
else
echo "OK"
fi
elif [[ $1 == "disable" ]]; then
echo -n "$(timestamp) [openHABian] Disabling WiFi... "
if ! grep -qsE "^[[:space:]]*dtoverlay=(pi3-)?disable-wifi" /boot/config.txt; then
if echo "dtoverlay=disable-wifi" >> /boot/config.txt; then echo "OK (Reboot needed)"; else echo "FAILED"; return 1; fi
else
echo "OK"
fi
fi
}

# fingerprinting based on
# https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
is_pizero() {
Expand Down
6 changes: 5 additions & 1 deletion functions/menu.bash
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ show_main_menu() {
esac

elif [[ "$choice" == "20"* ]]; then
choice2=$(whiptail --title "Welcome to the openHABian Configuration Tool $(get_git_revision)" --menu "Setup Options" 18 116 11 --cancel-button Back --ok-button Execute \
choice2=$(whiptail --title "Welcome to the openHABian Configuration Tool $(get_git_revision)" --menu "Setup Options" 20 116 13 --cancel-button Back --ok-button Execute \
"21 | Log Viewer" "openHAB Log Viewer webapp (frontail)" \
"22 | miflora-mqtt-daemon" "Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon" \
"23 | Mosquitto" "MQTT broker Eclipse Mosquitto" \
Expand All @@ -95,6 +95,8 @@ show_main_menu() {
"27 | knxd" "KNX specific, the KNX router/gateway daemon knxd" \
"28 | 1wire" "1wire specific, owserver and related packages" \
"29 | FIND" "Framework for Internal Navigation and Discovery" \
" | FIND3" "Framework for Internal Navigation and Discovery (ALPHA)" \
" | Monitor Mode" "Patch firmware to enable monitor mode (ALPHA/DANGEROUS)" \
"2A | Telldus Core" "Telldus Core service for Tellstick USB devices" \
"2B | Mail Transfer Agent" "Install Exim4 as MTA to relay mails via public services" \
3>&1 1>&2 2>&3)
Expand All @@ -110,6 +112,8 @@ show_main_menu() {
27\ *) knxd_setup ;;
28\ *) 1wire_setup ;;
29\ *) find_setup ;;
*FIND3) find3_setup ;;
*Monitor\ Mode) setup_monitor_mode ;;
2A\ *) telldus_core_setup ;;
2B\ *) exim_setup ;;
"") return 0 ;;
Expand Down
8 changes: 4 additions & 4 deletions functions/openhab.bash
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ dashboard_add_tile() {
application="$1"
openhabConfig="/etc/openhab2"
dashboardConfig="${openhabConfig}/services/dashboard.cfg"
tileDesc="$(grep "^[[:space:]]*tile_desc_${application}" "${BASEDIR:-/opt/openhabian}"/includes/dashboard-imagedata.sh | sed 's|tile_desc_'"${application}"'=||g; s|"||g')"
tileImg="$(grep "^[[:space:]]*tile_imagedata_${application}" "${BASEDIR:-/opt/openhabian}"/includes/dashboard-imagedata.sh | sed 's|tile_imagedata_'"${application}"'=||g; s|"||g')"
tileURL="$(grep "^[[:space:]]*tile_url_${application}" "${BASEDIR:-/opt/openhabian}"/includes/dashboard-imagedata.sh | sed 's|tile_url_'"${application}"'=||g; s|"||g')"
tileDesc="$(grep "^[[:space:]]*tile_desc_${application}" "${BASEDIR:-/opt/openhabian}"/includes/dashboard-imagedata | sed 's|tile_desc_'"${application}"'=||g; s|"||g')"
tileImg="$(grep "^[[:space:]]*tile_imagedata_${application}" "${BASEDIR:-/opt/openhabian}"/includes/dashboard-imagedata | sed 's|tile_imagedata_'"${application}"'=||g; s|"||g')"
tileURL="$(grep "^[[:space:]]*tile_url_${application}" "${BASEDIR:-/opt/openhabian}"/includes/dashboard-imagedata | sed 's|tile_url_'"${application}"'=||g; s|"||g')"

echo -n "$(timestamp) [openHABian] Adding an openHAB dashboard tile for '${application}'... "

case $application in
grafana|frontail|nodered|find|openhabiandocs)
grafana|frontail|nodered|find|find3|openhabiandocs)
true ;;
*)
echo "FAILED (tile name not valid)"; return 1 ;;
Expand Down
4 changes: 4 additions & 0 deletions functions/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ find_setup() {
echo "$(timestamp) [openHABian] FIND setup must be run in interactive mode! Canceling FIND setup!"
return 0
fi
if [[ -f /etc/systemd/system/find3server.service ]]; then
echo "$(timestamp) [openHABian] FIND cannot be used with FIND3! Canceling FIND setup!"
return 0
fi

local brokertext
local FINDADMIN
Expand Down
33 changes: 4 additions & 29 deletions functions/wifi.bash
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
#!/usr/bin/env bash

## Enable or disable the RPi WiFi module
## Valid arguments: "enable" or "disable"
##
## enable_disable_wifi(String option)
##
enable_disable_wifi() {
if ! is_pi; then return 0; fi

if [[ $1 == "enable" ]]; then
echo -n "$(timestamp) [openHABian] Enabling WiFi... "
if grep -qsE "^[[:space:]]*dtoverlay=(pi3-)?disable-wifi" /boot/config.txt; then
if sed -i -E '/^[[:space:]]*dtoverlay=(pi3-)?disable-wifi/d' /boot/config.txt; then echo "OK (Reboot needed)"; else echo "FAILED"; return 1; fi
else
echo "OK"
fi
elif [[ $1 == "disable" ]]; then
echo -n "$(timestamp) [openHABian] Disabling WiFi... "
if ! grep -qsE "^[[:space:]]*dtoverlay=(pi3-)?disable-wifi" /boot/config.txt; then
if echo "dtoverlay=disable-wifi" >> /boot/config.txt; then echo "OK (Reboot needed)"; else echo "FAILED"; return 1; fi
else
echo "OK"
fi
fi
}

## Configure WiFi setup on current system
## Valid arguments: "setup" or "disable"
##
Expand Down Expand Up @@ -83,12 +58,12 @@ configure_wifi() {
if iwlist wlan0 scan |& grep -qs "Interface doesn't support scanning"; then
# WiFi might be blocked
rfkill unblock wifi
ifconfig wlan0 up
ip link set wlan0 up
if iwlist wlan0 scan |& grep -qs "Interface doesn't support scanning"; then
echo "FAILED"
echo -e "\\nI was not able to turn on the WiFi\\nHere is some more information:\\n"
rfkill list all
ifconfig
ip a
return 1
else
echo "OK"
Expand Down Expand Up @@ -123,8 +98,8 @@ configure_wifi() {
echo -e "\\nallow-hotplug wlan0\\niface wlan0 inet manual\\nwpa-roam /etc/wpa_supplicant/wpa_supplicant.conf\\niface default inet dhcp" >> /etc/network/interfaces
fi
if ! cond_redirect wpa_cli reconfigure; then echo "FAILED (reconfigure)"; return 1; fi
if ! cond_redirect ifconfig wlan0 down; then echo "FAILED (down)"; return 1; fi
if cond_redirect ifconfig wlan0 up; then echo "OK (reboot now)"; else echo "FAILED (up)"; return 1; fi
if ! cond_redirect ip link set wlan0 down; then echo "FAILED (down)"; return 1; fi
if cond_redirect ip link set wlan0 up; then echo "OK (reboot now)"; else echo "FAILED (up)"; return 1; fi

whiptail --title "Operation Successful!" --msgbox "Setup was successful. The credentials provided were not tested. Please reboot now." 7 80
elif [[ $1 == "disable" ]]; then
Expand Down
1 change: 1 addition & 0 deletions includes/90-wireless.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBSYSTEM=="ieee80211", ACTION=="add", KERNEL=="%KERNEL", RUN+="/sbin/iw phy %k interface add mon0 type monitor", RUN+="/sbin/ip link set mon0 up"
Loading

0 comments on commit fdc243a

Please sign in to comment.