UNVR-NAS/scripts/docker/bootstrap/001-bootstrap
Chris Blake 27713ab79e fix: tune reboot timeout on panic, improve shutdown ulcmd support
* Ensure we have all the right targets for ulcmd-shutdown-hook to show the shutdown message
* Move to an init script that we can use for setup commands, like adjusting our kernel panic timeout.
2024-05-27 13:07:51 -05:00

71 lines
3.1 KiB
Bash
Executable file

#!/bin/bash
set -e
echo "Starting 001-bootstrap within chroot!"
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
# Conf debconf
debconf-set-selections /debconf.set
rm -f /debconf.set
# Initial package install
apt-get clean
apt-get update
apt-mark hold linux-image-* # We do not want these, as we run our own kernel!
# Setup our services
systemctl enable ubnt-init
systemctl enable mock-ubnt-api
systemctl enable ulcmd
systemctl enable ulcmd-reboot-hook
systemctl enable ulcmd-shutdown-hook
systemctl enable unvr-fan-daemon
# Now that we have our wanted kernel in place, do the rest of our installs
apt-get -o Dpkg::Options::="--force-confold" -y --allow-downgrades \
--allow-remove-essential --allow-change-held-packages install cloud-init \
bsdextrautils git binutils ca-certificates e2fsprogs haveged parted curl \
locales console-common openssh-server less vim net-tools wireguard-tools \
ntpsec u-boot-tools wget initramfs-tools python3-flask gnupg libc-ares2 \
dfu-util
# Locale gen
locale-gen
# Setup OMV repo
wget --quiet --output-document=- https://packages.openmediavault.org/public/archive.key | gpg --dearmor --yes --output "/usr/share/keyrings/openmediavault-archive-keyring.gpg"
cat <<EOF >> /etc/apt/sources.list.d/openmediavault.list
deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public sandworm main
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages sandworm main
## This software is not part of OpenMediaVault, but is offered by third-party
## developers as a service to OpenMediaVault users.
deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://packages.openmediavault.org/public sandworm partner
# deb [signed-by=/usr/share/keyrings/openmediavault-archive-keyring.gpg] https://downloads.sourceforge.net/project/openmediavault/packages sandworm partner
EOF
# Install OMV
apt-get update
apt-get --yes --auto-remove --show-upgraded \
--allow-downgrades --allow-change-held-packages \
--no-install-recommends \
--option DPkg::Options::="--force-confdef" \
--option DPkg::Options::="--force-confold" \
install openmediavault openmediavault-md || true # We "fail" all apt cmds from here on til we boot on HW
# Setup NICs for OMV to manage
jq --null-input --compact-output \
"{uuid: \"fa4b1c66-ef79-11e5-87a0-0002b3a176b4\", devicename: \"enp0s1\", method: \"dhcp\", method6: \"auto\"}" | \
omv-confdbadm update "conf.system.network.interface" -
jq --null-input --compact-output \
"{uuid: \"fa4b1c66-ef79-11e5-87a0-0002b3a176b4\", devicename: \"enp0s2\", method: \"dhcp\", method6: \"auto\"}" | \
omv-confdbadm update "conf.system.network.interface" -
# Set hostname
omv-confdbadm update "conf.system.network.dns" "{\"hostname\": \"unvr-nas\"}"
# Cleanup stuff we don't want floating around
apt-get autoclean || true
apt-get --purge -y autoremove || true
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /etc/resolv.conf
rm -rf /var/lib/dbus/machine-id /etc/machine-id # Nuke machine IDs