forked from shell-script/unlock-redmi-ax3000
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ax3000.sh
executable file
·101 lines (89 loc) · 2.88 KB
/
ax3000.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
93
94
95
96
97
98
99
100
101
#!/bin/ash
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2020 paldier (https://www.right.com.cn/forum/thread-4046020-1-1.html)
# Copyright (C) 2020 yyjdelete (https://www.right.com.cn/forum/thread-4060726-1-1.html)
# Copyright (C) 2021 Tianling Shen <[email protected]>
info_font="\033[36m[Info]\033[0m"
success_font="\033[32m[Success]\033[0m"
warning_font="\033[33m[Warning]\033[0m"
dump_mtd(){
echo -e "${info_font} Dumping MTD9..."
mkdir -p /tmp/syslogbackup/
nanddump -f /tmp/syslogbackup/bdata_mtd9.img /dev/mtd9
echo -e "${success_font} Done."
echo -e "${info_font} Now you can download it at:"
echo -e " http://192.168.31.1/backup/log/bdata_mtd9.img"
}
keep_script(){
echo -e "${info_font} Creating keep.d for mounting script..."
sed -i "/miwifi_overlay/d" "/etc/sysupgrade.conf"
cat >> "/etc/sysupgrade.conf" <<-EOF
/etc/init.d/miwifi_overlay
/etc/rc.d/S00miwifi_overlay
EOF
sync
echo -e "${success_font} Done."
}
mount_overlay(){
echo -e "${info_font} Creating mounting overlay script..."
cat > "/etc/init.d/miwifi_overlay" <<-EOF
#!/bin/sh /etc/rc.common
START=00
. /lib/functions/preinit.sh
start() {
[ -e /data/overlay ] || mkdir /data/overlay
[ -e /data/overlay/upper ] || mkdir /data/overlay/upper
[ -e /data/overlay/work ] || mkdir /data/overlay/work
mount --bind /data/overlay /overlay
fopivot /overlay/upper /overlay/work /rom 1
#Fixup miwifi misc, and DO NOT use /overlay/upper/etc instead, /etc/uci-defaults/* may be already removed
/bin/mount -o noatime,move /rom/data /data 2>&-
/bin/mount -o noatime,move /rom/etc /etc 2>&-
/bin/mount -o noatime,move /rom/ini /ini 2>&-
/bin/mount -o noatime,move /rom/userdisk /userdisk 2>&-
#Enable SSH
grep -q 'channel="debug"' /etc/init.d/dropbear || {
sed -i 's/channel=.*/channel="debug"/g' /etc/init.d/dropbear
/etc/init.d/dropbear start
}
return 0
}
EOF
chmod 755 /etc/init.d/miwifi_overlay
/etc/init.d/miwifi_overlay enable
sync
echo -e "${success_font} Done."
echo -e "${info_font} After reboot, please run 'sh $0 keep' to keep these settings when upgrade."
echo -e ""
echo -e "${warning_font} Rebooting device..."
reboot
}
case "$1" in
"hack")
chmod 0755 /etc/fuckax3000
/etc/fuckax3000 hack
/etc/fuckax3000 lock
echo -e "${success_font} Now you've got permanent Telnet/SSH access."
;;
"unlock")
chmod 0755 /etc/fuckax3000
/etc/fuckax3000 unlock
echo -e "${info_font} After reboot, please run 'sh $0 hack' to get permanent Telnet/SSH access."
echo -e ""
echo -e "${warning_font} Your device should be rebooted automatically, if not, please do it manually."
;;
"dump")
dump_mtd
;;
"keep")
keep_script
;;
"mount")
mount_overlay
;;
*)
echo -e "${info_font} Usage: sh $0 [hack|unlock|dump|keep|mount]"
exit 2
;;
esac