Last active
September 2, 2021 16:21
-
-
Save elseym/4614b8d1937b1206593053a72f544950 to your computer and use it in GitHub Desktop.
openwrt stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ash | |
while [ $# -gt 0 ]; do case "${1}" in | |
-f|--force) force="y";; | |
-r|--renew|--redownload) renew="y";; | |
-d|--destination) shift; dest_dir="${1}";; | |
-i|--dnsmasq_instance) shift; dnsmasq_instance="${1}";; | |
-t|--types|--imagetypes|--images) shift; images="${1}";; | |
esac; shift; done | |
dnsmasq_instance="${dnsmasq_instance:-"0"}" | |
images="${images:-".efi .kpxe -arm64.efi -rpi4-snp.efi"}" | |
tftp_enabled="$(uci -q get dhcp.@dnsmasq[${dnsmasq_instance}].enable_tftp)" | |
tftp_root="$(uci -q get dhcp.@dnsmasq[${dnsmasq_instance}].tftp_root)" | |
[ "${tftp_enabled}" = "1" -o "${force}" = "y" ] || exit 1 | |
dest_dir="${dest_dir:-${tftp_root:-"/tmp/tftpboot"}}" | |
mkdir -p "${dest_dir}" | |
for image in $images; do file="${dest_dir}/netboot.xyz${image}" | |
[ "${renew}" = "y" ] && rm -f "${file}" | |
[ -e "${file}" ] || wget -T 5 -O "${file}" "https://boot.netboot.xyz/ipxe/${file##*/}" | |
done | |
chmod -R a+r "${dest_dir}" | |
chmod a+x "${dest_dir}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkgistbin() { f="/usr/bin/${1##*/}"; wget -T 5 -O "${f}" "${1}"; chmod +x "${f}"; } | |
mkgistbin "https://gist.github.com/elseym/4614b8d1937b1206593053a72f544950/raw/f36de6d8993d878d530e8b59bd217315b655b15c/netboot.xyz" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment