[mikrotik] add scripts to setup/configure basic mikrotik stuff
This commit is contained in:
parent
704f2dab7c
commit
678d1bec02
2 changed files with 82 additions and 0 deletions
45
mikrotik-setup.sh
Normal file
45
mikrotik-setup.sh
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius, 2019-12-02
|
||||
# Setup standard mikrotik settings
|
||||
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "$0 <target> [target]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
target=$1; shift
|
||||
|
||||
|
||||
conf() {
|
||||
echo $@
|
||||
ssh admin@${target} "$@"
|
||||
}
|
||||
copy() {
|
||||
scp "$1" admin@${target}:
|
||||
}
|
||||
|
||||
# store ssh key in the admin user!
|
||||
copy ~/.ssh/id_rsa.pub
|
||||
conf "/user ssh-keys import user=admin public-key-file=id_rsa.pub"
|
||||
conf "/file remove id_rsa.pub"
|
||||
|
||||
# remove unecessary stuff
|
||||
for unusedpkg in calea gps lora mpls openflow tr069-client ups \
|
||||
advanced-tools hotspot ntp; do
|
||||
conf "/system package uninstall $unusedpkg"
|
||||
done
|
||||
|
||||
# ensure important stuff is enabled
|
||||
for wantpkg in wireless; do
|
||||
conf "/system package enable $wantpkg"
|
||||
done
|
||||
|
||||
# TODOs:
|
||||
# setup capsman
|
||||
# setup IPv6
|
||||
# setup password
|
||||
# disable dhcp server
|
||||
|
||||
# New script for setting up the main capsman:
|
||||
# certificate generation!
|
37
mikrotik-update.sh
Executable file
37
mikrotik-update.sh
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/bin
|
||||
# Nico Schottelius, 2019-12-02
|
||||
# Update mikrotik routers to the latest package
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "$0 <version> <arch> router [router...]"
|
||||
cat <<EOF
|
||||
Arch:
|
||||
- rb4011: arm
|
||||
- hapac: mipsbe
|
||||
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}"!
|
Loading…
Reference in a new issue