Skip to content

Commit

Permalink
remove FIND v2 install code
Browse files Browse the repository at this point in the history
Signed_off_by: Markus Storm <markus.storm@gmx.net>
  • Loading branch information
mstormi authored Dec 27, 2020
1 parent 0564864 commit 2018068
Showing 1 changed file with 0 additions and 100 deletions.
100 changes: 0 additions & 100 deletions functions/packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -301,106 +301,6 @@ mqtt_setup() {
fi
}

## Function for installing FIND to allow for indoor localization of WiFi devices.
## This function can only be invoked in INTERACTIVE with userinterface.
##
## find_setup()
##
find_setup() {
if [[ -z $INTERACTIVE ]]; then
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="You've chosen to work with an external MQTT broker.\\n\\nPlease be aware that you might need to add authentication credentials. You can do so after the installation.\\n\\nConsult with the FIND documentation or the openHAB community for details."
local FINDADMIN
local FINDADMINPASS
local findArch
local findClient
local findDist="/var/lib/findserver"
local findPass1
local findPass2
local findRelease
local introText="Install and setup the FIND server system to allow for indoor localization of WiFi devices.\\n\\nPlease note that FIND will run together with an app that is only available on Android.\\n\\nThere is no iOS app available, for more information see: https://www.internalpositioning.com/faq/#can-i-use-an-iphone"
local mqttMissingText="FIND requires an MQTT broker to run, but Mosquitto could not be found on this system.\\n\\nYou can configure FIND to use any existing MQTT broker (in the next step) or you can go back and install Mosquitto from the openHABian menu.\\n\\nDo you want to continue with the FIND installation?"
local mqttPasswd="/etc/mosquitto/passwd"
local MQTTPORT
local MQTTSERVER
local successText="FIND setup was successful.\\n\\nSettings can be configured in '/etc/default/findserver'. Be sure to restart the service after.\\n\\nYou can obtain the FIND app for Android through the Play Store. There is no iOS app available, for more information see: https://www.internalpositioning.com/faq/#can-i-use-an-iphone\\n\\nCheck out your FIND server's dashboard at: http://${HOSTNAME}:8003\\n\\nFor further information: https://www.internalpositioning.com"
local temp

if ! dpkg -s 'libsvm-tools' &> /dev/null; then
echo -n "$(timestamp) [openHABian] Installing FIND required packages... "
if cond_redirect apt-get install --yes libsvm-tools; then echo "OK"; else echo "FAILED"; return 1; fi
fi

if is_arm; then
findArch="arm"
else
findArch="amd64"
fi
findRelease="https://github.com/schollz/find/releases/download/v2.4.1/find_2.4.1_linux_${findArch}.zip"
findClient="https://github.com/schollz/find/releases/download/v0.6client/fingerprint_0.6_linux_${findArch}.zip"
temp="$(mktemp -d "${TMPDIR:-/tmp}"/openhabian.XXXXX)"

echo "$(timestamp) [openHABian] Beginning setup of FIND, the Framework for Internal Navigation and Discovery... "

if ! [[ -f "/etc/mosquitto/mosquitto.conf" ]]; then
if ! (whiptail --title "Mosquitto not installed, continue?" --defaultno --yes-button "Continue" --no-button "Cancel" --yesno "$mqttMissingText" 13 80); then echo "CANCELED"; return 0; fi
fi

if (whiptail --title "FIND installation?" --yes-button "Continue" --no-button "Cancel" --yesno "$introText" 14 80); then echo "OK"; else echo "CANCELED"; return 0; fi

echo -n "$(timestamp) [openHABian] Configuring FIND... "
if ! MQTTSERVER="$(whiptail --title "FIND Setup" --inputbox "\\nPlease enter the hostname of the device your MQTT broker is running on:" 9 80 localhost 3>&1 1>&2 2>&3)"; then echo "CANCELED"; return 0; fi
if [[ $MQTTSERVER != "localhost" ]]; then
if ! (whiptail --title "MQTT Broker Notice" --yes-button "Continue" --no-button "Cancel" --yesno "$brokerText" 12 80); then echo "CANCELED"; return 0; fi
fi
if ! MQTTPORT="$(whiptail --title "FIND Setup" --inputbox "\\nPlease enter the port number the MQTT broker is listening on:" 9 80 1883 3>&1 1>&2 2>&3)"; then echo "CANCELED"; return 0; fi
if [[ -f $mqttPasswd ]]; then
if ! FINDADMIN="$(whiptail --title "findserver MQTT Setup" --inputbox "\\nEnter a username for FIND to connect with on your MQTT broker:" 9 80 find 3>&1 1>&2 2>&3)"; then echo "CANCELED"; return 0; fi
while [[ -z $FINDADMINPASS ]]; do
if ! findPass1="$(whiptail --title "findserver MQTT Setup" --passwordbox "\\nEnter a password for the FIND user on your MQTT broker:" 9 80 3>&1 1>&2 2>&3)"; then echo "CANCELED"; return 0; fi
if ! findPass2="$(whiptail --title "findserver MQTT Setup" --passwordbox "\\nPlease confirm the password for the FIND user on your MQTT broker:" 9 80 3>&1 1>&2 2>&3)"; then echo "CANCELED"; return 0; fi
if [[ $findPass1 == "$findPass2" ]] && [[ ${#findPass1} -ge 8 ]] && [[ ${#findPass2} -ge 8 ]]; then
FINDADMINPASS="$findPass1"
else
whiptail --title "findserver MQTT Setup" --msgbox "Password mismatched, blank, or less than 8 characters... Please try again!" 7 80
fi
done
if ! cond_redirect mosquitto_passwd -b "$mqttPasswd" "$FINDADMIN" "$FINDADMINPASS"; then echo "FAILED (mosquitto password)"; return 1; fi
if ! cond_redirect systemctl restart mosquitto.service; then echo "FAILED (restart service)"; return 1; fi
fi
echo "OK"

echo -n "$(timestamp) [openHABian] Installing FIND... "
if ! cond_redirect mkdir -p "$findDist"; then echo "FAILED (create directory)"; return 1; fi
if ! cond_redirect wget -qO "${temp}/find.zip" "$findRelease"; then echo "FAILED (fetch FIND)"; return 1; fi
if ! cond_redirect wget -qO "${temp}/client.zip" "$findClient"; then echo "FAILED (fetch client)"; return 1; fi
if ! cond_redirect unzip -qo "${temp}/find.zip" -d "$findDist"; then echo "FAILED (unzip FIND)"; return 1; fi
if ! cond_redirect unzip -qo "${temp}/client.zip" fingerprint -d "$findDist"; then echo "FAILED (unzip client)"; return 1; fi
if ! cond_redirect ln -sf "$findDist"/findserver /usr/sbin/findserver; then echo "FAILED (link findserver)"; return 1; fi
if ! cond_redirect ln -sf "$findDist"/fingerprint /usr/sbin/fingerprint; then echo "FAILED (link fingerprint)"; return 1; fi
if cond_redirect rm -rf "$temp"; then echo "OK"; else echo "FAILED"; return 1; fi

echo -n "$(timestamp) [openHABian] Setting up FIND service... "
if ! (sed -e 's|%MQTTSERVER|'"${MQTTSERVER}"'|g; s|%MQTTPORT|'"${MQTTPORT}"'|g; s|%FINDADMINPASS|'"${FINDADMINPASS}"'|g; s|%FINDADMIN|'"${FINDADMIN}"'|g; s|%FINDPORT|8003|g; s|%FINDSERVER|localhost|g' "${BASEDIR:-/opt/openhabian}"/includes/findserver.service > /etc/systemd/system/findserver.service); then echo "FAILED (service file creation)"; return 1; fi
if ! cond_redirect chmod 644 /etc/systemd/system/findserver.service; then echo "FAILED (permissions)"; return 1; fi
if ! (sed -e 's|%MQTTSERVER|'"${MQTTSERVER}"'|g; s|%MQTTPORT|'"${MQTTPORT}"'|g; s|%FINDADMINPASS|'"${FINDADMINPASS}"'|g; s|%FINDADMIN|'"${FINDADMIN}"'|g; s|%FINDPORT|8003|g; s|%FINDSERVER|localhost|g' "${BASEDIR:-/opt/openhabian}"/includes/findserver > /etc/default/findserver); then echo "FAILED (service configuration creation)"; return 1; fi
if ! cond_redirect systemctl -q daemon-reload &> /dev/null; then echo "FAILED (daemon-reload)"; return 1; fi
if cond_redirect systemctl enable --now findserver.service; then echo "OK"; else echo "FAILED (enable service)"; return 1; fi

whiptail --title "Operation Successful!" --msgbox "$successText" 15 80

if openhab_is_installed; then
dashboard_add_tile "find"
fi
}

## Function for installing kndx as your EIB/KNX IP gateway and router to support your KNX bus system.
## This function can be invoked either INTERACTIVE with userinterface or UNATTENDED.
##
Expand Down

0 comments on commit 2018068

Please sign in to comment.