Commit 99cdec02 authored by nanahira's avatar nanahira

pxe

parent a395f58b
#!ipxe
:global_vars
# set site name
set site_name MyCard Boot
# set boot domain
set boot_domain {{services.address}}:16980
# set location of memdisk
set memdisk http://${boot_domain}/memdisk
# set location of custom netboot.xyz live assets
set live_endpoint https://github.com/netbootxyz
# signature check enabled?
set sigs_enabled false
# set location of signatures for sources
set sigs http://boot.netboot.xyz/sigs/
# set location of latest iPXE
iseq ${platform} efi && set ipxe_disk netboot.xyz-snponly.efi || set ipxe_disk netboot.xyz-undionly.kpxe
# set default boot timeout
set boot_timeout 10000
######################################
# Media Locations for Licensed Distros
######################################
set rhel_base_url
set win_base_url
##################
# official mirrors
##################
:mirrors
### Alpine Linux
set alpinelinux_mirror http://mirrors.tuna.tsinghua.edu.cn
set alpinelinux_base_dir alpine
### Arch Linux
set archlinux_mirror mirrors.tuna.tsinghua.edu.cn
set archlinux_base_dir archlinux
### CentOS
set centos_mirror http://mirrors.tuna.tsinghua.edu.cn
set centos_base_dir centos
### Debian
{% if dnsmasq.aptCacher is defined and dnsmasq.aptCacher %}
set debian_mirror http://deb.debian.org
{% else %}
set debian_mirror http://mirrors.tuna.tsinghua.edu.cn
{% endif %}
set debian_base_dir debian
### Devuan
set devuan_mirror http://deb.devuan.org
set devuan_base_dir devuan
### Fedora
set fedora_mirror http://mirrors.tuna.tsinghua.edu.cn
set fedora_base_dir fedora
### Fedora CoreOS
set coreos_mirror https://builds.coreos.fedoraproject.org
set coreos_base_dir prod/streams
### FreeDOS
set freedos_mirror http://www.freedos.org
set freedos_base_dir download/download
### IPFire
set ipfire_mirror https://downloads.ipfire.org
set ipfire_base_dir releases/ipfire-2.x
### Kali Linux
set kali_mirror http://mirrors.tuna.tsinghua.edu.cn
set kali_base_dir kali
### Mageia
set mageia_mirror http://mirrors.tuna.tsinghua.edu.cn
set mageia_base_dir mageia
### OpenBSD
set openbsd_mirror http://mirrors.tuna.tsinghua.edu.cn
set openbsd_base_dir OpenBSD
### OpenSUSE
set opensuse_mirror http://mirrors.tuna.tsinghua.edu.cn
set opensuse_base_dir opensuse/distribution/leap
### RancherOS
set rancheros_mirror http://releases.rancher.com
set rancheros_base_dir os/latest
### Scientific Linux
set scientific_mirror http://ftp1.scientificlinux.org
set scientific_base_dir linux/scientific
### Slackware
set slackware_mirror http://mirror.rackspace.com
set slackware_base_dir slackware
### SmartOS
set smartos_mirror https://netboot.joyent.com/os/
set smartos_base_dir /platform/i86pc/
### Ubuntu
{% if dnsmasq.aptCacher is defined and dnsmasq.aptCacher %}
set ubuntu_mirror http://archive.ubuntu.com
{% else %}
set ubuntu_mirror http://mirrors.tuna.tsinghua.edu.cn
{% endif %}
set ubuntu_base_dir ubuntu
#################################################
# determine architectures and enable menu options
#################################################
:architectures
set menu_linux 1
set menu_bsd 1
set menu_unix 1
set menu_freedos 1
set menu_live 1
set menu_windows 1
set menu_utils 1
iseq ${buildarch} i386 && goto x86_64 ||
iseq ${buildarch} x86_64 && goto x86_64 ||
iseq ${buildarch} arm64 && goto arm64 ||
goto architectures_end
:x86_64
iseq ${platform} efi && goto efi ||
goto architectures_end
:arm64
set menu_linux 0
set menu_linux_arm 1
set menu_unix 0
set menu_freedos 0
set menu_live 0
set menu_live_arm 1
set menu_security 0
set menu_windows 0
set menu_utils 0
set menu_utils_arm 1
iseq ${platform} efi && goto efi ||
goto architectures_end
:efi
set menu_bsd 0
set menu_freedos 0
set menu_security 0
goto architectures_end
:architectures_end
goto clouds
###################################
# set iPXE cloud provider specifics
###################################
:clouds
iseq ${ipxe_cloud_config} gce && goto gce ||
iseq ${ipxe_cloud_config} packet && goto packet ||
goto clouds_end
:gce
set cmdline console=ttyS0,115200n8
goto clouds_end
:packet
iseq ${buildarch} i386 && goto packet_x86_64 ||
iseq ${buildarch} x86_64 && goto packet_x86_64 ||
iseq ${buildarch} arm64 && goto packet_arm64 ||
goto clouds_end
:packet_x86_64
set cmdline console=ttyS1,115200n8
iseq ${platform} efi && set ipxe_disk netboot.xyz-packet.efi || set ipxe_disk netboot.xyz-packet.kpxe
set menu_freedos 0
set menu_windows 0
set menu_utils 0
goto clouds_end
:packet_arm64
set cmdline console=ttyAMA0,115200
set ipxe_disk netboot.xyz-packet-arm64.efi
set menu_bsd 0
set menu_freedos 0
set menu_live 0
set menu_security 0
set menu_windows 0
set menu_utils 0
goto clouds_end
:clouds_end
goto end
:end
exit
#!ipxe
# CentOS Operating System
# http://www.centos.org
isset ${dhcp-server} && set ipparam ip=dhcp || set ipparam ip=${ip}::${gateway}:${netmask}:::none nameserver=${dns}
set ipparam BOOTIF=${netX/mac} ${ipparam}
goto ${menu} ||
:centos
clear osversion
set os CentOS
menu ${os} - ${arch}
item 8 ${space} ${os} 8.x Latest
item 8-stream ${space} ${os} 8.0 Stream
item 7 ${space} ${os} 7.x Latest
isset ${osversion} || choose osversion || goto linux_menu
echo ${cls}
set dir ${centos_base_dir}/${osversion}/BaseOS/${arch}/os
iseq ${osversion} 7 && set dir ${centos_base_dir}/${osversion}/os/${arch} ||
set repo ${centos_mirror}/${dir}
goto boottype
:boottype
set ova ${os} ${osversion}
menu ${os} ${arch} boot type
item graphical ${ova} graphical installer
item text ${ova} text based installer
item rescue ${ova} rescue
item kickstart ${ova} set kickstart url [ ${ksurl} ]
item kickstart_device ${ova} set ksdevice [ ${ksdevice} ]
isset ${bt} || choose bt || goto centos
echo ${cls}
iseq ${bt} text && goto text ||
iseq ${bt} rescue && goto rescue ||
iseq ${bt} kickstart && goto kickstart ||
iseq ${bt} kickstart_device && goto kickstart_device ||
goto bootos_images
:text
set params text ||
goto bootos_images
:rescue
set params rescue ||
goto bootos_images
:kickstart
echo -n Specify kickstart URL for ${os} ${osversion}: && read ksurl
set params inst.ks=${ksurl} ||
clear bt
goto boottype
:kickstart_device
echo -n Specify ksdevice param for ${os} ${osversion}: && read ksdevice
set ksdevice ${ksdevice} ||
clear bt
goto boottype
:bootos_images
imgfree
kernel ${centos_mirror}/${dir}/images/pxeboot/vmlinuz inst.repo=${repo} ${params} ${ipparam} initrd=initrd.img ${cmdline}
initrd ${centos_mirror}/${dir}/images/pxeboot/initrd.img
echo
echo MD5sums:
md5sum vmlinuz initrd.img
boot
goto linux_menu
:linux_menu
clear menu
exit 0
......@@ -38,8 +38,13 @@ services:
image: linuxserver/netbootxyz
environment:
PUID: {{ansible_user_uid}}
PGID: {{ansible_user_gid}}
- '{{services.address}}:69:69/udp'
PGID: {{ansible_user_gid}}
ports:
- '69:69/udp'
- '{{services.address}}:16980:80'
volumes:
- ./pxe/data:/assets:ro
- ./pxe/menus:/config/menus
{% endif %}
{% if services.ddns is defined and services.ddns %}
{% for instance in services.ddns %}
......
......@@ -17,7 +17,7 @@
src: ./files/bridge-post-scripts/pre-down.sh.j2
dest: '{{ansible_user_dir}}/nextgen-router/scripts/{{br.name}}/pre-down.sh'
mode: 0755
- name: pre-down script
- name: post-down script
template:
src: ./files/bridge-post-scripts/post-down.sh.j2
dest: '{{ansible_user_dir}}/nextgen-router/scripts/{{br.name}}/post-down.sh'
......
......@@ -28,3 +28,15 @@ grep -P '^bogus-nxdomain=.+$' dnsmasq-china-list/bogus-nxdomain.china.conf | sed
# cd ..
curl -sL https://cokebar.github.io/gfwlist2dnsmasq/dnsmasq_gfwlist_ipset.conf | grep -P '^ipset=' > ./data/gfwlist-ipset.conf
MENU_VERSION=$(curl -sL "https://api.github.com/repos/netbootxyz/netboot.xyz/releases/latest" | jq -r '.tag_name')
echo "Netboot version: ${MENU_VERSION}"
cd data
wget -m http://boot.netboot.xyz
wget -O boot.netboot.xyz/memdisk http://boot.netboot.xyz/memdisk
mkdir pxe-menus
wget -O - https://github.com/netbootxyz/netboot.xyz/releases/download/${MENU_VERSION}/menus.tar.gz | tar zxf - -C ./pxe-menus/
rm -rf pxe-menus/boot.cfg
cp -rf boot.netboot.xyz/ipxe/netboot.xyz* ./pxe-menus/
cp -rf ../files/pxe/centos.ipxe ./pxe-menus/
cd ..
......@@ -11,7 +11,17 @@
template:
src: ./files/services/docker-compose.yml.j2
dest: '{{ansible_user_dir}}/nextgen-router/services/others/docker-compose.yml'
- name: pxe things
include_tasks: ./tasks/pxe.yaml
when: dnsmasq.pxe is defined and dnsmasq.pxe == "localhost"
- name: start services
docker_compose:
project_src: '{{ansible_user_dir}}/nextgen-router/services/others'
remove_orphans: true
handlers:
- name: restart_pxe
docker_compose:
project_src: '{{ansible_user_dir}}/nextgen-router/services/others'
restarted: true
services:
- pxe
- name: pxe data directory
file:
path: '{{ansible_user_dir}}/nextgen-router/services/others/pxe/data'
state: directory
recurse: true
- name: pxe menus directory
file:
path: '{{ansible_user_dir}}/nextgen-router/services/others/pxe/menus/local'
state: directory
recurse: true
- name: boot.cfg
template:
src: ../files/pxe/boot.cfg.j2
dest: '{{ansible_user_dir}}/nextgen-router/services/others/pxe/menus/boot.cfg'
notify: restart_pxe
- name: pxe disks
synchronize:
src: ../data/boot.netboot.xyz/
dest: '{{ansible_user_dir}}/nextgen-router/services/others/pxe/data'
delete: true
recursive: yes
verify_host: no
checksum: yes
archive: no
notify: restart_pxe
- name: pxe menus
synchronize:
src: ../data/pxe-menus/
dest: '{{ansible_user_dir}}/nextgen-router/services/others/pxe/menus'
recursive: yes
verify_host: no
checksum: yes
archive: no
notify: restart_pxe
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment