git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/erase-broken-modules
diff options
context:
space:
mode:
authormail_redacted_for_web 2022-03-24 17:37:10 +0100
committermail_redacted_for_web 2022-03-24 17:37:10 +0100
commitc58a64be77d4fe0640616851af294300d60233c4 (patch)
treeca6b38f3dae6a1a599076ae966f4bbb0a4f0fe3c /erase-broken-modules
downloadmikrotik-fixes-c58a64be77d4fe0640616851af294300d60233c4.tar.bz2
InComm, +wiper
Diffstat (limited to 'erase-broken-modules')
-rw-r--r--erase-broken-modules/README.md18
-rwxr-xr-xerase-broken-modules/wiper9
-rw-r--r--erase-broken-modules/wiper.rsc27
3 files changed, 54 insertions, 0 deletions
diff --git a/erase-broken-modules/README.md b/erase-broken-modules/README.md
new file mode 100644
index 0000000..32a993d
--- /dev/null
+++ b/erase-broken-modules/README.md
@@ -0,0 +1,18 @@
+# Scenario
+
+For whatever reason, you end up with a MikroTīk device with broken modules. Whatever you do, they
+will not disappear. Also, in my scenario – the user module was broken – one of two devices never applied
+any update, and the other even did not remember most changes.
+
+The solution is to:
+
+1. Uninstall all packages that can be uninstalled (except for system)
+1. Disable all packages that cannot be uninstalled (mostly because they are bundled)
+1. Place an update to the device's root
+1. Reboot
+
+You will then end up with an updated device, no other modules installed, and in 2/2 cases for me
+all setting were still present. Of course a backup prior to this is still highly recommended.
+
+This folder contains an example rsc file managing the actions on the device and an example script
+copying the update and firing the rsc.
diff --git a/erase-broken-modules/wiper b/erase-broken-modules/wiper
new file mode 100755
index 0000000..5c8a7f5
--- /dev/null
+++ b/erase-broken-modules/wiper
@@ -0,0 +1,9 @@
+#!/usr/bin/env sh
+
+MIKROTIK_HOSTNAME="banana"
+NPK_VERSION="6.49.5"
+ARCH="arm"
+
+scp wiper.rsc "${MIKROTIK_HOSTNAME}:wiper.rsc"||exit 1
+scp "routeros-${ARCH}-${NPK_VERSION}.npk" "${MIKROTIK_HOSTNAME}:routeros-${ARCH}-${NPK_VERSION}.npk"||exit 2
+ssh "$MIKROTIK_HOSTNAME" "/import wiper.rsc"
diff --git a/erase-broken-modules/wiper.rsc b/erase-broken-modules/wiper.rsc
new file mode 100644
index 0000000..dd6bd7a
--- /dev/null
+++ b/erase-broken-modules/wiper.rsc
@@ -0,0 +1,27 @@
+# vim:syntax=rsc:ts=4
+# procedure: 1. try manually to uninstall a package. unless that works add it to pkgdis, if it works --> pkguninst.
+# leave routeros-* in uninstall.
+# 2. put an UPGRADE package into the root folder of the device, put this rsc file on a disk
+# 3. execute the rsc file
+# ...not yet tested with a downgrade package.
+:global pkguninst {"lora";"ups";"gps";"ntp";"openflow";"user-manager";"multicast";"calea";"tr069-client";"routeros-arm"}
+:global pkgdis {"ipv6";"wireless";"hotspot";"mpls";"routing";"ppp";"dhcp";"security";"advanced-tools"}
+
+# -------------------------- #
+
+#:put "uptime:"
+:global uptime [/system resource get uptime]
+:global cpu [/system resource get cpu]
+:global arch [/system resource get architecture-name]
+:put "CPU: $cpu ($arch) - Uptime: $uptime\n"
+:put "Setting packages to disabled..."
+:foreach pd in=$pkgdis do={
+ /system package disable $pd
+}
+:put "Setting packages to uninstall..."
+:foreach pu in=$pkguninst do={
+ /system package uninstall $pu
+}
+:put "Rebooting..."
+
+/system reboot