<commit_before>#!/bin/sh
# Configure this (virtual) host as an eReuse PXE server.
#
# This is meant to be run when generating the server OVA.

# Remove unnecessary packages.
apt-get -qq purge @PKGS_TO_REMOVE@ thermald plymouth

# Install needed packages.
# Enable additional packages like VirtualBox's.
sed -i -e 's/ main/ main multiverse/' /etc/apt/sources.list
apt-get -qq update
apt-get -qq --no-install-recommends install virtualbox-guest-dkms

# Enable VirtualBox's shared folder module.
cat << 'EOF' > /etc/modules-load.d/ereuse.conf
# To share eReuse's data folder with the VirtualBox host.
vboxsf
EOF

# Rebuild initramfs if missing.
if [ ! -f /initrd.img ]; then
    update-initramfs -u
fi

# Avoid attempting graphical login and get a console login prompt.
sed -i -r -e 's/^(GRUB_HIDDEN_.*)/#\1/' -e 's/quiet splash/quiet/' /etc/default/grub
# Fix boot loader.
update-grub
grub-install $(findmnt -no SOURCE / | sed -r 's/p?[0-9]+$//')

# Setup users.<commit_msg>Pending server packages, DHCP configuration.<commit_after>#!/bin/sh
# Configure this (virtual) host as an eReuse PXE server.
#
# This is meant to be run when generating the server OVA.

# Remove unnecessary packages.
apt-get -qq purge @PKGS_TO_REMOVE@ thermald plymouth

# Install needed packages.
# Enable additional packages like VirtualBox's.
sed -i -e 's/ main/ main multiverse/' /etc/apt/sources.list
apt-get -qq update
apt-get -qq --no-install-recommends install virtualbox-guest-dkms \
        isc-dhcp-server tftpd-hpa nfs-kernel-server samba

# Enable VirtualBox's shared folder module.
cat << 'EOF' > /etc/modules-load.d/ereuse.conf
# To share eReuse's data folder with the VirtualBox host.
vboxsf
EOF

# Configure the DHCP server.
address=$(ip -4 addr show dev eth0 | sed -nr 's/.*\binet ([^/]+).*/\1/p')
netpfx24=$(echo $address | cut -f1-3 -d.)  # assume /24
nameservers=$(sed -rn 's/.*nameserver\s+([.0-9]+).*/\1/p' /etc/resolv.conf | tr '\n' ' ')
mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.backup
cat << EOF > /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;

# TFTP options
allow booting;
allow bootp;

# My network environment
subnet $netpfx24.0 netmask 255.255.255.0 {
  next-server $address;
  filename "pxelinux.0";
  range dynamic-bootp $netpfx24.10 $netpfx24.210;
  option domain-name-servers $nameservers;
  option routers $address;
  option broadcast-address $netpfx24.255;
}
EOF

# Rebuild initramfs if missing.
if [ ! -f /initrd.img ]; then
    update-initramfs -u
fi

# Avoid attempting graphical login and get a console login prompt.
sed -i -r -e 's/^(GRUB_HIDDEN_.*)/#\1/' -e 's/quiet splash/quiet/' /etc/default/grub
# Fix boot loader.
update-grub
grub-install $(findmnt -no SOURCE / | sed -r 's/p?[0-9]+$//')

# Setup users.
{'fraction_non_alphanumeric': 0.13922210105416213, 'fraction_numerical': 0.016721192293711377, 'mean_word_length': 3.5337726523887976, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1047667', 'n_tokens_mistral': 1042, 'n_tokens_neox': 997, 'n_words': 307}