Skip to content

Commit

Permalink
Prompt user to remove frontail on openHAB 4.3+ (#1935)
Browse files Browse the repository at this point in the history
* Revert "Remove frontail by default (#1933)"

This reverts commit cc5489164816cac0c708029ca4b7fafb2cc4920f.

* Prompt user to remove frontail

Related #1933

* Update docs for deprecation of frontail

* Update wording in NEWS for clarity

---------

Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye authored Dec 20, 2024
1 parent 59956c7 commit 5cd34e8
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 54 deletions.
15 changes: 9 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ Hit tab to unselect buttons and scroll through the text using UP/DOWN or
PGUP/PGDN. All announcements are stored in `/opt/openhabian/docs/CHANGELOG.md`
for you to lookup.

## Frontail removed ## December 17, 2024
We have removed the frontail log-viewer package and deleted it from all
systems with openHAB 4.3 or later installed. As of openHAB 4.3 a log-viewer
is built in to openHAB, and frontail has serious security vulnerabilities
present and is no longer maintained. We apologize for any inconvenience
this may cause.
## Frontail removed ## December 18, 2024
We suggest removal of the frontail log-viewer package on all systems with
openHAB 4.3+. There is still an option to keep it or install it however it
is no longer supported and is provided as is. The reasoning for removal is
that frontail has serious security vulnerabilities present and is no longer
maintained.

openHAB 4.3 adds a new builtin logviewer. You can look forward to it
becoming even more capable over the coming months as it is refined as well.

## Legacy openHAB 2 support removed ## November 23, 2024
We have removed legacy support for the openHAB 2 systems. Please upgrade to
Expand Down
15 changes: 9 additions & 6 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Frontail removed ## December 17, 2024
We have removed the frontail log-viewer package and deleted it from all
systems with openHAB 4.3 or later installed. As of openHAB 4.3 a log-viewer
is built in to openHAB, and frontail has serious security vulnerabilities
present and is no longer maintained. We apologize for any inconvenience
this may cause.
## Frontail removed ## December 18, 2024
We suggest removal of the frontail log-viewer package on all systems with
openHAB 4.3+. There is still an option to keep it or install it however it
is no longer supported and is provided as is. The reasoning for removal is
that frontail has serious security vulnerabilities present and is no longer
maintained.

openHAB 4.3 adds a new builtin logviewer. You can look forward to it
becoming even more capable over the coming months as it is refined as well.

## Legacy openHAB 2 support removed ## November 23, 2024
We have removed legacy support for the openHAB 2 systems. Please upgrade to
Expand Down
1 change: 1 addition & 0 deletions docs/openhabian.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ In `openhabian.conf`, uncomment and complete the lines reading `hw=`, `hwarch=`
openHABian comes with a number of additional tools to quickly install and set up additional home automation related software.
You'll find all of these in the [openHABian Configuration Tool](#openhabian-configuration-tool), menu option 20.

- DEPRECATED [Frontail](https://github.com/mthenw/frontail) - openHAB Log Viewer accessible from [http://openhabian:9001](http://openhabian:9001) (only provided as is)
- [InfluxDB and Grafana](https://community.openhab.org/t/influxdb-grafana-persistence-and-graphing/13761/1) - persistence and graphing available from [http://openhabian:3000](http://openhabian:3000)
- [Eclipse Mosquitto](http://mosquitto.org) - Open Source MQTT v3.1/v3.1.1 Broker
- [Node-RED](https://nodered.org) - "Flow-based programming for the Internet of Things". Access at [http://openhabian:1880](http://openhabian:1880).
Expand Down
54 changes: 30 additions & 24 deletions functions/menu.bash
Original file line number Diff line number Diff line change
Expand Up @@ -112,43 +112,49 @@ show_main_menu() {

elif [[ "$choice" == "20"* ]]; then
choice2=$(whiptail --title "openHABian Configuration Tool — $(get_git_revision)" --menu "Optional Components" 24 118 16 --cancel-button Back --ok-button Execute \
"21 | miflora-mqtt-daemon" "Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon" \
"22 | Mosquitto" "MQTT broker Eclipse Mosquitto" \
"23 | InfluxDB+Grafana" "A powerful persistence and graphing solution" \
"24 | Node-RED" "Flow-based programming for the Internet of Things" \
"25 | Homegear" "Homematic specific, the CCU2 emulation software Homegear" \
"26 | knxd" "KNX specific, the KNX router/gateway daemon knxd" \
"27 | 1wire" "1wire specific, owserver and related packages" \
"28 | deCONZ" "deCONZ / Phoscon companion app for Conbee/Raspbee controller" \
"29 | Zigbee2MQTT" "Install or Update Zigbee2MQTT" \
"21 | Log Viewer" "[DEPRECATED] openHAB Log Viewer webapp (frontail)" \
" | Add log to viewer" "[DEPRECATED] Add a custom log to openHAB Log Viewer (frontail)" \
" | Remove log from viewer" "[DEPRECATED] Remove a custom log from openHAB Log Viewer (frontail)" \
"22 | miflora-mqtt-daemon" "Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon" \
"23 | Mosquitto" "MQTT broker Eclipse Mosquitto" \
"24 | InfluxDB+Grafana" "A powerful persistence and graphing solution" \
"25 | Node-RED" "Flow-based programming for the Internet of Things" \
"26 | Homegear" "Homematic specific, the CCU2 emulation software Homegear" \
"27 | knxd" "KNX specific, the KNX router/gateway daemon knxd" \
"28 | 1wire" "1wire specific, owserver and related packages" \
"29 | deCONZ" "deCONZ / Phoscon companion app for Conbee/Raspbee controller" \
"2A | Zigbee2MQTT" "Install or Update Zigbee2MQTT" \
" | Remove Zigbee2MQTT" "Remove Zigbee2MQTT from this system" \
"2A | FIND 3" "Framework for Internal Navigation and Discovery" \
"2B | FIND 3" "Framework for Internal Navigation and Discovery" \
" | Monitor Mode" "Patch firmware to enable monitor mode (ALPHA/DANGEROUS)" \
"2B | Install HABApp" "Python 3 integration and rule engine for openHAB" \
"2C | Install HABApp" "Python 3 integration and rule engine for openHAB" \
" | Remove HABApp" "Remove HABApp from this system" \
"2C | Install EVCC" "Deploy Electric Vehicle Charge Controller" \
"2D | Install EVCC" "Deploy Electric Vehicle Charge Controller" \
" | Remove EVCC" "Uninstall EVCC" \
" | Setup EVCC" "Setup EVCC from command line (German only)" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ] || [ $RET -eq 255 ]; then return 0; fi
wait_for_apt_to_finish_update
case "$choice2" in
21\ *) miflora_setup ;;
22\ *) mqtt_setup ;;
23\ *) influxdb_grafana_setup ;;
24\ *) nodered_setup ;;
25\ *) homegear_setup ;;
26\ *) knxd_setup ;;
27\ *) 1wire_setup ;;
28\ *) deconz_setup ;;
29\ *) zigbee2mqtt_setup "install";;
21\ *) frontail_setup;;
*Add\ log\ to\ viewer*) custom_frontail_log "add";;
*Remove\ log\ from\ viewer*) custom_frontail_log "remove";;
22\ *) miflora_setup ;;
23\ *) mqtt_setup ;;
24\ *) influxdb_grafana_setup ;;
25\ *) nodered_setup ;;
26\ *) homegear_setup ;;
27\ *) knxd_setup ;;
28\ *) 1wire_setup ;;
29\ *) deconz_setup ;;
2A\ *) zigbee2mqtt_setup "install";;
*Remove\ Zigbee2MQTT*) zigbee2mqtt_setup "remove";;
2A\ *) find3_setup ;;
2B\ *) find3_setup ;;
*Monitor\ Mode) setup_monitor_mode ;;
2B\ *) habapp_setup "install";;
2C\ *) habapp_setup "install";;
*Remove\ HABApp*) habapp_setup "remove";;
2C\ *) install_evcc "install";;
2D\ *) install_evcc "install";;
*Remove\ EVCC*) install_evcc "remove";;
*Setup\ EVCC*) setup_evcc;;
"") return 0 ;;
Expand Down
136 changes: 124 additions & 12 deletions functions/nodejs-apps.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# shellcheck disable=SC2181

