-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.sh
executable file
·92 lines (84 loc) · 2.29 KB
/
setup.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
###
# @Author: ttimochan
# @Date: 2022-12-21 21:16:34
# @LastEditors: ttimochan
# @LastEditTime: 2023-01-22 18:47:49
# @FilePath: /unlock-redmi-ax6000/setup.sh
###
#!/bin/bash
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, please use root user"
exit 1
fi
nvram_set(){
echo -e 'admin\nadmin' | passwd root
nvram set ssh_en=1
nvram set telnet_en=1
nvram set uart_en=1
nvram set boot_wait=on
nvram commit
}
set_init(){
sed -i 's/channel=.*/channel="debug"/g' /etc/init.d/dropbear
/etc/init.d/dropbear restart
}
uci_readly(){
echo "Copyright ======================"
echo ""
echo "Official blog: https://www.miaoer.xyz/posts/network/flash-redmi-ax6000"
echo "Read more at: miaoer.xyz"
echo "================================"
echo " "
mkdir /data/auto_ssh
cd /data/auto_ssh
curl -O https://fastly.jsdelivr.net/gh/miaoermua/unlock-redmi-ax6000@main/auto_ssh.sh
if [ ! -f auto_ssh.sh ]; then
echo "Error: auto_ssh.sh download failed"
exit 1
fi
chmod +x auto_ssh.sh
}
uci_start(){
uci set firewall.auto_ssh=include
uci set firewall.auto_ssh.type='script'
uci set firewall.auto_ssh.path='/data/auto_ssh/auto_ssh.sh'
uci set firewall.auto_ssh.enabled='1'
uci commit firewall
uci set system.@system[0].timezone='CST-8'
uci set system.@system[0].webtimezone='CST-8'
uci set system.@system[0].timezoneindex='2.84'
uci commit
}
main(){
nvram_set
if [ $(nvram get ssh_en) != "1" ]; then
echo "Error: nvram_set failed"
exit 1
fi
set_init
if [ $(ps | grep dropbear | grep -v grep | wc -l) == "0" ]; then
echo "Error: set_init failed"
exit 1
fi
uci_readly
if [ ! -f /data/auto_ssh/auto_ssh.sh ]; then
echo "Error: uci_readly failed"
exit 1
fi
uci_start
if [ $(uci show firewall | grep auto_ssh | wc -l) == "0" ]; then
echo "Error: uci_start failed"
exit 1
fi
mtd erase crash
echo "Success ======================"
echo ""
echo "all works done!"
sleep 1
echo "The device has been unlocked by SSH."
echo "After restarting, you can exit Telnet and proceed to the next step."
echo " "
echo "reboot 1 second later"
reboot
}
main