UNVR-NAS/scripts/docker/bootstrap/001-bootstrap
Chris Blake 24d98456e6 fix: bring back ulcmd for startup
This is also used for LED config on the UNVR, which is dumb and should be moved later but for now it is what it is.
2024-06-18 19:20:02 -05:00

82 lines
3.4 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
# Run depmod for our kernel so we pick up btrfs + more
depmod -a 4.19.152-alpine-unvr
# 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 unvr-fan-daemon
systemctl enable ulcmd # This runs ubnt-ulcmd.sh!
# Do we have ulcmd? if so, we are UNVRPRO so enable ulcmd services
if [ -f "/usr/bin/ulcmd" ]; then
systemctl enable mock-ubnt-api
systemctl enable ulcmd-reboot-hook
systemctl enable ulcmd-shutdown-hook
fi
# 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 bluez
# Enable bluetooth
systemctl enable bluetooth
# 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