-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinstall.sh
33 lines (25 loc) · 949 Bytes
/
install.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
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# Must be root !
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
echo "Preparation ..."
apt install unzip -y
# Latest Stable
CHR_VERSION=6.49.7
# Environment
DISK=$(lsblk | grep "disk" | head -n 1 | cut -d' ' -f1)
INTERFACE=$(ip -o -4 route show to default | awk '{print $5}')
INTERFACE_IP=$(ip addr show $INTERFACE | grep global | cut -d' ' -f 6 | head -n 1)
INTERFACE_GATEWAY=$(ip route show | grep default | awk '{print $3}')
wget -qO routeros.zip https://download.mikrotik.com/routeros/$CHR_VERSION/chr-$CHR_VERSION.img.zip && \
unzip routeros.zip && \
rm -rf routeros.zip
mount -o loop,offset=512 chr-$CHR_VERSION.img /mnt
echo "/ip address add address=${INTERFACE_IP} interface=[/interface ethernet find where name=ether1]
/ip route add gateway=${INTERFACE_GATEWAY}
" > /mnt/rw/autorun.scr
umount /mnt
echo u > /proc/sysrq-trigger
dd if=chr-$CHR_VERSION.img of=/dev/${DISK} bs=1M