Skip to content

Hiding the Unifi OS nag screen #183

@drizuid

Description

@drizuid

If you are fully aware of the pending deprecation of unifi network application and the push to move to Unifi OS, you may want to hide the nag screen when you login. Here is how to do so in our container.

Source

note in the volumes section the mapped in script denoted with <-----

  unifi-network-application:
    <<: *lsioint
    image: lscr.io/linuxserver/unifi-network-application:latest
    container_name: unifi-network-application
    networks:
      - dznet
      - logging
    environment:
      <<: *lsio
      UNIFI_VERSION: 9.4.19
      MONGO_USER: ${UNIFIUSER}
      MONGO_PASS: ${UNIFIPASS}
      MONGO_HOST: mongo
      MONGO_PORT: 27017
      MONGO_DBNAME: unifi
      MONGO_AUTHSOURCE: admin
    labels:
      - diun.enable=true
    volumes:
      - ${CONFDIR}/unifi-network-application:/config
      - ${CONFDIR}/swag/etc:/swag-ssl
      - ${TIME}:${TIME}:ro
      - /srv/scripts/unifi-patch-upgrade-nag.sh:/custom-cont-init.d/unifi-patch-upgrade-nag.sh # <-----
    ports:
      - 3478:3478/udp
      - 10001:10001/udp
      - 8080:8080
      - 8081:8081
      - 8143:8443
      - 8843:8843
      - 8880:8880
      - 6789:6789

the script contents should be

#!/bin/bash
# Patch out the "Upgrade to UniFi OS Server" nag modal
# Mount as:
#   -v ./unifi-patch-upgrade-nag.sh:/custom-cont-init.d/unifi-patch-upgrade-nag.sh

set -eu

SWAI_FILE=$(find /usr/lib/unifi/webapps/ROOT/app-unifi/react/js/ -name 'swai.*.js' 2>/dev/null | head -1)

if [ -z "${SWAI_FILE:-}" ]; then
    echo "[patch] swai.js not found, skipping upgrade nag patch"
    exit 0
fi

# Already patched?
if grep -q 'return !1&&r?' "$SWAI_FILE"; then
    echo "[patch] Already patched"
    exit 0
fi

# Replace:
#   return n&&r?<any>.createElement(<any>.aF.Root
# with:
#   return !1&&r?<same>.createElement(<same>.aF.Root
#
# This avoids depending on minified symbol names like e/t and Ne/fe/he.
if sed -E -i \
    's/return n&&r\?([A-Za-z_$][A-Za-z0-9_$]*)\.createElement\(([A-Za-z_$][A-Za-z0-9_$]*)\.aF\.Root/return !1\&\&r?\1.createElement(\2.aF.Root/' \
    "$SWAI_FILE"; then

    if grep -q 'return !1&&r?' "$SWAI_FILE"; then
        echo "[patch] Upgrade to UniFi OS Server nag removed"
    else
        echo "[patch] Pattern not found, UniFi bundle changed"
        exit 1
    fi
else
    echo "[patch] sed failed"
    exit 1
fi

I have tested this in my own environment and it works perfectly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions