ungleich-tools/mikrotik-update.sh
2020-07-28 15:40:15 +02:00

43 lines
924 B
Bash
Executable file

#!/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
Version:
- the package version as found on https://mikrotik.com/download
Arch:
- rb4011: arm
- crs326: arm
- hapac: mipsbe
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}"!