Hiding the Unifi OS nag screen

未关闭
#183 5 条评论 7 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
bash, docker

调研方向

从容器初始化路径和挂载的 /custom-cont-init.d/unifi-patch-upgrade-nag.sh 入口点开始,然后检查它所针对的 /usr/lib/unifi/webapps/ROOT/app-unifi/react/js/ bundle。将所提供脚本的行为与镜像启动流程进行比较。完成的标准是:预期 bundle 存在时隐藏升级提示,而缺失或已更改的 bundle 会被报告,且不会静默地成功。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Dockerfile
星标
1.2k
派生
96
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

linuxserver/docker-unifi-network-application 的其他 Issue

查看 linuxserver/docker-unifi-network-application 的全部 Issue

相似的 Issue

更多 DevOps Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。