-
Notifications
You must be signed in to change notification settings - Fork 5
/
custom-build-8324.sh
executable file
·274 lines (194 loc) · 7.94 KB
/
custom-build-8324.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#!/bin/bash
customdir=/tmp/mount
bcmdir=/tmp/consumer
srcdir=$customdir/zyxel-source/GPL_Release_V100AAKL28C0
#Test for base build directory
if [ ! -d "$bcmdir" ] ;then
if [ ! -f "$srcdir/bcm963xx_4.12L.06B_consumer_release.tar.gz" ];then
echo "Please fetch zyxel source with git (see README) or aquire from Zyxel"
exit
else
mkdir -p /tmp/consumer
tar -zxvf $srcdir/bcm963xx_4.12L.06B_consumer_release.tar.gz -C /tmp/consumer
echo "Zyxel source extracted to $bcmdir"
fi
fi
if [ ! -d "$bcmdir/bcm963xx_router" ] ;then
echo -n "Run consumer_install? (y/n) "
read cinstall
if [ "cinstall" != "${cinstall#[Yy]}" ] ;then
cd $bcmdir
#patch < $customdir/consumer_install.patch
./consumer_install
#patch -R < $customdir/consumer_install.patch
echo "Zyxel consumer_install finished"
echo ""
else
echo "Bye!"
exit
fi
fi
echo -n "Apply jumbo frames patch? (y/n)? "
read jumbo
echo -n "Enable multiple telnet sessions? (y/n)? "
read telnet
echo -n "Updated adsl_phy (x6)? (y/n)? "
read adslx6
if [ "$adslx6" != "${adslx6#[Yy]}" ] ;then
adslx1=n
else
echo -n "Updated adsl_phy (x1)? (y/n)? "
read adslx1
fi
echo -n "Enabled custom commands at boot? (y/n)? "
read customcmds
echo -n "Enabled stats logging and webserver? (y/n)? "
read stats
echo ""
echo "Jumbo frames - $jumbo"
echo "Multiple telnet - $telnet"
echo "Updated adsl_phy (x6) - $adslx6"
echo "Updated adsl_phy (x1) - $adslx1"
echo "Custom boot commands - $customcmds"
echo "Stats logging and server - $stats"
echo ""
echo -n "Apply to build? (y/n) "
read doit
if [ "$doit" != "${doit#[Yy]}" ] ;then
echo ""
else
echo "Bye!"
exit
fi
customversion="28"
if [ ! -d "$customdir/original" ] ;then
mkdir $customdir/original
fi
if [ "$jumbo" != "${jumbo#[Yy]}" ] ;then
cd $bcmdir
patch -p3 < $customdir/jumboframes.patch
customversion+="-jumbo"
echo "Jumbo frames enabled"
fi
if [ "$telnet" != "${telnet#[Yy]}" ] ;then
cp $bcmdir/bcm963xx_router/userspace/private/apps/telnetd/telnetd_VMG8924-B10A_save $customdir/original/
cp $customdir/8324_telnetd $bcmdir/bcm963xx_router/userspace/private/apps/telnetd/telnetd_VMG8924-B10A_save
customversion+="-tel"
echo "Multiple telnet sessions enabled"
fi
if [ "$adslx1" != "${adslx1#[Yy]}" ] ;then
cp $bcmdir/bcm963xx_router/bcmdrivers/broadcom/char/adsl/impl1/adsl_phyVMG8924-B10A.bin_save $customdir/original/
cp $customdir/A2pv6F039x1_adsl_phy.bin $bcmdir/bcm963xx_router/bcmdrivers/broadcom/char/adsl/impl1/adsl_phyVMG8924-B10A.bin_save
customversion+="-x1"
echo "Using updated x1 adsl_phy.bin"
fi
if [ "$adslx6" != "${adslx6#[Yy]}" ] ;then
cp $bcmdir/bcm963xx_router/bcmdrivers/broadcom/char/adsl/impl1/adsl_phyVMG8924-B10A.bin_save $customdir/original/
cp $customdir/A2pv6F039x6_adsl_phy.bin $bcmdir/bcm963xx_router/bcmdrivers/broadcom/char/adsl/impl1/adsl_phyVMG8924-B10A.bin_save
customversion+="-x6"
echo "Using updated x6 adsl_phy.bin"
fi
if [ "$stats" != "${stats#[Yy]}" ] ;then
#Build mongoose http server
cd $customdir/stats-staging/mongoose/
make
#Move server and html/css/js to build
cp $customdir/stats-staging/mongoose/stats-server $customdir/stats-staging/stats-server/stats-server-bin
cp -r $customdir/stats-staging/stats-server $bcmdir/bcm963xx_router/userspace/private/apps/httpd/
mv $bcmdir/bcm963xx_router/userspace/private/apps/httpd/stats-server/stats-server-bin $bcmdir/bcm963xx_router/userspace/private/apps/httpd/
#Save original build files
cp $bcmdir/bcm963xx_router/userspace/private/apps/httpd/Makefile $customdir/original/httpd_Makefile_8324
cp $bcmdir/bcm963xx_router/targets/fs.src/etc/profile $customdir/original/8324_profile
#Replace httpd Makefile and profile with ones that move and launch the stats-server
#cp $customdir/stats-staging/stats_httpd_Makefile_8324 $bcmdir/bcm963xx_router/userspace/private/apps/httpd/Makefile
#cp $customdir/stats-staging/8324_stats_profile $bcmdir/bcm963xx_router/targets/fs.src/etc/profile
cd $bcmdir/bcm963xx_router/userspace/private/apps/httpd/
patch < $customdir/stats-staging/8324-stats-Makefile.patch
cd $bcmdir/bcm963xx_router/targets/fs.src/etc/
patch < $customdir/stats-staging/stats-profile.patch
customversion+="-stats"
echo "Stats logging and webserver enabled"
fi
if [ "$customcmds" != "${customcmds#[Yy]}" ] ;then
#Save original profile
if [ ! -f $customdir/original/8324_profile ];then
cp $bcmdir/bcm963xx_router/targets/fs.src/etc/profile $customdir/original/8324_profile
fi
cd $bcmdir/bcm963xx_router/targets/fs.src/etc/
patch < $customdir/customcmd-profile.patch
customversion+="-cmd"
fi
#Save original version string file
cp $bcmdir/bcm963xx_router/targets/VMG8924-B10A/VMG8924-B10A $customdir/original/VMG8924-B10A_vstring
versionfile=$bcmdir/bcm963xx_router/targets/VMG8924-B10A/VMG8924-B10A
#Use selected features to update version string
sed -i "s|MSTC_EXTERNAL_VERSION=\"1.00(AAKL.28)C0\"|MSTC_EXTERNAL_VERSION=\"$customversion\"|g" $versionfile
sed -i "s|MSTC_INTERNAL_VERSION=\"1.00(AAKL.28)C0\"|MSTC_INTERNAL_VERSION=\"$customversion\"|g" $versionfile
echo "Version string updated to "$customversion
echo -n "Continue to actual build (y/n)? "
read build
if [ "$build" != "${build#[Yy]}" ] ;then
cd $bcmdir/bcm963xx_router/
make PROFILE=VMG8924-B10A
if [ ! -d "$customdir/images" ] ;then
mkdir $customdir/images
fi
model="8x24-B10A-"
customversion+=".bin"
model+=$customversion
cp images/ras.bin $customdir/images/$model
echo ""
echo "Build complete, image saved to "$customdir"/images/"$model
echo ""
echo "Check for rational file size! ~27MB"
echo ""
fi
echo -n "Revert all changes to build? (y/n)? "
echo -n "With 8x24 this is achieved by removing bcm963xx_router folder and extracting again."
read revert
if [ "$revert" != "${revert#[Yy]}" ] ;then
: '
cd $bcmdir/bcm963xx_router/
make clean
if [ "$jumbo" != "${jumbo#[Yy]}" ] ;then
cd $bcmdir
patch -R -p3 < $customdir/jumboframes.patch
echo "Jumbo frames patch reversed"
fi
if [ "$telnet" != "${telnet#[Yy]}" ] ;then
cp $customdir/original/telnetd_VMG8924-B10A_save $bcmdir/bcm963xx_router/userspace/private/apps/telnetd/telnetd_VMG8924-B10A_save
echo "Original telnetd restored"
fi
if [ "$adslx1" != "${adslx1#[Yy]}" ] ;then
cp $customdir/original/adsl_phyVMG8924-B10A.bin_save $bcmdir/bcm963xx_router/bcmdrivers/broadcom/char/adsl/impl1/adsl_phyVMG8924-B10A.bin_save
echo "Original adsl_phy.bin restored"
fi
if [ "$adslx6" != "${adslx6#[Yy]}" ] ;then
cp $customdir/original/adsl_phyVMG8924-B10A.bin_save $bcmdir/bcm963xx_router/bcmdrivers/broadcom/char/adsl/impl1/adsl_phyVMG8924-B10A.bin_save
echo "Original adsl_phy.bin restored"
fi
if [ "$stats" != "${stats#[Yy]}" ] ;then
rm -rf $bcmdir/bcm963xx_router/userspace/private/apps/httpd/stats-server/
rm -f $bcmdir/bcm963xx_router/userspace/private/apps/httpd/stats-server-bin
cp $customdir/original/httpd_Makefile_8324 $bcmdir/bcm963xx_router/userspace/private/apps/httpd/Makefile
cp $customdir/original/8324_profile $bcmdir/bcm963xx_router/targets/fs.src/etc/profile
echo "Stats logging and webserver removed"
fi
cp $customdir/original/VMG8924-B10A_vstring $bcmdir/bcm963xx_router/targets/VMG8924-B10A/VMG8924-B10A
echo "Restored version string"
'
rm -rf $bcmdir/bcm963xx_router
cd $bcmdir
patch < $customdir/consumer_install_source.patch
./consumer_install
patch -R < $customdir/consumer_install_source.patch
if [ "$stats" != "${stats#[Yy]}" ] ;then
cd $customdir/stats-staging/mongoose
make clean
rm $customdir/stats-staging/stats-server/stats-server-bin
fi
echo ""
echo "Clean source extracted to $bcmdir/bcm963xx_router"
echo ""
echo "Bye"
fi