From 77e4294e8bad5d4608c4fac20d0c2429052e79fa Mon Sep 17 00:00:00 2001 From: David Lutz Date: Thu, 18 Jul 2024 09:49:17 +0200 Subject: [PATCH] ff3l-badblocks-disable-autoupdater: init --- ff3l-badblocks-disable-autoupdater/Makefile | 31 +++++++++++++++++++ ff3l-badblocks-disable-autoupdater/README.md | 7 +++++ .../upgrade/590-badblocks-disable-autoupdater | 17 ++++++++++ 3 files changed, 55 insertions(+) create mode 100644 ff3l-badblocks-disable-autoupdater/Makefile create mode 100644 ff3l-badblocks-disable-autoupdater/README.md create mode 100755 ff3l-badblocks-disable-autoupdater/luasrc/lib/gluon/upgrade/590-badblocks-disable-autoupdater diff --git a/ff3l-badblocks-disable-autoupdater/Makefile b/ff3l-badblocks-disable-autoupdater/Makefile new file mode 100644 index 00000000..0046f94b --- /dev/null +++ b/ff3l-badblocks-disable-autoupdater/Makefile @@ -0,0 +1,31 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ff3l-badblocks-disable-autoupdater +PKG_VERSION:=1 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include ../../../package/gluon.mk + +define Package/ff3l-badblocks-disable-autoupdater + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=Disable autoupdater if device has bad eraseblocks +endef + +define Build/Prepare + mkdir -p $(PKG_BUILD_DIR) +endef + +define Build/Configure +endef + +define Build/Compile + $(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/) +endef + +define Package/ff3l-badblocks-disable-autoupdater/install + $(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/ +endef + +$(eval $(call BuildPackage,ff3l-badblocks-disable-autoupdater)) \ No newline at end of file diff --git a/ff3l-badblocks-disable-autoupdater/README.md b/ff3l-badblocks-disable-autoupdater/README.md new file mode 100644 index 00000000..6d0417d7 --- /dev/null +++ b/ff3l-badblocks-disable-autoupdater/README.md @@ -0,0 +1,7 @@ +ff3l-badblocks-disable-autoupdater +============= + +Transitional package to be used with last Gluon v2019.1.x release +Simply disables the autoupdater for UBNT ERX devices with bad eraseblocks in flash and prefixes the node's name with "#BADBLOCKS". +This mitigates the issue that these devices would get bricked by an update to Gluon v2020.1 or newer, where the handling of bad eraseblocks has been changed. + diff --git a/ff3l-badblocks-disable-autoupdater/luasrc/lib/gluon/upgrade/590-badblocks-disable-autoupdater b/ff3l-badblocks-disable-autoupdater/luasrc/lib/gluon/upgrade/590-badblocks-disable-autoupdater new file mode 100755 index 00000000..71790218 --- /dev/null +++ b/ff3l-badblocks-disable-autoupdater/luasrc/lib/gluon/upgrade/590-badblocks-disable-autoupdater @@ -0,0 +1,17 @@ +#!/usr/bin/lua +local uci = require('simple-uci').cursor() +local eraseblock = io.popen("dmesg|grep \"Bad eraseblock\""):read('*a') +local hostname = uci:get_first('system', 'system', 'hostname') +if (eraseblock ~= '') then + io.write('has badblocks, disabling autoupdater...\n') + uci:set('autoupdater', 'settings', 'enabled', '0') + uci:save('autoupdater') + if hostname:find('BADBLOCKS') then + io.write('already prefixed\n') + else + io.write('changing hostname to "#BADBLOCKS '..hostname..'"...\n') + io.popen('pretty-hostname "#BADBLOCKS '..hostname..'"') + end +else + io.write('no badblocks\n') +end