/
build.snap.sh
executable file
·56 lines (48 loc) · 1.9 KB
/
build.snap.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
#!/bin/bash
defaultUrl=https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-ramips-mt7621-xiaomi_mi-router-4a-gigabit-squashfs-sysupgrade.bin
builderUrl=https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-imagebuilder-ramips-mt7621.Linux-x86_64.tar.xz
profileSetting=xiaomi_mi-router-4a-gigabit
targetBin="./bin/targets/ramips/mt7621/openwrt-ramips-mt7621-xiaomi_mi-router-4a-gigabit-squashfs-sysupgrade.bin"
# cd the directory
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
cd $DIR
echo -e "--------"
git pull
#check version
rm index.html
wget -q https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/
sLine=$(cat index.html | grep 4a-gigabit-squashfs-sysupgrade.bin)
sTime=$(expr "$sLine" : '.*"d">\(.*\)</td>.*')
sVersion=$(echo $sTime | awk '{printf "%s_%s", $2,$3}')
#sVersion=Dec_1
echo $(date '+%F %T') Expected version $sVersion
[ -f ./firmware/snap/${sVersion}.bin ] && {
echo Version ${sVersion}.bin already exist !
exit
}
#build luci version
rm -r openwrt-imagebuilder-ramips-mt7621.Linux-x86_64*
echo downloading imagebuilder
wget -nv $builderUrl
tar -xf openwrt-imagebuilder-ramips-mt7621.Linux-x86_64.tar.xz
cd openwrt-imagebuilder-ramips-mt7621.Linux-x86_64
echo building luci version ... output: buildInfo
make image PROFILE=$profileSetting PACKAGES="luci luci-theme-material" >>../buildInfo.$sVersion 2>&1
if [ $? -eq 0 ]; then
echo "Successfully created $sVersion"
else
echo "luciVersion build failed!!!"
exit
fi
cp $targetBin ../firmware/snap/${sVersion}-luci.bin
cd ..
#download default bin
wget $defaultUrl -nv -O ./firmware/snap/${sVersion}.bin
echo [ $sTime ] $sVersion.bin version >>./versionDate
echo [ $(date "+%a %b %e %R:%S %Y") ] $sVersion-luci.bin build >>./versionDate
echo '--------------' >>./versionDate
echo ${sVersion}-luci.bin >./latestVersion
#github push
git add .
git commit -am "add version ${sVersion}"
git push