#!/bin/sh # Copyright (c) 2024 Pedro # SPDX-License-Identifier: AGPL-3.0-or-later set -e set -u # DEBUG set -x install_dependencies() { apt update apt install -y wget dnsmasq nfs-kernel-server rsync } backup_file() { target="${1}" ts="$(date +'%Y-%m-%d_%H-%M-%S')" if [ -f "${target}" ]; then cp -a "${target}" "${target}_bak_${ts}" fi } install_nfs() { backup_file /etc/exports # debian live nfs path is readonly, do a trick # to make snapshots subdir readwrite if ! grep -q "/snapshots" /proc/mounts; then mount --bind "${nfs_path}/snapshots" "/snapshots" fi cat > /etc/exports < /etc/dnsmasq.d/pxe-tftp < "${tftp_path}/pxelinux.cfg/default" <