## Function for installing NodeJS for Node-RED and other addons.
## Function for installing NodeJS for frontail and other addons.
##
## nodejs_setup()
##
Expand Down Expand Up @@ -54,32 +54,144 @@ nodejs_setup() {
fi
}

## Function for downloading frontail to current system
##
## frontail_download(String prefix)
##
frontail_download() {
echo -n "$(timestamp) [openHABian] Downloading frontail... "
if ! [[ -d "${1}/frontail" ]]; then
cond_echo "\\nFresh Installation... "
if cond_redirect git clone https://github.com/Interstellar0verdrive/frontail_AEM.git "${1}/frontail"; then echo "OK"; else echo "FAILED (git clone)"; return 1; fi
else
cond_echo "\\nUpdate... "
if cond_redirect update_git_repo "${1}/frontail" "master"; then echo "OK"; else echo "FAILED (update git repo)"; return 1; fi
fi
}

## Function for removing frontail as its insecure and not maintained.
##
## frontail_remove()
##
frontail_remove() {
local frontailBase
local frontailDir="/opt/frontail"
local removeText="Frontail is a log viewer that is not maintained and has security issues. As of openHAB 4.3 there is a built in log viewer which replaces it.\\n\\nWould you like to remove it from your system? If not, be aware that it is not recommended to use it and is no longer a supported feature of openHABian."

frontailBase="$(npm list -g | head -n 1)/node_modules/frontail"

if ! [[ $(openhab-cli info | grep "Version" | xargs | cut -d ' ' -f 2) =~ 4.[3-9]* ]]; then return 0; fi
if ! dpkg --compare-versions "$(sed -n 's/openhab-distro\s*: //p' /var/lib/openhab/etc/version.properties)" gt "4.3.0"; then return 0; fi
if [[ -z $INTERACTIVE ]]; then return 0; fi


if [[ -d $frontailBase ]] || [[ -d $frontailDir ]]; then
echo -n "$(timestamp) [openHABian] Removing openHAB Log Viewer frontail... "
if [[ $(systemctl is-active frontail.service) == "active" ]]; then
if ! cond_redirect systemctl stop frontail.service; then echo "FAILED (stop service)"; return 1; fi
if (whiptail --title "Frontail Removal" --yes-button "Remove" --no-button "Keep" --defaultyes --scrolltext --yesno "$removeText" 27 84); then
echo -n "$(timestamp) [openHABian] Removing openHAB Log Viewer frontail... "
if [[ $(systemctl is-active frontail.service) == "active" ]]; then
if ! cond_redirect systemctl stop frontail.service; then echo "FAILED (stop service)"; return 1; fi
fi
if ! cond_redirect systemctl disable frontail.service; then echo "FAILED (disable service)"; return 1; fi
cond_redirect npm uninstall -g frontail
rm -f /etc/systemd/system/frontail.service
rm -rf /var/log/frontail
rm -rf /opt/frontail

if grep -qs "frontail-link" "/etc/openhab/services/runtime.cfg"; then
cond_redirect sed -i -e "/frontail-link/d" "/etc/openhab/services/runtime.cfg"
fi
if cond_redirect systemctl -q daemon-reload; then echo "OK"; else echo "FAILED (daemon-reload)"; return 1; fi
fi
fi
}

