Pxe: miscellaneous changes #9
16
Dockerfile
Normal file
16
Dockerfile
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
|
# detect DOCKER_BUILD condition/situation in install script
|
||||||
|
ENV DOCKER_BUILD true
|
||||||
|
|
||||||
|
# pre install sudo
|
||||||
|
RUN apt update && apt install sudo && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
COPY ./install-dependencies.sh /
|
||||||
|
RUN /install-dependencies.sh \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /opt/workbench-script
|
||||||
|
|
||||||
|
ENTRYPOINT sh ./deploy-workbench.sh
|
|
@ -197,7 +197,15 @@ create_persistence_partition() {
|
||||||
tmp_rw_mount="/tmp/${rw_img_name}"
|
tmp_rw_mount="/tmp/${rw_img_name}"
|
||||||
${SUDO} umount -f -l "${tmp_rw_mount}" >/dev/null 2>&1 || true
|
${SUDO} umount -f -l "${tmp_rw_mount}" >/dev/null 2>&1 || true
|
||||||
mkdir -p "${tmp_rw_mount}"
|
mkdir -p "${tmp_rw_mount}"
|
||||||
${SUDO} mount "$(pwd)/${rw_img_path}" "${tmp_rw_mount}"
|
# detect relative path, else absolute path
|
||||||
|
# TODO solve this situation better
|
||||||
|
# thanks https://unix.stackexchange.com/questions/256434/check-if-shell-variable-contains-an-absolute-path
|
||||||
|
if [ "${rw_img_path}" = "${rw_img_path#/}" ]; then
|
||||||
|
mount_rw_img_path="$(pwd)/${rw_img_path}"
|
||||||
|
else
|
||||||
|
mount_rw_img_path="${rw_img_path}"
|
||||||
|
fi
|
||||||
|
${SUDO} mount "${mount_rw_img_path}" "${tmp_rw_mount}"
|
||||||
${SUDO} mkdir -p "${tmp_rw_mount}"
|
${SUDO} mkdir -p "${tmp_rw_mount}"
|
||||||
if [ ! -f "settings.ini" ]; then
|
if [ ! -f "settings.ini" ]; then
|
||||||
${SUDO} cp -v settings.ini.example settings.ini
|
${SUDO} cp -v settings.ini.example settings.ini
|
||||||
|
@ -324,14 +332,12 @@ END
|
||||||
echo 'Install requirements'
|
echo 'Install requirements'
|
||||||
|
|
||||||
# Install debian requirements
|
# Install debian requirements
|
||||||
|
# TODO converge more here with install-dependencies.sh
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
sudo locales keyboard-configuration console-setup qrencode \
|
sudo locales keyboard-configuration console-setup qrencode \
|
||||||
python-is-python3 python3 python3-dev python3-pip pipenv \
|
python-is-python3 python3 python3-dev python3-pip pipenv \
|
||||||
dmidecode smartmontools hwinfo pciutils lshw nfs-common < /dev/null
|
dmidecode smartmontools hwinfo pciutils lshw nfs-common < /dev/null
|
||||||
|
|
||||||
# Install lshw B02.19 utility using backports (DEPRECATED in Debian 12)
|
|
||||||
#apt install -y -t ${VERSION_CODENAME}-backports lshw < /dev/null
|
|
||||||
|
|
||||||
echo 'Install sanitize requirements'
|
echo 'Install sanitize requirements'
|
||||||
|
|
||||||
# Install sanitize debian requirements
|
# Install sanitize debian requirements
|
||||||
|
@ -432,8 +438,10 @@ if [ -z "${DEBUG:-}" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cleanup bash history
|
# cleanup bash history
|
||||||
history -c
|
# https://stackoverflow.com/questions/3199893/howto-detect-bash-from-shell-script
|
||||||
|
if [ "\${BASH_VERSION}" ]; then
|
||||||
|
history -c
|
||||||
|
fi
|
||||||
CHROOT
|
CHROOT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,31 +482,6 @@ prepare_chroot_env() {
|
||||||
prepare_app
|
prepare_app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# thanks https://willhaley.com/blog/custom-debian-live-environment/
|
|
||||||
install_requirements() {
|
|
||||||
# Install requirements
|
|
||||||
eval "${decide_if_update_str}" && decide_if_update
|
|
||||||
image_deps='debootstrap
|
|
||||||
squashfs-tools
|
|
||||||
xorriso
|
|
||||||
mtools
|
|
||||||
dosfstools'
|
|
||||||
# secureboot:
|
|
||||||
# -> extra src https://wiki.debian.org/SecureBoot/
|
|
||||||
# -> extra src https://wiki.debian.org/SecureBoot/VirtualMachine
|
|
||||||
# -> extra src https://wiki.debian.org/GrubEFIReinstall
|
|
||||||
bootloader_deps='isolinux
|
|
||||||
syslinux-efi
|
|
||||||
grub-pc-bin
|
|
||||||
grub-efi-amd64-bin
|
|
||||||
ovmf
|
|
||||||
grub-efi-amd64-signed'
|
|
||||||
${SUDO} apt-get install -y \
|
|
||||||
${image_deps} \
|
|
||||||
${bootloader_deps}
|
|
||||||
}
|
|
||||||
|
|
||||||
# thanks https://willhaley.com/blog/custom-debian-live-environment/
|
# thanks https://willhaley.com/blog/custom-debian-live-environment/
|
||||||
create_base_dirs() {
|
create_base_dirs() {
|
||||||
mkdir -p "${ISO_PATH}"
|
mkdir -p "${ISO_PATH}"
|
||||||
|
@ -523,7 +506,7 @@ detect_user() {
|
||||||
echo "ERROR: this script needs root or sudo permissions (current user is not part of sudo group)"
|
echo "ERROR: this script needs root or sudo permissions (current user is not part of sudo group)"
|
||||||
exit 1
|
exit 1
|
||||||
# detect user with sudo or already on sudo src https://serverfault.com/questions/568627/can-a-program-tell-it-is-being-run-under-sudo/568628#568628
|
# detect user with sudo or already on sudo src https://serverfault.com/questions/568627/can-a-program-tell-it-is-being-run-under-sudo/568628#568628
|
||||||
elif [ ! "\${userid}" = 0 ] || [ -n "\${SUDO_USER}" ]; then
|
elif [ ! "\${userid}" = 0 ] || [ -n "\${SUDO_USER:-}" ]; then
|
||||||
SUDO='sudo'
|
SUDO='sudo'
|
||||||
# jump to current dir where the script is so relative links work
|
# jump to current dir where the script is so relative links work
|
||||||
cd "\$(dirname "\${0}")"
|
cd "\$(dirname "\${0}")"
|
||||||
|
@ -532,7 +515,7 @@ detect_user() {
|
||||||
# detect pure root
|
# detect pure root
|
||||||
elif [ "\${userid}" = 0 ]; then
|
elif [ "\${userid}" = 0 ]; then
|
||||||
SUDO=''
|
SUDO=''
|
||||||
ISO_PATH="/opt/workbench"
|
ISO_PATH="/opt/workbench-script/iso"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
END
|
END
|
||||||
|
@ -553,7 +536,7 @@ main() {
|
||||||
|
|
||||||
create_base_dirs
|
create_base_dirs
|
||||||
|
|
||||||
install_requirements
|
echo 'Assuming that you already executed ./install-dependencies.sh'
|
||||||
|
|
||||||
prepare_chroot_env
|
prepare_chroot_env
|
||||||
|
|
||||||
|
|
13
docker-compose.yaml
Normal file
13
docker-compose.yaml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
services:
|
||||||
|
build-iso:
|
||||||
|
init: true
|
||||||
|
build: .
|
||||||
|
# this is needed to mount inside docker
|
||||||
|
privileged: true
|
||||||
|
# uncomment next two lines to test this
|
||||||
|
environment:
|
||||||
|
- DEBUG=true
|
||||||
|
volumes:
|
||||||
|
- .:/opt/workbench-script:ro
|
||||||
|
- ./iso:/opt/workbench-script/iso:rw
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Copyright (c) 2024 Pedro <copyright@cas.cat>
|
# Copyright (c) 2024 pangea.org Associació Pangea - Coordinadora Comunicació per a la Cooperació
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
@ -9,7 +9,52 @@ set -u
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
sudo apt install smartmontools lshw hwinfo dmidecode
|
sudo apt update
|
||||||
|
|
||||||
|
# system dependencies
|
||||||
|
host_deps='sudo'
|
||||||
|
# thanks https://stackoverflow.com/questions/23513045/how-to-check-if-a-process-is-running-inside-docker-container
|
||||||
|
if [ ! "${DOCKER_BUILD}" ]; then
|
||||||
|
host_deps="${host_deps} qemu-system"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# workbench deploy/builder image dependencies
|
||||||
|
image_deps='debootstrap
|
||||||
|
squashfs-tools
|
||||||
|
xorriso
|
||||||
|
mtools
|
||||||
|
dosfstools'
|
||||||
|
|
||||||
|
# workbench deploy/builder bootloader dependencies
|
||||||
|
# thanks https://willhaley.com/blog/custom-debian-live-environment/
|
||||||
|
# secureboot:
|
||||||
|
# -> extra src https://wiki.debian.org/SecureBoot/
|
||||||
|
# -> extra src https://wiki.debian.org/SecureBoot/VirtualMachine
|
||||||
|
# -> extra src https://wiki.debian.org/GrubEFIReinstall
|
||||||
|
bootloader_deps='isolinux
|
||||||
|
syslinux-efi
|
||||||
|
syslinux-common
|
||||||
|
grub-pc-bin
|
||||||
|
grub-efi-amd64-bin
|
||||||
|
ovmf
|
||||||
|
shim-signed
|
||||||
|
grub-efi-amd64-signed'
|
||||||
|
|
||||||
|
# workbench-script client dependencies
|
||||||
|
client_deps='smartmontools
|
||||||
|
lshw
|
||||||
|
hwinfo
|
||||||
|
dmidecode
|
||||||
|
inxi
|
||||||
|
python3
|
||||||
|
pipenv'
|
||||||
|
|
||||||
|
# install all
|
||||||
|
sudo apt install --no-install-recommends -y \
|
||||||
|
${host_deps} \
|
||||||
|
${image_deps} \
|
||||||
|
${bootloader_deps} \
|
||||||
|
${client_deps}
|
||||||
}
|
}
|
||||||
|
|
||||||
main "${@}"
|
main "${@}"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
server_ip=192.168.1.2
|
# assuming server_ip using qemu
|
||||||
nfs_allowed_lan=192.168.1.0/24
|
server_ip=10.0.2.1
|
||||||
|
nfs_allowed_lan=10.0.2.0/24
|
||||||
tftp_path='/srv/pxe-tftp'
|
tftp_path='/srv/pxe-tftp'
|
||||||
nfs_path='/srv/pxe-nfs'
|
nfs_path='/srv/pxe-nfs'
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
|
.PHONY: test_pxe
|
||||||
test_pxe:
|
test_pxe:
|
||||||
qemu-system-x86_64 -m 1G -boot n -netdev user,id=mynet0,tftp=/srv/pxe-tftp,bootfile=pxelinux.0 -device virtio-net,netdev=mynet0
|
qemu-system-x86_64 -m 1G -boot n -netdev user,id=mynet0,tftp=/srv/pxe-tftp,bootfile=pxelinux.0 -device virtio-net,netdev=mynet0
|
||||||
|
|
||||||
|
# TODO not very convinced on having this, but ok right now
|
||||||
|
.PHONY: install_pxe_debug
|
||||||
|
install_pxe_debug:
|
||||||
|
DEBUG=true ./install-pxe.sh
|
||||||
|
|
Loading…
Reference in a new issue