批量下载OpenWrt源

批量下载OpenWrt源

OpenWrt源在国内的访问非常慢,导致安装软件包时半天也没反应,以致于正常的维护都无法进行。于是在网上找到了批量下载源的方法,稍作修改,分享给大家。

进入到想要存放源文件的地方,执行以下命令,新建一个脚本文件

vim openwrt.sh

复制并粘贴以下内容(如果要下载其他包,先修改我注释的地方)

#!/bin/sh

#Packages want to download
#修改为自己要下载的源
Packages="barrier_breaker/14.07/ar71xx/generic/packages"

#save current path to $path
path=$(dirname $0)
path=${path/\./$(pwd)}
echo "Packages will download to ${path}"

mkdir -p $path/$Packages/base
cd $path/$Packages/base
wget http://downloads.openwrt.org/$Packages/base/
wget -i index.html -F -B http://downloads.openwrt.org/$Packages/base/

mkdir -p $path/$Packages/luci
cd $path/$Packages/luci
wget http://downloads.openwrt.org/$Packages/luci/
wget -i index.html -F -B http://downloads.openwrt.org/$Packages/luci/

mkdir -p $path/$Packages/management
cd $path/$Packages/management
wget http://downloads.openwrt.org/$Packages/management/
wget -i index.html -F -B http://downloads.openwrt.org/$Packages/management/

mkdir -p $path/$Packages/packages
cd $path/$Packages/packages
wget http://downloads.openwrt.org/$Packages/packages/
wget -i index.html -F -B http://downloads.openwrt.org/$Packages/packages/

mkdir -p $path/$Packages/routing
cd $path/$Packages/routing
wget http://downloads.openwrt.org/$Packages/routing/
wget -i index.html -F -B http://downloads.openwrt.org/$Packages/routing/

mkdir -p $path/$Packages/telephony
cd $path/$Packages/telephony
wget http://downloads.openwrt.org/$Packages/telephony/
wget -i index.html -F -B http://downloads.openwrt.org/$Packages/telephony/

mkdir -p path/$Packages/oldpackages
cd $path/$Packages/oldpackages
wget http://downloads.openwrt.org/$Packages/oldpackages/
wget -i index.html -F -B http://downloads.openwrt.org/$Packages/oldpackages/

赋于可执行权限,并执行

chmod +x openwrt.sh
sh openwrt.sh

等待一段时间后,所有文件就会下载在当前目录下。对于本例,所有文件存放于“barrier_breaker”下,使用7z压缩后大小为521M。

进阶

如果挂载了USB存储,可以将下载的的源放到其中,假设位于 “/mnt/sda1/barrier_breaker/”,然后执行下列命令创建一个软链接:

ln -s /mnt/sda1/barrier_breaker/ /www/

然后前往“系统-软件包-配置”,将源的配置改为:

dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
# src/gz barrier_breaker_base http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/base
# src/gz barrier_breaker_luci http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/luci
# src/gz barrier_breaker_packages http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/packages
# src/gz barrier_breaker_routing http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/routing
# src/gz barrier_breaker_telephony http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony
# src/gz barrier_breaker_management http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/management
src/gz barrier_breaker_oldpackages http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/oldpackages

# local package mirror
src/gz barrier_breaker_base http://localhost/barrier_breaker/14.07/ar71xx/generic/packages/base
src/gz barrier_breaker_luci http://localhost/barrier_breaker/14.07/ar71xx/generic/packages/luci
src/gz barrier_breaker_packages http://localhost/barrier_breaker/14.07/ar71xx/generic/packages/packages
src/gz barrier_breaker_routing http://localhost/barrier_breaker/14.07/ar71xx/generic/packages/routing
src/gz barrier_breaker_telephony http://localhost/barrier_breaker/14.07/ar71xx/generic/packages/telephony
src/gz barrier_breaker_management http://localhost/barrier_breaker/14.07/ar71xx/generic/packages/management

这样即是路由自己运行了一个源镜像,并且系统将从本地镜像中安装软件包,速度是最快的。但如果要更新软件包,需要自己更新USB中的包文件。

Leave a Reply

电子邮件地址不会被公开。 必填项已用*标注