You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
211 lines
9.1 KiB
211 lines
9.1 KiB
#!/bin/bash |
|
|
|
[ "${alias_dir}" = "" ] && alias_dir=$(pwd) |
|
source "${alias_dir}/common" |
|
|
|
openwrt_make_mini_openwrt_image_prep_install() |
|
{ |
|
printf "Установка компонентов для sshd openwrt_make_mini_openwrt_image\n" |
|
ask_continue && return |
|
sudo apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk git ccache gettext libssl-dev xsltproc |
|
#17.01 |
|
sudo apt-get install zlib-devel-static |
|
} |
|
mkalias_with_prefix 'openwrt_make_mini_openwrt_image_prep_install' |
|
|
|
openwrt_make_mini_openwrt_image() |
|
{ |
|
printf "Загрузка sshd\n" |
|
ask_continue && return |
|
image_builder_url=$1 |
|
pkg=$2 |
|
#image_builder_url="https://downloads.openwrt.org/releases/17.01.7/targets/brcm47xx/legacy/lede-imagebuilder-17.01.7-brcm47xx-legacy.Linux-x86_64.tar.xz" |
|
image_builder_url="https://downloads.openwrt.org/releases/19.07.7/targets/brcm47xx/legacy/openwrt-imagebuilder-19.07.7-brcm47xx-legacy.Linux-x86_64.tar.xz" |
|
#image_builder_url="https://downloads.openwrt.org/releases/22.03.7/targets/bcm47xx/legacy/openwrt-imagebuilder-22.03.7-bcm47xx-legacy.Linux-x86_64.tar.xz" |
|
#image_builder_url="https://downloads.openwrt.org/releases/18.06.9/targets/brcm47xx/legacy/openwrt-imagebuilder-18.06.9-brcm47xx-legacy.Linux-x86_64.tar.xz" |
|
|
|
file_name="${image_builder_url##*/}" |
|
base="${file_name%.[^.]*.[^.]*}" |
|
ext="${file_name:${#base} + 1}" |
|
|
|
image_builder_file=${file_name} |
|
image_builder_dir=${base} |
|
|
|
echo ${file_name} ${base} ${ext} |
|
|
|
[ -f ./${image_builder_file} ] || wget ${image_builder_url} |
|
|
|
[ -d ./${image_builder_dir} ] || tar -xf ${image_builder_file} |
|
|
|
n2n_ipk="n2n-edge_HEAD-1_mipsel_mips32.ipk" |
|
n2n_add="" |
|
|
|
! [ -f ./${n2n_ipk} ] || n2n_add="libcap kmod-tun n2n-edge" |
|
cp ${n2n_ipk} ${image_builder_dir}/packages/${n2n_ipk} |
|
cp ${n2n_ipk} ${image_builder_dir}/package/${n2n_ipk} |
|
|
|
cd ${image_builder_dir} |
|
|
|
make image V=s PROFILE=standard PACKAGES="${pkg}" |
|
# FILES=files/ |
|
|
|
make V=s info |
|
|
|
find . -name "*.trx" |
|
find . -name "root.squashfs" |
|
find . -name "*kernel.bin" |
|
} |
|
|
|
#image_builder_url= |
|
|
|
openwrt_make_mini_openwrt_image_17_01() |
|
{ |
|
printf "Создание mini_openwrt_image для версии 17_01\n" |
|
ask_continue && return |
|
url="https://downloads.openwrt.org/releases/17.01.7/targets/brcm47xx/legacy/lede-imagebuilder-17.01.7-brcm47xx-legacy.Linux-x86_64.tar.xz" |
|
pkg="base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd swconfig -wpad-mini nvram otrx -kmod-leds-gpio -kmod-gpio-button-hotplug -kmod-ledtrig-default-on -kmod-ledtrig-timer -kmod-ledtrig-netdev dnsmasq iptables -ip6tables -ppp -ppp-mod-pppoe firewall odhcpd -odhcp6c -kmod-b43" |
|
# block-mount kmod-usb-storage kmod-fs-ext4 kmod-usb-ohci kmod-usb2 ${n2n_add}" |
|
openwrt_make_mini_openwrt_image "${url}" "${pkg}" |
|
} |
|
mkalias_with_prefix 'openwrt_make_mini_openwrt_image_17_01' |
|
|
|
openwrt_make_mini_openwrt_image_18_06() |
|
{ |
|
printf "Создание mini_openwrt_image для версии 18_06\n" |
|
ask_continue && return |
|
url="https://downloads.openwrt.org/releases/18.06.9/targets/brcm47xx/legacy/openwrt-imagebuilder-18.06.9-brcm47xx-legacy.Linux-x86_64.tar.xz" |
|
pkg="-lcui -ppp -ppp-mod-pppoe base-files busybox dnsmasq dropbear firewall fstools -ip6tables iptables kernel -kmod-b43 -kmod-gpio-button-hotplug -kmod-ipt-offload -kmod-leds-gpio -kmod-ledtrig-default-on -kmod-ledtrig-netdev -kmod-ledtrig-timer libc libgcc logd mtd netifd nvram odhcp6c -odhcpd-ipv6only opkg otrx swconfig uci uclient-fetch -wpad-mini" |
|
# 'block-mount kmod-usb-storage kmod-fs-ext4 kmod-usb-ohci kmod-usb2 ${n2n_add}' |
|
openwrt_make_mini_openwrt_image "${url}" "${pkg}" |
|
} |
|
mkalias_with_prefix 'openwrt_make_mini_openwrt_image_18_06' |
|
|
|
openwrt_make_mini_openwrt_image_19_07() |
|
{ |
|
printf "Создание mini_openwrt_image для версии 19_07\n" |
|
ask_continue && return |
|
url="https://downloads.openwrt.org/releases/19.07.7/targets/brcm47xx/legacy/openwrt-imagebuilder-19.07.7-brcm47xx-legacy.Linux-x86_64.tar.xz" |
|
pkg="-lcui -ppp -ppp-mod-pppoe base-files busybox dnsmasq dropbear firewall fstools -ip6tables iptables kernel -kmod-b43 -kmod-gpio-button-hotplug -kmod-ipt-offload -kmod-leds-gpio -kmod-ledtrig-default-on -kmod-ledtrig-netdev -kmod-ledtrig-timer libc libgcc logd mtd netifd nvram odhcp6c -odhcpd-ipv6only opkg otrx swconfig uci uclient-fetch -wpad-mini" |
|
# 'block-mount kmod-usb-storage kmod-fs-ext4 kmod-usb-ohci kmod-usb2 ${n2n_add}' |
|
openwrt_make_mini_openwrt_image "${url}" "${pkg}" |
|
} |
|
mkalias_with_prefix 'openwrt_make_mini_openwrt_image_19_07' |
|
|
|
openwrt_make_mini_openwrt_image_22_03() |
|
{ |
|
printf "Создание mini_openwrt_image для версии 22_03\n" |
|
ask_continue && return |
|
url="https://downloads.openwrt.org/releases/22.03.7/targets/bcm47xx/legacy/openwrt-imagebuilder-22.03.7-bcm47xx-legacy.Linux-x86_64.tar.xz" |
|
pkg="base-files busybox ca-bundle dnsmasq dropbear firewall4 fstools kernel -kmod-b43 -kmod-gpio-button-hotplug -kmod-leds-gpio -kmod-nft-offload libc libgcc -libustream-wolfssl logd -mtd netifd -nftables nvram odhcp6c -odhcpd-ipv6only opkg otrx -ppp -ppp-mod-pppoe procd -procd-seccomp swconfig uci uclient-fetch urandom-seed -urngd -wpad-basic-wolfssl" |
|
# block-mount kmod-usb-storage kmod-fs-ext4 kmod-usb-ohci kmod-usb2 ${n2n_add}" |
|
openwrt_make_mini_openwrt_image "${url}" "${pkg}" |
|
} |
|
mkalias_with_prefix 'openwrt_make_mini_openwrt_image_22_03' |
|
|
|
openwrt_upload_by_tftp() |
|
{ |
|
url=$1 |
|
file_name="${url##*/}" |
|
|
|
[ "$url" = "" ] && printf "Укажите url для скачивания, например 'http://downloads.openwrt.org/backfire/10.03/brcm47xx/openwrt-brcm47xx-squashfs.trx' или полный путь к файлу\n" && return |
|
printf "Загрузка openwrt на роутер через tftp. Подойдёт например для asus_wl520gu или asus_wl500pgv2. Внимание! В текущую папру произойдёт загрузка файла ${file_name}\n" |
|
ask_continue && return |
|
|
|
[ -f ./${file_name} ] || wget "${url}" |
|
|
|
atftp --trace --option "timeout 10" --option "mode octet" --put --local-file "${file_name}" 192.168.1.1 |
|
} |
|
mkalias_with_prefix 'openwrt_upload_by_tftp' |
|
|
|
openwrt_upload_backfire_10_03_by_tftp() |
|
{ |
|
url="http://downloads.openwrt.org/backfire/10.03/brcm47xx/openwrt-brcm47xx-squashfs.trx" |
|
openwrt_upload_by_tftp ${url} |
|
} |
|
mkalias_with_prefix 'openwrt_upload_backfire_10_03_by_tftp' |
|
|
|
openwrt_upload_22_03_by_tftp() |
|
{ |
|
url="https://downloads.openwrt.org/releases/22.03.7/targets/bcm47xx/legacy/openwrt-22.03.7-bcm47xx-legacy-asus_wl-500gp-v2-squashfs.trx" |
|
|
|
openwrt_upload_by_tftp ${url} |
|
} |
|
mkalias_with_prefix 'openwrt_upload_22_03_by_tftp' |
|
|
|
openwrt_progs_install() |
|
{ |
|
out=' |
|
# On router by: ssh root@192.168.1.1 |
|
# Для внешнего ЖД |
|
opkg install block-mount kmod-usb-storage kmod-usb-ohci kmod-fs-ext4 kmod-usb2 |
|
opkg install mc |
|
opkg install hd-idle |
|
# set enabled to 1 in hd-idle config |
|
vi /etc/config/hd-idle |
|
' |
|
echo "${out}" |
|
} |
|
mkalias_with_prefix 'openwrt_progs_install' |
|
|
|
openwrt_n2n_make_ipk() |
|
{ |
|
progs='# Ubuntu |
|
sudo apt-get install gcc-multilib g++-multilib git libncurses-dev gawk perl python3-distutils' |
|
#-sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 10 |
|
# AltLinux - не удалось запустить |
|
#sudo apt-get install perl-IPC-Cmd perl-CPAN |
|
#cpan JSON |
|
|
|
printf "Компиляция n2n для openwrt. Внимание в тукущую дирректуроию произойдёт загрузка исходников. Перед запуском рекомендуется установить программы ${progs}\n" |
|
ask_continue && return |
|
|
|
# wl500gpv2 https://archive.openwrt.org/releases/22.03.0/targets/bcm47xx/legacy/openwrt-sdk-22.03.0-bcm47xx-legacy_gcc-11.2.0_musl.Linux-x86_64.tar.xz |
|
|
|
# wl520gu url="https://downloads.openwrt.org/releases/19.07.6/targets/brcm47xx/legacy/openwrt-sdk-19.07.6-brcm47xx-legacy_gcc-7.5.0_musl.Linux-x86_64.tar.xz" # Fix gcc version include/prereq-build.mk: grep -E '^(4\.[8-9]|[5-9]\.?|13\.?)' |
|
|
|
# dir 620 c1 (asus_rt-n15u) url="https://downloads.openwrt.org/releases/23.05.5/targets/bcm47xx/mips74k/openwrt-sdk-23.05.5-bcm47xx-mips74k_gcc-12.3.0_musl.Linux-x86_64.tar.xz" |
|
|
|
# wl520gu 17.01.7 |
|
url="https://archive.openwrt.org/releases/17.01.7/targets/brcm47xx/legacy/lede-sdk-17.01.7-brcm47xx-legacy_gcc-5.4.0_musl-1.1.16.Linux-x86_64.tar.xz" |
|
|
|
file_name="${url##*/}" |
|
base="${file_name%.[^.]*.[^.]*}" |
|
ext="${file_name:${#base} + 1}" |
|
|
|
sdk_name=${base} |
|
sdk=${file_name} |
|
|
|
[ -f ./${sdk} ] || wget "${url}" |
|
|
|
[ -d ./${sdk_name} ] || tar -xf "${sdk}" |
|
|
|
[ -f ./n2n ] || git clone https://github.com/ntop/n2n n2n |
|
|
|
N2N_PKG_VERSION=$(n2n/scripts/version.sh) |
|
echo $N2N_PKG_VERSION |
|
|
|
cp -r n2n/packages/openwrt ${sdk_name}/package/n2n |
|
|
|
cd ${sdk_name} |
|
|
|
make oldconfig |
|
|
|
make package/n2n/clean V=s |
|
|
|
make package/n2n/prepare USE_SOURCE_DIR=$(realpath ../n2n) V=s |
|
|
|
make package/n2n/compile V=s |
|
|
|
find . -name "n2n*.ipk" |
|
} |
|
mkalias_with_prefix 'openwrt_n2n_make_ipk' |
|
|
|
openwrt_() |
|
{ |
|
printf "Загрузка\n" |
|
ask_continue && return |
|
} |
|
#mkalias_with_prefix 'openwrt_' |
|
|
|
|
|
|
|
|