routeros: Rename role

This commit is contained in:
Timo Makinen 2025-04-06 17:32:32 +00:00
parent 4c9a7dbcfb
commit f114a2d5d9
4 changed files with 1 additions and 1 deletions

View file

@ -0,0 +1,16 @@
# Mikrotik Routeros Cheat Sheet
## Update
```
/system package update print
/tool fetch url=https://oob.foo.sh/routeros/routeros-7.13.4-arm.npk
/system reboot
/system package update print
```
## Change port vlan
```
/interface/bridge/port/set [find where bridge=bridge and interface=ether1] pvid=30
```

View file

@ -0,0 +1,63 @@
#!/bin/sh
set -eu
umask 022
cd /srv/web/oob.foo.sh/routeros
verbose=false
if [ "${1:-}" = "-v" ]; then
verbose=true
shift
fi
if [ $# -gt 0 ]; then
echo "Usage: $(basename "$0") [-v]" 1>&2
exit 1
fi
packageinfo=$(curl -sSf "https://mikrotik.com/download" | awk -F '"' '
{
if (!url && $0 ~ /routeros-[0-9\.]+-arm.npk/) {
url=$2
} else if (!found && url && $0 ~ /data-checksum-sha256/) {
print url " " $6
found = 1
}
}
')
packageurl="$(echo "$packageinfo" | cut -d " " -f 1)"
checksum="$(echo "$packageinfo" | cut -d " " -f 2)"
if [ -z "$packageurl" ]; then
echo "ERR: Got empty package URL, exiting" 1>&2
exit 1
fi
packagename="$(basename "$packageurl")"
if [ -f "$packagename" ]; then
"$verbose" && echo "Already up to date"
exit 0
fi
if [ -z "$checksum" ]; then
echo "ERR: Failed to determine package checksum" 1>&2
exit 1
fi
echo "Downloading new package '${packagename}'"
tmpfile="$(mktemp -p .)"
trap 'rm -f -- "$tmpfile"' EXIT
curl -sSf -o "$tmpfile" "$packageurl"
if [ "$(sha256sum "$tmpfile" | cut -d " " -f 1)" != "$checksum" ]; then
echo "ERR: Checksum check failed, not saving package" 1>&2
exit 1
fi
mv "$tmpfile" "$packagename"
echo
curl -sSf "https://cdn.mikrotik.com/routeros/$(echo "$packagename" | cut -d "-" -f 2)/CHANGELOG"
echo
echo