## Function for installing frontail to enable the openHAB log viewer web application.
##
## frontail_setup()
##
frontail_setup() {
local frontailBase
local frontailUser="frontail"

if ! node_is_installed || is_armv6l; then
echo -n "$(timestamp) [openHABian] Installing Frontail prerequsites (NodeJS)... "
if cond_redirect nodejs_setup; then echo "OK"; else echo "FAILED"; return 1; fi
fi

frontailBase="$(npm list -g | head -n 1)/node_modules/frontail"

if ! (id -u ${frontailUser} &> /dev/null || cond_redirect useradd --groups "${username:-openhabian}",openhab -s /bin/bash -d /var/tmp ${frontailUser}); then echo "FAILED (adduser)"; return 1; fi

echo -n "$(timestamp) [openHABian] Installing openHAB Log Viewer (frontail)... "
if [[ -d $frontailBase ]]; then
cond_echo "Removing any old installations... "
cond_redirect npm uninstall -g frontail
rm -f /etc/systemd/system/frontail.service
rm -rf /var/log/frontail
rm -rf /opt/frontail
fi

if ! cond_redirect frontail_download "/opt"; then echo "FAILED (download)"; return 1; fi
cd /opt/frontail || (echo "FAILED (cd)"; return 1)
# npm arguments explained:
# --omit=dev ignores the dev dependencies (we do not require them for production usage)
# Do NOT catch exit 1 for npm audit fix, because it's thrown when a vulnerability can't be fixed. Happens when a fix requires an upgrade to a new major release with possible breaking changes.
cond_redirect npm audit fix --omit=dev
if ! cond_redirect npm update --audit=false --omit=dev; then echo "FAILED (update)"; return 1; fi
if cond_redirect npm install --global --audit=false --omit=dev; then echo "OK"; else echo "FAILED (install)"; return 1; fi

echo -n "$(timestamp) [openHABian] Setting up openHAB Log Viewer (frontail) service... "
if ! (sed -e "s|%FRONTAILBASE|${frontailBase}|g" "${BASEDIR:-/opt/openhabian}"/includes/frontail.service > /etc/systemd/system/frontail.service); then echo "FAILED (service file creation)"; return 1; fi
if ! cond_redirect chmod 644 /etc/systemd/system/frontail.service; then echo "FAILED (permissions)"; return 1; fi
if ! cond_redirect systemctl -q daemon-reload; then echo "FAILED (daemon-reload)"; return 1; fi
if ! cond_redirect systemctl enable --now frontail.service; then echo "FAILED (enable service)"; return 1; fi
if cond_redirect systemctl restart frontail.service; then echo "OK"; else echo "FAILED (restart service)"; return 1; fi # Restart the service to make the change visible

if openhab_is_installed; then
dashboard_add_tile "frontail"
fi
}

