-
Notifications
You must be signed in to change notification settings - Fork 6
/
restoreConfig.sh
143 lines (120 loc) · 4.09 KB
/
restoreConfig.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh
# set -v
set -e
# local ##### upload this file on "restore config" Menu only !!!
##############################################################################
#
# @category "Cgminer 4.9.2 for Bitmain Antminer S9"
# @package "Mintorro-S9 Firmware"
# @author Miguel Padilla <miguel.padilla@zwilla.de>
# @copyright (c) 2016 - Miguel Padilla
# @link "https://www.mintorro.com"
#
# According to our dual licensing model, this program can be used either
# under the terms of the GNU Affero General Public License, version 3,
# or under a proprietary license.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
##############################################################################
#
# vi restoreConfig-sh
# paste this code into
# press "esc" "w" "q"
#
# create the md5 sum at the folder where you compiled the source
#
# cp cgminer bmminer
# cp cgminer-api bmminer-api
# md5sum bmminer-api > bmminer-api.md5
# md5sum bmminer > bmminer.md5
#
# review this script, test it on ssh terminal and then save it again with your changes and
#
# md5sum restoreConfig.sh > restoreConfig.md5
#
# cp restoreConfig.sh and restoreConfig.md5 to your build root
#
# create the tar
# tar -cf AntminerS9-Update-Bmminer.tar restoreConfig.md5 bmminer.md5 bmminer-api.md5 restoreConfig.sh bmminer-api bmminer
#
# now copy AntminerS9-Update-Bmminer.tar to your computer from where you have access to the frontend of your Antminer S9
#
# * click on Menu System
# * click on Menu Upgrade
# * click on menu "Restore backup"
# * choose the AntminerS9-Update-Bmminer.tar
# * click on "upload Archive..."
#
# now the following process will start:
#
# * uploading AntminerS9-Update-Bmminer.tar
# * check for old version and delete them
# * check the md5sum of the files
#
#Make a backup now at first
cp BackupMyFilesAndDownload.cgi /www/pages/cgi-bin/BackupMyFilesAndDownload.cgi
mkdir -p /config/upgrade
mkdir -p /config/downgrade
touch /config/restoreConfig.sh
chmod 777 /config/upgrade
chmod 777 /config/downgrade
rm -rf /config/upgrade/bmminer
rm -rf /config/upgrade/bmminer-api
rm -rf /config/upgrade/bmminer.md5
rm -rf /config/upgrade/bmminer-api.md5
for f in bmminer.md5 bmminer-api.md5 bmminer-api bmminer; do
if [ -f $f ] ; then
cp -p $f /config/upgrade/
fi;
done
chmod -R 777 /config/upgrade
chmod -R 777 /config/downgrade
md5sum -c /config/upgrade/bmminer.md5
md5sum -c /config/upgrade/bmminer-api.md5
# Backup original, but do not overwirte
cp -p /usr/bin/bmminer /config/downgrade/bmminer-orig;
cp -p /usr/bin/bmminer-api /config/downgrade/bmminer-api-orig;
cp -p /www/pages/upgrade.html /config/downgrade/upgrade.html-orig;
# with this you can access the miner hard from outside just call http://minerip/cgi-bin/StartMinerSoftware.cgi
cp -p StartMinerSoftware.cgi /www/pages/cgi-bin/StartMinerSoftware.cgi;
rm /usr/bin/bmminer
rm /usr/bin/bmminer-api
cp -p /config/upgrade/bmminer /usr/bin/bmminer
cp -p /config/upgrade/bmminer-api /usr/bin/bmminer-api
cp -p upgrade.html /www/pages/upgrade.html;
cd /usr/bin;
echo $(date) > /config/upgrade/update.date
sync;
su root /etc/init.d/bmminer.sh stop;
sleep 2
su root /etc/init.d/bmminer.sh restart;
# CGI output must start with at least empty line (or headers)
printf "Content-type: text/html\r\n\r\n"
cat <<-EOH
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="5; url=/cgi-bin/BackupMyFilesAndDownload.cgi;">
<script type="text/javascript">
window.location.href="/cgi-bin/BackupMyFilesAndDownload.cgi";
</script>
<script>
function f_submit_goback() {
window.location.href="/cgi-bin/BackupMyFilesAndDownload.cgi";
}
</script>
<title>Backup complete!</title>
</head>
<H1>Backup complete!</H1>
<body>
If you are not redirected automatically, follow the <a href='f_submit_goback()'>link</a>
</body>
</html>
EOH
exit;
# NOTE!!! Not yet tested !!!