forked from darkfire13/RouterOS-CHR-Install
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchr_install
More file actions
36 lines (34 loc) · 1.72 KB
/
chr_install
File metadata and controls
36 lines (34 loc) · 1.72 KB
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
34
35
36
#!/bin/bash
#ADDRESS=xxx.xxx.xxx.xxx/24
ADDRESS=`ip addr show enp0s3 | grep global | cut -d' ' -f 6 | head -n 1`
#GATEWAY=xxx.xxx.xxx.1
GATEWAY=`ip route list | grep default | cut -d' ' -f 3`
# Raw disk image https://mikrotik.com/download#chr
#VERSIONCHR=7.10.2
VERSIONCHR=7.11
wget -4 https://download.mikrotik.com/routeros/$VERSIONCHR/chr-$VERSIONCHR.img.zip -O chr.img.zip
gunzip -c chr.img.zip > chr.img
mount -o loop,offset=33571840 chr.img /mnt
# apt install -y pwgen coreutils #installing the password generation package
# PASSWORD=$(pwgen 12 1) #password generation
echo "Username: admin"
# echo "Password: $PASSWORD"
echo "Password: 12345"
echo "/ip address add address=$ADDRESS network=$GATEWAY interface=[/interface ethernet find where name=ether1]" > /mnt/rw/autorun.scr
echo "/ip route add gateway=$GATEWAY" >> /mnt/rw/autorun.scr
echo "/ip service disable telnet" >> /mnt/rw/autorun.scr #потому что туда сразу начинает что-то ломится
echo "/user set 0 name=admin password=$PASSWORD" >> /mnt/rw/autorun.scr
# echo "/ip dns set server=8.8.8.8,1.1.1.1" >> /mnt/rw/autorun.scr
# remount all mounted filesystems to read-only mode
echo u > /proc/sysrq-trigger
dd if=chr.img bs=1024 of=/dev/vda
echo "sync disk"
# synchronize all mounted filesystems
echo s > /proc/sysrq-trigger
echo "Sleep 10 seconds"
#надо подождать и можно закрывать окно. хрен его знает как заставить его под финал написать что можно закрывать окно
#/usr/bin/sleep 10
read -t 10 -u 1
echo "Ok, reboot"
# perform an immediate OS reboot similar to the RESET button (without synchronising and unmounting file systems)
echo b > /proc/sysrq-trigger