if grep -qs "frontail-link" "/etc/openhab/services/runtime.cfg"; then
cond_redirect sed -i -e "/^frontail-link-*$/d" "/etc/openhab/services/runtime.cfg"
## Function for adding/removing a user specifed log to/from frontail
##
## custom_frontail_log()
##
custom_frontail_log() {
local frontailService="/etc/systemd/system/frontail.service"
local addLog
local removeLog
local array

if ! [[ -f $frontailService ]]; then
if [[ -n $INTERACTIVE ]]; then whiptail --title "Frontail not installed" --msgbox "Frontail is not installed!\\n\\nCanceling operation!" 9 80; fi
return 0
fi

if [[ $1 == "add" ]]; then
if [[ -n $INTERACTIVE ]]; then
if ! addLog="$(whiptail --title "Enter file path" --inputbox "\\nEnter the path to the logfile that you would like to add to frontail:" 9 80 3>&1 1>&2 2>&3)"; then echo "CANCELED"; return 0; fi
else
if [[ -n $2 ]]; then addLog="$2"; else return 0; fi
fi
if cond_redirect systemctl -q daemon-reload; then echo "OK"; else echo "FAILED (daemon-reload)"; return 1; fi

for log in "${addLog[@]}"; do
if [[ -f $log ]]; then
echo -n "$(timestamp) [openHABian] Adding '${log}' to frontail... "
if ! cond_redirect sed -i -e "/^ExecStart/ s|$| ${log}|" "$frontailService"; then echo "FAILED (add log)"; return 1; fi
if ! cond_redirect systemctl -q daemon-reload; then echo "FAILED (daemon-reload)"; return 1; fi
if cond_redirect systemctl restart frontail.service; then echo "OK"; else echo "FAILED (restart service)"; return 1; fi
else
if [[ -n $INTERACTIVE ]]; then
whiptail --title "File does not exist" --msgbox "The specifed file path does not exist!\\n\\nCanceling operation!" 9 80
return 0
else
echo "$(timestamp) [openHABian] Adding '${log}' to frontail... FAILED (file does not exist)"
fi
fi
done
elif [[ $1 == "remove" ]] && [[ -n $INTERACTIVE ]]; then
readarray -t array < <(grep -e "^ExecStart.*$" "$frontailService" | awk '{for (i=12; i<=NF; i++) {printf "%s\n\n", $i}}')
((count=${#array[@]} + 6))
removeLog="$(whiptail --title "Select log to remove" --cancel-button Cancel --ok-button Select --menu "\\nPlease choose the log that you would like to remove from frontail:\\n" "$count" 80 0 "${array[@]}" 3>&1 1>&2 2>&3)"
if ! cond_redirect sed -i -e "s|${removeLog}||" -e '/^ExecStart/ s|[[:space:]]\+| |g' "$frontailService"; then echo "FAILED (remove log)"; return 1; fi
if ! cond_redirect systemctl -q daemon-reload; then echo "FAILED (daemon-reload)"; return 1; fi
if cond_redirect systemctl restart frontail.service; then echo "OK"; else echo "FAILED (restart service)"; return 1; fi
fi
}

Expand All @@ -97,7 +209,7 @@ nodered_setup() {
local temp

if ! node_is_installed || is_armv6l; then
echo -n "$(timestamp) [openHABian] Installing Node-RED prerequsites (NodeJS)... "
echo -n "$(timestamp) [openHABian] Installing Frontail prerequsites (NodeJS)... "
if cond_redirect nodejs_setup; then echo "OK"; else echo "FAILED"; return 1; fi
fi
if ! dpkg -s 'build-essential' &> /dev/null; then
Expand Down
17 changes: 17 additions & 0 deletions functions/nodejs-apps.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,27 @@ load helpers.bash

setup_file() {
export BASEDIR="${BATS_TEST_DIRNAME}/.."
mkdir -p /var/log/openhab
setfacl -R -m g::rwX /var/log/openhab
}

teardown_file() {
unset BASEDIR
systemctl kill frontail.service || true
}

@test "installation-frontail_install" {
echo -e "# ${COL_CYAN}$(timestamp) [openHABian] Frontail installation starting...${COL_DEF}" >&3
run frontail_setup 3>&-
if [ "$status" -ne 0 ]; then echo "$output" >&3; fi
[ "$status" -eq 0 ]
echo -e "# ${COL_GREEN}$(timestamp) [openHABian] Frontail installation successful.${COL_DEF}" >&3

echo -e "# ${COL_CYAN}$(timestamp) [openHABian] Checking if Frontail service is running...${COL_DEF}" >&3
run systemctl is-active --quiet frontail.service
if [ "$status" -ne 0 ]; then echo "$output" >&3; fi
[ "$status" -eq 0 ]
echo -e "# ${COL_GREEN}$(timestamp) [openHABian] Frontail service is running.${COL_DEF}" >&3
}

@test "installation-zigbee2mqtt_install" {
Expand Down
6 changes: 3 additions & 3 deletions functions/openhab.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# shellcheck disable=SC2154

## Generate systemd dependencies for zram and others to start together with OH
## Generate systemd dependencies for zram, Frontail and others to start together with OH
## This is done using /etc/systemd/system/openhab.service.d/override.conf
##
## create_systemd_dependencies()
Expand Down Expand Up @@ -243,7 +243,7 @@ openhab_misc() {
}

## Create a openHAB dashboard title and image for the input application.
## Valid arguments: "grafana", "nodered", "find", or "openhabiandocs"
## Valid arguments: "grafana", "frontail", "nodered", "find", or "openhabiandocs"
##
## dashboard_add_tile(String application)
##
Expand All @@ -267,7 +267,7 @@ dashboard_add_tile() {
echo -n "$(timestamp) [openHABian] Adding an openHAB dashboard tile for '${application}'... "

case $application in
grafana|nodered|find3|openhabiandocs)
grafana|frontail|nodered|find3|openhabiandocs)
true ;;
*)
echo "FAILED (tile name not valid)"; return 1 ;;
Expand Down
4 changes: 4 additions & 0 deletions includes/dashboard-imagedata

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions includes/frontail.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Frontail openHAB instance, reachable at http://%H:9001
Documentation=https://github.com/mthenw/frontail
After=openhab.service
PartOf=openhab.service

[Service]
Type=simple
ExecStart=%FRONTAILBASE/bin/frontail --disable-usage-stats --ui-highlight --ui-highlight-preset %FRONTAILBASE/preset/openhab_AEM.json --theme openhab_AEM --lines 2000 --number 200 /var/log/openhab/openhab.log /var/log/openhab/events.log
Restart=always
User=frontail
Group=openhab
Environment=PATH=/usr/local/bin:/usr/bin/
Environment=NODE_ENV=production
WorkingDirectory=/usr/bin/

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions includes/openhab-override.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Wants=homegear.service
Before=homegear.service
Wants=frontail.service homegear.service
Before=frontail.service homegear.service

[Service]
UMask=0002
Expand Down
2 changes: 1 addition & 1 deletion openhabian-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ else
zram_is_installed && init_zram_mounts "autoupdate" && echo "zram_reset=done" >> /etc/openhabian.conf # update zram to fix potential issues
jsscripting_npm_check "openhab"
jsscripting_npm_check "openhab_rules_tools"
#frontail_remove # remove old frontail service if present can be removed in future
frontail_remove
while show_main_menu; do
true
done
Expand Down

0 comments on commit 5cd34e8

Please sign in to comment.