-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdo-routeros.sh
24 lines (22 loc) · 982 Bytes
/
do-routeros.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# Thanks for Roginvs https://www.digitalocean.com/community/questions/installing-mikrotik-routeros
# You can just copy paste and run script below on freshly installed Ubuntu 16.04
wget http://download2.mikrotik.com/routeros/6.42.6/chr-6.42.6.img.zip -O chr.img.zip && \
gunzip -c chr.img.zip > chr.img && \
mount -o loop,offset=33554944 chr.img /mnt && \
ADDRESS=`ip addr show eth0 | grep global | cut -d' ' -f 6 | head -n 1` && \
GATEWAY=`ip route list | grep default | cut -d' ' -f 3` && \
echo "/ip address add address=$ADDRESS interface=[/interface ethernet find where name=ether1]
/ip route add gateway=$GATEWAY
/ip service disable telnet
/user set 0 name=thatsme password=mysupadupapassW0ort
" > /mnt/rw/autorun.scr && \
umount /mnt && \
echo u > /proc/sysrq-trigger && \
dd if=chr.img bs=1024 of=/dev/vda && \
echo "sync disk" && \
echo s > /proc/sysrq-trigger && \
echo "Sleep 5 seconds" && \
sleep 5 && \
echo "Ok, reboot" && \
echo b > /proc/sysrq-trigger