ungleich-tools/mikrotik-update.sh

44 lines
924 B
Bash
Raw Normal View History

2020-07-28 13:40:15 +00:00
#!/bin/sh
# Nico Schottelius, 2019-12-02
# Update mikrotik routers to the latest package
if [ $# -lt 2 ]; then
echo "$0 <version> <arch> router [router...]"
cat <<EOF
2020-05-21 15:09:39 +00:00
Version:
- the package version as found on https://mikrotik.com/download
Arch:
- rb4011: arm
2020-05-21 15:09:39 +00:00
- crs326: arm
- hapac: mipsbe
2020-05-21 15:09:39 +00:00
router:
- The hostname(s) or IP(v6) addresses of the routers you want to update
EOF
exit 1
fi
version=$1; shift
arch=$1; shift
file=all_packages-${arch}-${version}.zip
url=https://download.mikrotik.com/routeros/${version}/${file}
tmp=$(mktemp -d)
cd "$tmp"
wget "${url}"
unzip "${file}"
pkg_list="dhcp ipv6 lcd lte multicast ppp routing security system user-manager wireless"!
while [ $# -ge 1 ]; do
target=$1; shift
echo "Updating ${target}"
for pkg in $pkg_list; do
scp ${pkg}-${version}-${arch}.npk "admin@${target}:"
done
ssh admin@${target} "/system reboot"
done
rm -rf "${tmp}"!