mirror of
https://github.com/riptidewave93/UNVR-NAS.git
synced 2025-03-09 15:40:13 +00:00
feat: initial upload
Initial public release
This commit is contained in:
commit
85a5bd66e0
30 changed files with 943 additions and 0 deletions
62
scripts/docker/bootstrap/001-bootstrap
Executable file
62
scripts/docker/bootstrap/001-bootstrap
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/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 ulcmd
|
||||
systemctl enable ulcmd
|
||||
systemctl enable mock-ubnt-api
|
||||
|
||||
# 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 u-boot-menu initramfs-tools python3-flask gnupg
|
||||
|
||||
# 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
|
||||
|
||||
# Disable systemd-networkd
|
||||
systemctl disable systemd-networkd
|
||||
systemctl disable systemd-networkd-wait-online
|
||||
systemctl mask systemd-networkd
|
||||
systemctl mask systemd-networkd-wait-online
|
||||
|
||||
# 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
|
61
scripts/docker/run_debootstrap.sh
Executable file
61
scripts/docker/run_debootstrap.sh
Executable file
|
@ -0,0 +1,61 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
docker_scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
||||
. ${scripts_path}/vars.sh
|
||||
|
||||
# Exports
|
||||
export PATH=${build_path}/toolchain/${toolchain_bin_path}:${PATH}
|
||||
export GCC_COLORS=auto
|
||||
export CROSS_COMPILE=${toolchain_cross_compile}
|
||||
export ARCH=arm64
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
export DEBCONF_NONINTERACTIVE_SEEN=true
|
||||
|
||||
# CD into our rootfs mount, and starts the fun!
|
||||
cd ${build_path}/rootfs
|
||||
debootstrap --no-check-gpg --foreign --arch=${deb_arch} --include=apt-transport-https ${deb_release} ${build_path}/rootfs ${deb_mirror}
|
||||
cp /usr/bin/qemu-aarch64-static usr/bin/
|
||||
chroot ${build_path}/rootfs /debootstrap/debootstrap --second-stage
|
||||
|
||||
# Copy over our kernel modules and kernel
|
||||
mv -f "${build_path}/fw-extract/rootfs/lib/modules" ${build_path}/rootfs/lib
|
||||
cp "${build_path}/fw-extract/kernel.bin" "${build_path}/rootfs/boot/uImage"
|
||||
|
||||
# Copy over our overlay if we have one
|
||||
if [[ -d ${root_path}/overlay/${fs_overlay_dir}/ ]]; then
|
||||
echo "Applying ${fs_overlay_dir} overlay"
|
||||
cp -R ${root_path}/overlay/${fs_overlay_dir}/* ./
|
||||
fi
|
||||
|
||||
# Apply our part UUIDs to fstab
|
||||
sed -i "s|BOOTUUIDPLACEHOLDER|$(blkid -o value -s UUID ${build_path}/boot.ext4)|g" ${build_path}/rootfs/etc/fstab
|
||||
sed -i "s|ROOTUUIDPLACEHOLDER|$(blkid -o value -s UUID ${build_path}/rootfs.ext4)|g" ${build_path}/rootfs/etc/fstab
|
||||
|
||||
# Hostname
|
||||
echo "${distrib_name}" > ${build_path}/rootfs/etc/hostname
|
||||
echo "127.0.1.1 ${distrib_name}" >> ${build_path}/rootfs/etc/hosts
|
||||
|
||||
# Console settings
|
||||
echo "console-common console-data/keymap/policy select Select keymap from full list
|
||||
console-common console-data/keymap/full select us
|
||||
" > ${build_path}/rootfs/debconf.set
|
||||
|
||||
# Copy over stuff for ulcmd, this is hacky, but that's this ENTIRE repo for you
|
||||
mv "${build_path}/fw-extract/rootfs/lib/systemd/system/ulcmd.service" "${build_path}/rootfs/lib/systemd/system/ulcmd.service"
|
||||
mv "${build_path}/fw-extract/rootfs/usr/bin/ulcmd" "${build_path}/rootfs/usr/bin/ulcmd"
|
||||
mkdir -p "${build_path}/rootfs/usr/lib/ubnt-fw/"
|
||||
for file in libgrpc++.so.1 libgrpc.so.10 libprotobuf.so.23 \
|
||||
libssl.so.1.1 libcrypto.so.1.1 libabsl*.so.20200923 libatomic.so.1; do
|
||||
mv ${build_path}/fw-extract/rootfs/usr/lib/aarch64-linux-gnu/${file} "${build_path}/rootfs/usr/lib/ubnt-fw/"
|
||||
done
|
||||
sed -i 's|Type=simple|Type=simple\nEnvironment="LD_LIBRARY_PATH=/usr/lib/ubnt-fw"|g' "${build_path}/rootfs/lib/systemd/system/ulcmd.service"
|
||||
|
||||
# Kick off bash setup script within chroot
|
||||
cp ${docker_scripts_path}/bootstrap/001-bootstrap ${build_path}/rootfs/bootstrap
|
||||
chroot ${build_path}/rootfs /bootstrap
|
||||
rm ${build_path}/rootfs/bootstrap
|
||||
|
||||
# Final cleanup
|
||||
rm ${build_path}/rootfs/usr/bin/qemu-aarch64-static
|
29
scripts/docker/run_mkimage_final.sh
Executable file
29
scripts/docker/run_mkimage_final.sh
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
||||
. ${scripts_path}/vars.sh
|
||||
|
||||
# Tempdir for root
|
||||
GENIMAGE_ROOT=$(mktemp -d)
|
||||
|
||||
# setup and move bits
|
||||
mkdir -p ${build_path}/final
|
||||
cp ${build_path}/boot.ext4 ${build_path}/final/
|
||||
cp ${build_path}/rootfs.ext4 ${build_path}/final/
|
||||
cp ${root_path}/genimage_final.cfg ${build_path}/genimage.cfg
|
||||
|
||||
# We get to gen an image per board, YAY!
|
||||
echo "Generating disk image"
|
||||
genimage \
|
||||
--rootpath "${GENIMAGE_ROOT}" \
|
||||
--tmppath "/tmp/genimage-initial-tmppath" \
|
||||
--inputpath "${build_path}/final" \
|
||||
--outputpath "${build_path}/final" \
|
||||
--config "${build_path}/genimage.cfg"
|
||||
mv ${build_path}/final/emmc.img ${build_path}/final/debian-UNVRPRO.img
|
||||
gzip ${build_path}/final/debian-UNVRPRO.img
|
||||
rm -rf /tmp/genimage-initial-tmppath # Cleanup
|
||||
|
||||
# Cleanup
|
||||
rm ${build_path}/final/boot.ext4 ${build_path}/final/rootfs.ext4 ${build_path}/genimage.cfg
|
19
scripts/docker/run_mkimage_initial.sh
Executable file
19
scripts/docker/run_mkimage_initial.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
|
||||
. ${scripts_path}/vars.sh
|
||||
|
||||
# Tempdir for root
|
||||
GENIMAGE_ROOT=$(mktemp -d)
|
||||
|
||||
# "fake" file so generation is happy
|
||||
touch ${GENIMAGE_ROOT}/placeholder
|
||||
|
||||
# Generate our boot and rootfs disk images
|
||||
genimage \
|
||||
--rootpath "${GENIMAGE_ROOT}" \
|
||||
--tmppath "/tmp/genimage-initial-tmppath" \
|
||||
--inputpath "${build_path}" \
|
||||
--outputpath "${build_path}" \
|
||||
--config "${root_path}/genimage_initial.cfg"
|
27
scripts/docker/setup_mkimage.sh
Executable file
27
scripts/docker/setup_mkimage.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# setup_mkimage is special, as it's copied to the dockerfile and ran
|
||||
# same with vars.sh which we put in place
|
||||
. /vars.sh
|
||||
|
||||
cd /usr/src
|
||||
echo "Downloading genimage..."
|
||||
wget ${genimage_src} -O /usr/src/${genimage_filename}
|
||||
|
||||
echo "Extracting genimage..."
|
||||
tar -xJf /usr/src/${genimage_filename}
|
||||
|
||||
echo "Building genimage..."
|
||||
cd ./${genimage_repopath}
|
||||
./configure
|
||||
make
|
||||
|
||||
echo "Installing genimage..."
|
||||
make install
|
||||
|
||||
echo "Cleaning up..."
|
||||
rm -rf /vars.sh # We wanna use it n burn it
|
||||
rm -rf /usr/src/${genimage_repopath}*
|
||||
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue