代码拉取完成,页面将自动刷新
同步操作将从 darcyg/wrtoy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
source common/common.sh common
function action_upgrade_feeds()
{
cd $op_dir
local fn
[ -z "$feeds_name" ] && feeds_name="all"
[ "$feeds_name" == "-" -o "$feeds_name" == "c" ] && feeds_name="commonpack"
[ "$feeds_name" == "all" ] && fn="-a" || fn="$feeds_name"
show i $(lang "upgrade feeds: $feeds_name" "升级feeds仓库: $feeds_name")
$doProxy ./scripts/feeds update "$fn"
$doProxy ./scripts/feeds install -a
#"$fn"
exit 0
}
function action_upgrade_custom_feeds()
{
feeds_name="-"
action_upgrade_feeds
exit 0
}
function action_use_proxy()
{
if [ $use_proxy == true ]; then
local has_proxy=$(netstat -apnl 2>/dev/null | grep $proxy_port)
[ ! -z "$has_proxy" ] && ( doProxy="proxychains"; \
show s $(lang "used ssh proxy($proxy_port)" "检测到ssh代理服务端口($proxy_port)")) || \
show s $(lang "no ssh proxy" "没有ssh代理服务")
doProxy="proxychains"
fi
doAction=true
}
function action_verbose()
{
doVerbose="V=s"
}
function action_install_new_openwrt()
{
show i $(lang "install openwrt base form git" "安装openwrt基本平台")
cd $op_root
./openwrt_synchro -f
exit 0
}
function action_reset_current_openwrt()
{
show i $(lang "reinstall openwrt base form git" "重新安装openwrt基本平台")
cd $op_root
./openwrt_synchro -m ch -f
exit 0
}
function action_install_release_openwrt()
{
show i $(lang "install openwrt base form git(release version)" "重新安装openwrt基本平台(release版本)")
cd $op_root
./openwrt_synchro -m rh -f
exit 0
}
function action_install_beta_openwrt()
{
show i $(lang "install openwrt base form git(beta version)" "重新安装openwrt基本平台(beta版本)")
cd $op_root
./openwrt_synchro -m bh -f
exit 0
}
function action_download_package()
{
show i $(lang "download all package source code" "下载所选模块所有源码包")
cd $op_dir
if [ $download_proxy_package == true ]; then
svpn.sh -r
use_proxy=true
action_use_proxy
fi
$doProxy make download $doVerbose $doMakeJ
exit 0
}
function action_restart_tftp()
{
show i $(lang "restart tftp server" "启动tftp服务")
sudo service tftpd-hpa restart
exit 0
}
function action_make_usb_image_disk()
{
show i $(lang "copy firmware file to usb driver" "拷贝产生的固件文件到usb盘")
cd $op_root
local bn=$(./hardware_manage -gv bn)
local bt=$(./hardware_manage -gv bt)
local pf=$(./hardware_manage -gv pf)
local cn=$(./hardware_manage -gv cn)
local tr=$(./hardware_manage -gv tr)
local tl=$(./hardware_manage -gv tl)
local bf=$(./hardware_manage -gv bf)
local ud=$(./hardware_manage -gv ud)
local mnt=$ud
local src="$op_dir/bin/$pf/$bf"
#local nbf=$(basename $bf .bin)"_"$(now).bin
#local mnt=$(df -h | grep $ud | awk '{print $6}')
if [ ! -e "$ud" ]; then
show s $(lang "usb disk($ud) not exists" "目标usb盘($ud)不存在")
exit 0
fi
#local dst="$mnt/$nbf"
#echo $src
#echo $dst
#echo $link
local fsize
local fsizeh
local fdtime
local fhash
if [ -f "$src" ]; then
[ -f "$dst" ] && rm $dst
fsize=$(ls -l $src | awk '{print $5}')
fsizeh=$(ls -lh $src | awk '{print $5}')
fhash=$(md5sum -b $src | awk '{print $1}')
show s $(lang "new file" "拷贝文件:") $ud
lang " filesize: $fsize byte ($fsizeh) md5:$fhash" " 文件大小: $fsize 字节 ($fsizeh) md5:$fhash"
local dmode=$(stat -c "%a" $ud)
[ "$dmode" == "666" -o "$dmode" == "777" ] && dd if=$src of=$ud conv=fsync || sudo dd if=$src of=$ud conv=fsync
#sync
else
show s $(lang "no file copy." "没有文件被复制")
fi
exit 0
}
function action_copy_usb_image_disk()
{
show i $(lang "copy firmware file to usb directory" "拷贝产生的固件文件到usb目录")
cd $op_root
local bn=$(./hardware_manage -gv bn)
local bt=$(./hardware_manage -gv bt)
local pf=$(./hardware_manage -gv pf)
local cn=$(./hardware_manage -gv cn)
local tr=$(./hardware_manage -gv tr)
local tl=$(./hardware_manage -gv tl)
local bf=$(./hardware_manage -gv bf)
local ud=$(./hardware_manage -gv ud)
local src="$op_dir/bin/$pf/$bf"
local nbf=$(basename $bf .bin)"_"$(now).bin
local mnt=$(df -h | grep $ud | awk '{print $6}')
if [ ! -d "$mnt" ]; then
show s $(lang "usb directory($ud) not exists" "目标usb目录($ud)不存在")
exit 0
fi
local dst="$mnt/$nbf"
#echo $src
#echo $dst
#echo $link
local fsize
local fsizeh
local fdtime
local fhash
if [ -f "$src" ]; then
[ -f "$dst" ] && rm $dst
fsize=$(ls -l $src | awk '{print $5}')
fsizeh=$(ls -lh $src | awk '{print $5}')
fhash=$(md5sum -b $src | awk '{print $1}')
fdtime=$(stat -c %y $src | awk -F. '{print $1}')
show s $(lang "new file" "拷贝文件:") $dst " ($fdtime)"
lang " filesize: $fsize byte ($fsizeh) md5:$fhash" " 文件大小: $fsize 字节 ($fsizeh) md5:$fhash"
cp -f $src $dst
sync
else
show s $(lang "no file copy." "没有文件被复制")
fi
exit 0
}
function action_clear()
{
show i $(lang "clear project" "清除项目")
cd $op_dir
if [ $clear_temp == true ]; then
rm -rf ./tmp
elif [ $clear_dir == true ]; then
make dirclean $doVerbose $doMakeJ
else
make clean $doVerbose $doMakeJ
fi
exit 0
}
function action_backup_config()
{
show i $(lang "backup openwrt config" "备份openwrt配置")
[ -z "$backup_config" ] && exit 0
cd $op_dir
show s $(lang "copy .config to config.$backup_config" "拷贝 .config 为 config.$backup_config")
cp .config config.$backup_config
}
function action_recover_config()
{
show i $(lang "recover openwrt config" "恢复openwrt配置")
[ -z "$recover_config" ] && exit 0
cd $op_dir
show s $(lang "copy config.$backup_config to .config" "拷贝 config.$backup_config 为 .config")
cp config.$recover_config .config
}
function action_show_diff_config()
{
show i $(lang "show openwrt config diff" "显示openwrt配置差异")
cd $op_dir
local difftool=$(which bcompare)
local prefix="config."
local pp1=".config"
local pp2=".config"
local ppmode="-rupN"
[ ! -f "$difftool" -o "$pmode" != "-" ] && difftool=diff
#[ -z "$pmode" -o "$pmode" == "--" ] || prefix=""
[ -z "$pmode" -o "$pmode" == "-" -o "$pmode" == "--" ] || ppmode=$pmode
[ -z "$p1" -o "$p1" == "-" ] || pp1=$prefix$p1
[ -z "$p2" -o "$p2" == "-" ] || pp2=$prefix$p2
#[ "$difftool" == "diff" ] || ppmode="&"
echo "command: $difftool $pp1 $pp2 $ppmode"
$difftool $pp1 $pp2 $ppmode
}
function action_build()
{
show i $(lang "build openwrt" "编译openwrt")
action_publish_upgrade > /dev/null 2>&1
cd $op_dir
if [ -z "$build_j" ]; then
make defconfig
$doProxy make $doVerbose $doMakeJ
else
make defconfig
$doProxy make -j $build_j -l9 $doVerbose
fi
}
function action_build_image()
{
show i $(lang "build openwrt image" "仅编译openwrt镜像")
cd $op_dir
make defconfig
if [ ! -z "$package_name" ]; then
$doProxy make package/$package_name/compile $doVerbose $doMakeJ
$doProxy make package/$package_name/install $doVerbose $doMakeJ
fi
$doProxy make package/install $doVerbose $doMakeJ
$doProxy make target/install $doVerbose $doMakeJ
$doProxy make package/index $doVerbose $doMakeJ
}
function action_build_image_packages()
{
show i $(lang "build openwrt image package install" "仅编译openwrt镜像-包集合")
cd $op_dir
make defconfig
if [ ! -z "$package_name" ]; then
$doProxy make package/$package_name/compile $doVerbose $doMakeJ
$doProxy make package/$package_name/install $doVerbose $doMakeJ
fi
$doProxy make package/install $doVerbose $doMakeJ
}
function action_build_image_linux()
{
show i $(lang "build openwrt image linux install" "仅编译openwrt镜像-Linux")
cd $op_dir
make defconfig
$doProxy make target/install $doVerbose $doMakeJ
}
function action_build_image_index()
{
show i $(lang "build openwrt image package index" "仅编译openwrt镜像-包索引")
cd $op_dir
make defconfig
$doProxy make package/index $doVerbose $doMakeJ
}
function action_copy_tftp()
{
show i $(lang "copy firmware file to tftp root directory" "拷贝产生的固件文件到tftp的固件目录")
cd $op_root
local bn=$(./hardware_manage -gv bn)
local bt=$(./hardware_manage -gv bt)
local pf=$(./hardware_manage -gv pf)
local cn=$(./hardware_manage -gv cn)
local tr=$(./hardware_manage -gv tr)
local tl=$(./hardware_manage -gv tl)
local bf=$(./hardware_manage -gv bf)
local src="$op_dir/bin/$pf/$bf"
local dst="$tr/$bf"
local link="$tr/$tl"
#echo $src
#echo $dst
#echo $link
local fsize
local fsizeh
local ofsize
local ofsizeh
local ofhash
local ofdtime
local fdtime
local fhash
#exit 0
if [ -L "$link" ]; then
ofsize=$(ls -l $tr/$(basename $(readlink $link)) | awk '{print $5}')
ofsizeh=$(ls -lh $tr/$(basename $(readlink $link)) | awk '{print $5}')
ofhash=$(md5sum -b $tr/$(basename $(readlink $link)) | awk '{print $1}')
ofdtime=$(stat -c %y $tr/$(basename $(readlink $link)) | awk -F. '{print $1}')
show s $(lang "old file" "原 文 件:") $(basename $(readlink $link)) "=>" $tl " ($ofdtime)"
lang " filesize: $ofsize byte ($ofsizeh) md5:$ofhash" " 文件大小: $ofsize 字节 ($ofsizeh) md5:$ofhash"
echo "link $tl exists! rm $tl file!"
rm -f $link
fi
if [ -f "$src" ]; then
[ -f "$dst" ] && rm $dst
fsize=$(ls -l $src | awk '{print $5}')
fsizeh=$(ls -lh $src | awk '{print $5}')
fhash=$(md5sum -b $src | awk '{print $1}')
fdtime=$(stat -c %y $src | awk -F. '{print $1}')
show s $(lang "new file" "生成文件:") $tl "=>" $bf " ($fdtime)"
lang " filesize: $fsize byte ($fsizeh) md5:$fhash" " 文件大小: $fsize 字节 ($fsizeh) md5:$fhash"
[ ! -z "$ofhash" -a ! -z "$fhash" -a "$ofhash" != "$fhash" ] && show s $(lang "file chanage!" "文件发生变更")
[ ! -z "$ofhash" -a ! -z "$fhash" -a "$ofhash" == "$fhash" ] && show s $(lang "file no chanage!" "文件一致")
cp -f $src $dst
ln -s $(basename $dst) $link
else
show s $(lang "no file copy." "没有文件被复制")
fi
}
function action_make_package()
{
show i $(lang "make package" "编译package")
cd $op_dir
[ -z "$package_name" ] && exit 0
local pn="compile"
[ $make_package == true ] && pn="compile"
[ $make_package_install == true ] && pn="install"
[ $make_package_download == true ] && pn="download"
[ $make_package_clean == true ] && pn="clean"
[ $make_package_refresh == true ] && pn="refresh"
[ $make_package_index == true ] && pn="Index"
make defconfig
[ "$pn" == "Index" ] && make package/index || $doProxy make package/$package_name/$pn $doVerbose $doMakeJ
exit 0
}
function action_make_menu()
{
show i $(lang "make menuconfig" "执行menuconfig(openwrt功能定制)")
cd $op_dir
make menuconfig $doVerbose
exit 0
}
function action_make_kernel_menu()
{
show i $(lang "make kernel menuconfig" "执行kernel menuconfig(linux内核定制)")
cd $op_dir
make kernel_menuconfig $doVerbose
exit 0
}
function action_make_defconfig()
{
show i $(lang "make defconfig" "执行Openwrt配置依赖关系梳理(清除无效配置,检测并设置依赖关系)")
cd $op_dir
make defconfig $doVerbose
exit 0
}
function action_make_j()
{
[ ! -z "$make_j" ] && doMakeJ="" || doMakeJ="-j $make_j -l9"
}
function action_patch_openwrt()
{
show i $(lang "patch project(app)" "给当前openwrt打上项目应用补丁")
[ -z "$proj_name" ] && proj_name=$(./hardware_manage -gv pn)
cd $op_root
local board_type=$(./hardware_manage -gv pf)
$doProxy ./patch_openwrt.py proj -t $board_type $proj_name -w
}
function action_patch_platform()
{
show i $(lang "patch project(platform)" "给当前openwrt打上项目平台补丁")
cd $op_root
local board_platform=$(./hardware_manage -gv pf)
local board_type=$(./hardware_manage -gv bp)
[ -z "$patch_platform" ] && board_type="$patch_platform"
$doProxy ./patch_openwrt.py proj -t $board_platform $board_type -w -P
}
function action_patch_host()
{
show i $(lang "patch project(host)" "给当前openwrt打上项目交叉编译补丁")
cd $op_root
$doProxy ./patch_openwrt.py proj -H -w empty
}
function action_publish_upgrade()
{
show i $(lang "publish sysupgrade firmware info" "openwrt发布升级固件信息")
cd $op_root
local bn=$(./hardware_manage -gv bn)
local bt=$(./hardware_manage -gv bt)
local pf=$(./hardware_manage -gv pf)
local pn=$(./hardware_manage -gv pn)
local cn=$(./hardware_manage -gv cn)
local tr=$(./hardware_manage -gv tr)
local tl=$(./hardware_manage -gv tl)
local bf=$(./hardware_manage -gv bf)
local pbc=$(./hardware_manage -gv pbc)
local pbt=$(./hardware_manage -gv pbt)
local pbn=$(./hardware_manage -gv pbn)
local pbv=$(./hardware_manage -gv pbv)
local pbd=$(./hardware_manage -gv pbd)
local uu=$(./hardware_manage -gv uu)
local ua=$(./hardware_manage -gv ua)
local link="$tr/$tl"
local cfgfile=""
local ofile=$tr/$(basename $(readlink $link))
local nowdate=$(date +%Y-%m-%dT%H:%M:%S)
local ofhash=$(md5sum -b $ofile | awk '{print $1}')
local ofsize=$(ls -l $ofile | awk '{print $5}')
local ofdtime=$(stat -c %y $ofile | awk -F. '{print $1}' | awk '{print $1"T"$2}')
local gitcommit=$(git log -1 --format=%H)
local diffdata=$(git diff)
local ofver="v1.0.0-beta"
[ ! -z "$diffdata" ] && gitcommit="$gitcommit +"
opt=".platform.factory=\"$pf\""
opt="$opt | .platform.chip=\"$pbc\""
opt="$opt | .platform.boardtype=\"$pbt\""
opt="$opt | .platform.boardname=\"$pbn\""
opt="$opt | .platform.boardver=\"$pbv\""
opt="$opt | .platform.boarddate=\"$pbd\""
opt="$opt | .firmware.build=\"$nowdate\""
opt="$opt | .firmware.filename=\"$bf\""
opt="$opt | .firmware.md5=\"$ofhash\""
opt="$opt | .firmware.git=\"$gitcommit\""
opt="$opt | .firmware.publish=\"beta\""
opt="$opt | .upgrade.url=\"$uu\""
opt="$opt | .upgrade.useragent=\"$ua\""
# project-firstrun
cfgdir=$op_dir/custom-feeds/common-system-fix/$pn-firstuprun/files/etc
#echo $cfgdir
if [ -d $cfgdir/ ]; then
if [ -f $cfgdir/set-upgrade ]; then
cfgf=$(cat $cfgdir/set-upgrade)
else
cfgf="{}"
fi
fver=$(echo "$cfgf" | jq '.firmware.version' -r)
[ ! -z "$fver" ] && ofver="$fver"
echo "================================================="
echo " write : set-upgrade "
echo "================================================="
echo "$cfgf" | jq "$opt" -r
echo "$cfgf" | jq "$opt" -c > $cfgdir/set-upgrade
fi
# firstrun
cfgdir=$op_dir/custom-feeds/common-system-fix/firstuprun/files/etc
if [ -d $cfgdir ]; then
if [ -f $cfgdir/set-upgrade ]; then
cfgf=$(cat $cfgdir/set-upgrade)
else
cfgf="{}"
fi
fver=$(echo "$cfgf" | jq '.firmware.version' -r)
[ ! -z "$fver" ] && ofver="$fver"
echo "================================================="
echo " write : set-upgrade "
echo "================================================="
echo "$cfgf" | jq "$opt" -r
echo "$cfgf" | jq "$opt" -c > $cfgdir/set-upgrade
fi
urlfw=$(dirname $uu)
opt="$opt | .upgrade.mode=\"null\""
opt="$opt | .upgrade.firmware.url=\"$urlfw/$bf\""
opt="$opt | .upgrade.firmware.md5=\"$ofhash\""
opt="$opt | .upgrade.firmware.version=\"${ofver}-$ofhash\""
opt="$opt | .upgrade.firmware.size=\"$ofsize\""
opt="$opt | .upgrade.firmware.build=\"$ofdtime\""
cfgdir=$tr
if [ -d $cfgdir ]; then
if [ -f $cfgdir/$pn.json ]; then
cfgf=$(cat $cfgdir/$pn.json)
else
cfgf="{}"
fi
echo "================================================="
echo " write : $pn.json "
echo "================================================="
echo "$cfgf" | jq "$opt" -r
echo "$cfgf" | jq "$opt" -c > $cfgdir/$pn.json
fi
cfgdir=$tr
if [ -d $cfgdir ]; then
if [ -f $cfgdir/$pn.$pf.json ]; then
cfgf=$(cat $cfgdir/$pn.$pf.json)
else
cfgf="{}"
fi
echo "================================================="
echo " write : $pn.$pf.json "
echo "================================================="
echo "$cfgf" | jq "$opt" -r
echo "$cfgf" | jq "$opt" -c > $cfgdir/$pn.$pf.json
fi
# project-admin-ui
# cfgdir=$op_dir/custom-feeds/common-system-fix/$pn-admin-ui
# open-public-admin-ui
# cfgdir=$op_dir/custom-feeds/common-system-fix/open-public-admin-ui
}
function action_mount_fs()
{
show i $(lang "mount/umount remote server fs to localhost" "映射远程服务器地址到本机")
cd $op_root
local rr=$(./hardware_manage -gv rr)
local lr=$(./hardware_manage -gv lr)
[ -z "$rr" -o -z "$lr" ] && {
show i $(lang "error config" "配置错误")
exit 0
}
if [ ! -d "$lr" ]; then
mkdir -p "$lr"
else
local trr=$(df -h | grep ${lr:0:-1} | awk '{print $1}')
#echo $rr $trr
[ "$trr" == "$rr" ] && {
show i $(lang "remote fs exist" "远程目录已经mount挂载")
exit 0
}
[ ! -z "$trr" ] && sudo umount $lr
fi
show i $(lang "- sshfs: $rr mount at $lr" "- sshfs: $rr 挂载到 $lr")
sshfs $rr $lr
}
function action_umount_fs()
{
show i $(lang "mount/umount remote server fs to localhost" "映射远程服务器地址到本机")
cd $op_root
local rr=$(./hardware_manage -gv rr)
local lr=$(./hardware_manage -gv lr)
[ -z "$rr" -o -z "$lr" ] && {
show i $(lang "error config" "配置错误")
exit 0
}
local trr=$(df -h | grep ${lr:0:-1} | awk '{print $1}')
[ ! -z "$trr" ] && umount $lr
}
function action_upload_firmware()
{
show i $(lang "update firmware or all packages to remote server" "上传固件或所有包文件到远程服务器")
cd $op_root
local rr=$(./hardware_manage -gv rr)
local lr=$(./hardware_manage -gv lr)
[ -z "$rr" -o -z "$lr" ] && {
show i $(lang "error config" "配置错误")
exit 0
}
local trr=$(df -h | grep ${lr:0:-1} | awk '{print $1}')
#echo $trr
[ "$trr" != "$rr" -o ! -d "$lr" ] && {
#show i $(lang "need mount remote fs at local directory" "必须mount挂载远程目录")
#exit 0
action_mount_fs
}
#echo "111111111"
local bn=$(./hardware_manage -gv bn)
local bt=$(./hardware_manage -gv bt)
local pf=$(./hardware_manage -gv pf)
local pn=$(./hardware_manage -gv pn)
local cn=$(./hardware_manage -gv cn)
local tr=$(./hardware_manage -gv tr)
local tl=$(./hardware_manage -gv tl)
local bf=$(./hardware_manage -gv bf)
local pbc=$(./hardware_manage -gv pbc)
local pbt=$(./hardware_manage -gv pbt)
local pbn=$(./hardware_manage -gv pbn)
local pbv=$(./hardware_manage -gv pbv)
local pbd=$(./hardware_manage -gv pbd)
local uu=$(./hardware_manage -gv uu)
local ua=$(./hardware_manage -gv ua)
local link="$tr/$tl"
local cfgfile=""
local ofile=$tr/$(basename $(readlink $link))
local nowdate=$(date +%Y-%m-%dT%H:%M:%S)
local nowdt=$(date +%Y%m%dT%H%M%S)
local ofhash=$(md5sum -b $ofile | awk '{print $1}')
local ofsize=$(ls -l $ofile | awk '{print $5}')
local ofdtime=$(stat -c %y $ofile | awk -F. '{print $1}' | awk '{print $1"T"$2}')
local ofdt=$(date --date="$(stat -c %y $ofile)" +%Y%m%dT%H%M%S)
local nfsize=0
#echo $ofile
#echo $nowdate
#echo $ofhash
#echo $ofsize
#echo $ofdtime
local nd=$(realpath -s $lr/fw/$ofdt/)
local nfb=$nd/$(basename $ofile)
[ ! -d "$nd" -a -n "$nd" ] && mkdir -p "$nd"
[ -f "$ofile" ] && {
show i $(lang "copy firmware $ofile => $nfb" "拷贝固件 $ofile => $nfb")
[ -f "$nfb" ] && {
nfsize=$(ls -l $nfb | awk '{print $5}')
}
[ "$nfsize" -ne "$ofsize" ] && rsync -av --progress "$ofile" "$nfb"
show i $(lang "firmware size : $nfsize [remote] / $ofsize [local]" "固件大小 : $nfsize [远程] / $ofsize [本地]")
show i $(lang "firmware md5 : $ofhash" "固件 md5 : $ofhash")
cfgdir=$op_dir/custom-feeds/common-system-fix/$pn-firstuprun/files/etc
if [ -f "$cfgdir/set-upgrade" ]; then
#fc=$(cat $cfgdir/set-upgrade)
show i $(lang "copy set-upgrade" "拷贝 set-upgrade")
cp "$cfgdir/set-upgrade" "$nd/set-upgrade"
else
cfgdir=$op_dir/custom-feeds/common-system-fix/firstuprun/files/etc
if [ -f "$cfgdir/set-upgrade" ]; then
#fc=$(cat $cfgdir/set-upgrade)
show i $(lang "copy set-upgrade" "拷贝 set-upgrade")
cp "$cfgdir/set-upgrade" "$nd/set-upgrade"
fi
fi
cfgdir=$tr
if [ -f "$cfgdir/$pn.$pf.json" ]; then
show i $(lang "copy $pn.json" "拷贝 $pn.$pf.json")
cp "$cfgdir/$pn.$pf.json" "$nd/$pn.json"
elif [ -f "$cfgdir/$pn.json" ]; then
show i $(lang "copy $pn.json" "拷贝 $pn.$pf.json")
cp "$cfgdir/$pn.json" "$nd/$pn.json"
fi
}
fusermount -u $lr
}
doAction=false
op_root=$(get_wrtoy_path)
op_wrtoy_dir=$(get_wrtoy_path ..)
op_hp_dir=$(get_wrtoy_path profiles)
op_tl_dir=$(get_wrtoy_path ../tftproot)
op_dir=$(get_wrtoy_path ../openwrt)
doProxy=
proxy_port=7070
doVerbose=
doMakeJ=
#======================================================
help_feeds=$(lang \
"upgrade and install feeds" \
"升级并安装feeds(默认为安装全部feeds)")
addOption -f --feeds \
action=action_upgrade_feeds dest=feeds_name \
help="$help_feeds"
#======================================================
help_custom_feeds=$(lang \
"upgrade and install custom feeds (feeds: commonpack)" \
"升级并安装commonpack feeds仓库")
addOption -fc --feeds-commonpack \
flagTrue action=action_upgrade_custom_feeds dest=feeds_custom \
help="$help_custom_feeds"
#======================================================
help_use_proxy=$(lang \
"use sock5 proxy(proxychains support)" \
"使用sock5代理(proxychains支持)")
addOption -pc --proxychains \
flagTrue action=action_use_proxy dest=use_proxy \
help="$help_use_proxy"
#======================================================
help_install_new_openwrt=$(lang \
"install new Git source from Openwrt" \
"从Openwrt的Git中提取最新的源")
addOption -I --install-openwrt \
flagTrue action=action_install_new_openwrt dest=install_new_openwrt \
help="$help_install_new_openwrt"
#======================================================
help_reset_current_openwrt=$(lang \
"reset current Git source from Openwrt" \
"从Openwrt的Git中提取当前版本的源")
addOption -R --reset-openwrt \
flagTrue action=action_reset_current_openwrt dest=reset_current_openwrt \
help="$help_reset_current_openwrt"
#======================================================
help_install_release_openwrt=$(lang \
"install release version Git source from Openwrt" \
"从Openwrt的Git中提取项目release版本的源")
addOption -IR --install-release-openwrt \
flagTrue action=action_install_release_openwrt dest=install_release_openwrt \
help="$help_install_release_openwrt"
#======================================================
help_install_beta_openwrt=$(lang \
"install beta version Git source from Openwrt" \
"从Openwrt的Git中提取项目beta版本的源")
addOption -IB --install-beta-openwrt \
flagTrue action=action_install_beta_openwrt dest=install_beta_openwrt \
help="$help_install_beta_openwrt"
#======================================================
help_verbose=$(lang \
"show verbose" \
"显示更详细的信息")
addOption -v --verbose \
flagTrue action=action_verbose dest=verbose \
help="$help_verbose"
#======================================================
help_download=$(lang \
"download all package source code" \
"下载所有选中的package的源码")
help_downloadp=$(lang \
"download all package source code from sock5 proxy" \
"通过sock5代理下载所有选中的package的源码")
addOption -dl --download \
flagTrue dest=download_package \
help="$help_download"
addOption -dl+ --download-proxy \
flagTrue dest=download_proxy_package \
help="$help_download"
print $download_proxy_package
#======================================================
help_backup_config=$(lang \
"backup openwrt config" \
"备份openwrt配置")
addOption -bc --backup-config \
action=action_backup_config dest=backup_config \
help="$help_backup_config"
#======================================================
help_recover_config=$(lang \
"recover openwrt config" \
"恢复openwrt配置")
addOption -rc --recover-config \
action=action_recover_config dest=recover_config \
help="$help_recover_config"
#======================================================
help_show_diff_config=$(lang \
"show diff openwrt config" \
"显示openwrt配置差异")
addOption -dc --diff-config \
flagTrue dest=diff_config \
help="$help_show_diff_config"
#======================================================
help_show_diff_config_mode=$(lang \
"show diff openwrt config mode" \
"显示openwrt配置差异模式")
addOption -pm --patch-mode \
default="-" dest=pmode \
help="$help_show_diff_config_mode"
#======================================================
help_show_diff_config_p1=$(lang \
"show diff openwrt config file1" \
"openwrt配置文件1")
addOption -p1 --patch-file1 \
default="-" dest=p1 \
help="$help_show_diff_config_p1"
#======================================================
help_show_diff_config_p2=$(lang \
"show diff openwrt config file2" \
"openwrt配置文件2")
addOption -p2 --patch-file2 \
default="-" dest=p2 \
help="$help_show_diff_config_p2"
#======================================================
help_clear=$(lang \
"clear project" \
"清除项目数据")
help_cleart=$(lang \
"clear project tmp dir" \
"清除项目菜单缓存目录")
help_cleard=$(lang \
"clear project make dirclean" \
"清除项目中间编译缓存目录")
addOption -cl --clear \
flagTrue action=action_clear dest=clear\
help="$help_clear"
addOption -ct --clear-temp \
flagTrue action=action_clear dest=clear_temp \
help="$help_cleart"
addOption -cd --clear-dir \
flagTrue action=action_clear dest=clear_dir \
help="$help_cleard"
#======================================================
help_make_usb_image_disk=$(lang \
"make firmware image file to usbdisk(image mode)" \
"将指定u盘制作成启动盘(x86/rpi)")
addOption -iu --usb \
flagTrue action=action_make_usb_image_disk dest=usb_image\
help="$help_make_usb_image_disk"
#======================================================
help_show_publish_upgrade=$(lang \
"publish sysupgrade firmware info" \
"openwrt发布升级固件信息")
addOption -pu --publish-upgrade \
flagTrue dest=publish_upgrade \
help="$help_show_publish_upgrade"
#======================================================
help_copy_usb_image_disk=$(lang \
"copy firmware image file to usbdisk(copy mode)" \
"将镜像拷贝到指定u盘")
addOption -cu --usb-copy \
flagTrue action=action_copy_usb_image_disk dest=usb_copy\
help="$help_copy_usb_image_disk"
#======================================================
help_restart_tftp=$(lang \
"restart tftp server" \
"启动tftp服务")
addOption --tftp \
flagTrue action=action_restart_tftp dest=restart_tftp \
help="$help_restart_tftp"
#======================================================
help_build_image=$(lang \
"only build openwrt image" \
"仅生成openwrt镜像")
help_build_image_p=$(lang \
"only build openwrt image package install" \
"仅生成openwrt镜像-包集合")
help_build_image_l=$(lang \
"only build openwrt image linux install" \
"仅生成openwrt镜像-Linux")
help_build_image_i=$(lang \
"only build openwrt image package index" \
"仅生成openwrt镜像-包索引")
addOption -bi --build-image \
flagTrue dest=build_image \
help="$help_build_image"
addOption -bip --build-image-packages \
flagTrue dest=build_image_packages \
help="$help_build_image_p"
addOption -bil --build-image-linux \
flagTrue dest=build_image_linux \
help="$help_build_image_l"
addOption -bii --build-image-index \
flagTrue dest=build_image_index \
help="$help_build_image_i"
#======================================================
help_build=$(lang \
"build openwrt" \
"编译openwrt")
help_buildj=$(lang \
"build openwrt -j" \
"多线程编译openwrt")
addOption -b --build \
flagTrue dest=build_base \
help="$help_build"
addOption -bj --build-j \
dest=build_j\
help="$help_buildj"
#======================================================
help_copy=$(lang \
"copy firmware file to tftp root directory" \
"拷贝产生的固件文件到tftp的固件目录")
addOption -c --copy \
flagTrue dest=copy_tftp \
help="$help_copy"
#======================================================
help_package_name=$(lang \
"set package name" \
"设置package名称")
help_make_package=$(lang \
"make package" \
"编译package")
help_make_packagei=$(lang \
"install package" \
"安装package")
help_make_packaged=$(lang \
"download package source" \
"下载package源码")
help_make_packagec=$(lang \
"clean package" \
"清除package编译文件")
help_make_packager=$(lang \
"refresh package" \
"刷新package")
help_make_packageI=$(lang \
"Index package" \
"索引package")
addOption -pn --package-name \
dest=package_name \
help="$help_package_name"
addOption -mp --make-package \
flagTrue dest=make_package \
help="$help_make_package"
addOption -mpi --make-package-install \
flagTrue dest=make_package_install \
help="$help_make_packagei"
addOption -mpd --make-package-download \
flagTrue dest=make_package_download \
help="$help_make_packaged"
addOption -mpc --make-package-clean \
flagTrue dest=make_package_clean \
help="$help_make_packagec"
addOption -mpr --make-package-refresh \
flagTrue dest=make_package_refresh \
help="$help_make_packager"
addOption -mpI --make-package-index \
flagTrue dest=make_package_index \
help="$help_make_packageI"
#======================================================
help_make_j=$(lang \
"multi thread compiled" \
"执行多线程编译")
addOption -j \
action=action_make_j dest=make_j \
help="$help_make_menu_j"
#======================================================
help_make_menu=$(lang \
"make menuconfig" \
"执行menuconfig(openwrt功能定制)")
addOption -m --menu-config \
flagTrue action=action_make_menu dest=menu_config\
help="$help_make_menu"
#======================================================
help_make_kernel_menuconfig=$(lang \
"make kernel menuconfig" \
"执行kernel menuconfig(linux内核定制)")
addOption -km --kernel-menu-config \
flagTrue action=action_make_kernel_menu dest=kernel_menu_config\
help="$help_make_kernel_menuconfig"
#======================================================
help_make_defconfig=$(lang \
"make defconfig" \
"执行Openwrt配置依赖关系梳理(清除无效配置,检测并设置依赖关系)")
addOption -def --default-config \
flagTrue action=action_make_defconfig dest=make_defconfig\
help="$help_make_defconfig"
#======================================================
help_patch_openwrt=$(lang \
"patch project(app)" \
"给当前openwrt打上项目应用补丁")
addOption -po --patch-openwrt \
default=mtall action=action_patch_openwrt dest=proj_name \
help="$help_patch_openwrt"
#======================================================
help_patch_platform=$(lang \
"patch project(platform)" \
"给当前openwrt打上项目平台补丁")
addOption -pp --patch-platform \
flagTrue action=action_patch_platform dest=patch_platform\
help="$help_patch_platform"
#======================================================
help_patch_host=$(lang \
"patch project(host)" \
"给当前openwrt打上项目交叉编译平台补丁")
addOption -ph --patch-host \
flagTrue action=action_patch_host dest=patch_host\
help="$help_patch_host"
#======================================================
help_mount_fs=$(lang \
"mount remote fs to local" \
"mount远程目录到本地")
addOption -mf --mount-fs \
flagTrue action=action_mount_fs dest=mount_fs\
help="$help_mount_fs"
#======================================================
help_upload_fw=$(lang \
"upload new firmware to remote fs" \
"上传新固件到远程目录")
addOption -uf --upload-firmware \
flagTrue action=action_upload_firmware dest=upload_fw\
help="$help_upload_fw"
#addOption -P --platform \
# action=action_reset_last_openwrt \
# help="set platform"
parseOptions "$@"
#action_run $profile $debug
function action_run()
{
[ $diff_config == true ] && action_show_diff_config
[ $download_package == true -o $download_proxy_package == true ] && action_download_package
[ $make_package == true -o \
$make_package_install == true -o \
$make_package_download == true -o \
$make_package_clean == true -o \
$make_package_refresh == true -o \
$make_package_index == true ] && action_make_package
[ $build_base == true ] && action_build
[ $build_image == true ] && action_build_image
[ $build_image_packages == true ] && action_build_image_packages
[ $build_image_linux == true ] && action_build_image_linux
[ $build_image_index == true ] && action_build_image_index
[ $build_j ] && action_build
[ $copy_tftp == true ] && action_copy_tftp
[ $publish_upgrade == true ] && action_publish_upgrade
}
action_run
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。