diff --git a/base-image-script/alpine-image_pt1.sh b/base-image-script/alpine-image_pt1.sh index d94f7e5..30ef928 100644 --- a/base-image-script/alpine-image_pt1.sh +++ b/base-image-script/alpine-image_pt1.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2025 fithwum +# All rights reserved set -e # Alpine version diff --git a/base-image-script/alpine-image_pt2.sh b/base-image-script/alpine-image_pt2.sh index 6b41be9..e5a4efb 100644 --- a/base-image-script/alpine-image_pt2.sh +++ b/base-image-script/alpine-image_pt2.sh @@ -1,4 +1,6 @@ -#!/bin/sh +#!/bin/bash +# Copyright (c) 2025 fithwum +# All rights reserved echo "[CHROOT] Inside Alpine rootfs" echo "[CHROOT] Updating system..." diff --git a/base-image-script/alpine-image_pt3.sh b/base-image-script/alpine-image_pt3.sh index 746c23e..a84838f 100644 --- a/base-image-script/alpine-image_pt3.sh +++ b/base-image-script/alpine-image_pt3.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2025 fithwum +# All rights reserved set -e ROOTFS_DIR="$1" diff --git a/base-image-script/debian-bookworm_pt1.sh b/base-image-script/debian-bookworm_pt1.sh index 53defb6..35b4760 100644 --- a/base-image-script/debian-bookworm_pt1.sh +++ b/base-image-script/debian-bookworm_pt1.sh @@ -1,59 +1,48 @@ #!/bin/bash -# Copyright (c) 2018 fithwum +# Copyright (c) 2025 fithwum # All rights reserved +set -e +set -o pipefail -RELEASE=stable +DEBIAN_RELEASE="bookworm" +ROOTFS_DIR="debian-${DEBIAN_RELEASE}" +SCRIPTS_URL="https://raw.githubusercontent.com/fithwum/files-for-dockers/refs/heads/master/base-image-script/" +PT2_SCRIPT="debian-${DEBIAN_RELEASE}_pt2.sh" +PT3_SCRIPT="debian-${DEBIAN_RELEASE}_pt3.sh" -echo " " -echo "INFO ! Downloading other parts of the script if needed." -if [ -e /debian-bookworm_pt2.sh ] - then - echo "INFO ! debian-bookworm_pt2.sh found ... will not download." - else - echo " " - echo "WARNING ! debian-bookworm_pt2.sh not found ... will download new copy." - wget --no-cache https://raw.githubusercontent.com/fithwum/files-for-dockers/refs/heads/master/base-image-script/debian-bookworm_pt2.sh -O /debian-bookworm_pt2.sh - chmod +x debian-bookworm_pt2.sh -fi -if [ -e /debian-bookworm_pt3.sh ] - then - echo "INFO ! debian-bookworm_pt3.sh found ... will not download." - else - echo " " - echo "WARNING ! debian-bookworm_pt3.sh not found ... will download new copy." - wget --no-cache https://raw.githubusercontent.com/fithwum/files-for-dockers/refs/heads/master/base-image-script/debian-bookworm_pt3.sh -O /debian-bookworm_pt3.sh - chmod +x debian-bookworm_pt3.sh -fi -sleep 1 -echo " " -echo "INFO ! Getting system updates." -apt-get -y update -apt-get -y upgrade -apt-get -y dist-upgrade -apt autoremove -y -echo " " -echo "INFO ! Installing debootstrap,ftp-upload,bash,dirmngr,curl." -sleep 1 -apt-get install -y debootstrap ftp-upload bash dirmngr curl -sleep 1 -echo " " -echo "INFO ! Downloading debian & selected packages." -debootstrap --force-check-gpg --variant=minbase --components=main,contrib,non-free --include=dirmngr,apt-transport-https,bash,software-properties-common,ca-certificates,wget,curl,nano --arch=amd64 bookworm /debian-bookworm http://deb.debian.org/debian/ -echo " " -echo "INFO ! Filesystem size uncompressed." -sleep 1 -du --human-readable --summarize debian-bookworm -sleep 5 -echo " " -echo "INFO ! Mounting folders for root." -mount --bind /dev debian-bookworm/dev -mount --bind /dev/pts debian-bookworm/dev/pts -mount --bind /proc debian-bookworm/proc -mount --bind /sys debian-bookworm/sys -sleep 1 -cp -v debian-bookworm_pt2.sh /debian-bookworm -echo " " -echo "INFO ! Changeing to new root." -sleep 1 -chroot debian-bookworm -exit +echo "[INFO] Preparing environment..." +apt-get update -y +apt-get upgrade -y +apt-get install -y --no-install-recommends debootstrap bash curl wget ftp-upload dirmngr + +echo "[INFO] Downloading extra scripts if missing..." +for SCRIPT in $PT2_SCRIPT $PT3_SCRIPT; do + if [ ! -f "./$SCRIPT" ]; then + echo "[INFO] Downloading $SCRIPT..." + wget --no-cache "$SCRIPTS_URL/$SCRIPT" -O "./$SCRIPT" + chmod +x "./$SCRIPT" + fi +done + +echo "[INFO] Bootstrapping Debian $DEBIAN_RELEASE..." +debootstrap \ + --variant=minbase \ + --components=main,contrib,non-free \ + --include=apt,ca-certificates \ + --arch=amd64 \ + "$DEBIAN_RELEASE" "$ROOTFS_DIR" http://deb.debian.org/debian/ + +echo "[INFO] Mounting system directories..." +for dir in dev dev/pts proc sys; do + mount --bind /$dir "$ROOTFS_DIR/$dir" +done + +echo "[INFO] Copying pt2 script into chroot..." +cp "./$PT2_SCRIPT" "$ROOTFS_DIR/root/$PT2_SCRIPT" +chmod +x "$ROOTFS_DIR/root/$PT2_SCRIPT" + +echo "[INFO] Entering chroot. Type 'exit' when done." +chroot "$ROOTFS_DIR" /root/$PT2_SCRIPT + +echo "[INFO] Running pt3 for packaging and upload..." +./$PT3_SCRIPT "$ROOTFS_DIR" diff --git a/base-image-script/debian-bookworm_pt2.sh b/base-image-script/debian-bookworm_pt2.sh index a608c3c..8b80d38 100644 --- a/base-image-script/debian-bookworm_pt2.sh +++ b/base-image-script/debian-bookworm_pt2.sh @@ -1,20 +1,21 @@ #!/bin/bash -# Copyright (c) 2018 fithwum +# Copyright (c) 2025 fithwum # All rights reserved +echo "[CHROOT] Configuring Debian system..." +echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/10-assume_yes -echo " " -echo "APT::Get::Assume-Yes \"true\";" | tee /etc/apt/apt.conf.d/10-assume_yes -sleep 1 -echo " " -echo "INFO ! Removeing unnecessary packages." -apt-get remove --allow-remove-essential pinentry-curses whiptail kmod iptables iproute2 dmidecode -sleep 1 -echo " " -echo "INFO ! Cleanup." +apt-get update +apt-get upgrade + +apt-get install --no-install-recommends software-properties-common bash wget curl nano locales + +echo "[CHROOT] Removing unnecessary packages..." +apt-get remove --purge --allow-remove-essential pinentry-curses whiptail kmod iptables iproute2 dmidecode || true + +echo "[CHROOT] Cleaning up..." apt-get clean -spt --fix-broken install -find /var/lib/apt/lists/ -maxdepth 2 -type f -delete -sleep 1 -echo " " -echo "INFO ! Type "exit" and reboot for final steps." -exit +apt-get install -f +find /var/lib/apt/lists/ -type f -delete + +echo "[CHROOT] Done. Type 'exit' to return." +exit \ No newline at end of file diff --git a/base-image-script/debian-bookworm_pt3.sh b/base-image-script/debian-bookworm_pt3.sh index bcdbf16..f82783e 100644 --- a/base-image-script/debian-bookworm_pt3.sh +++ b/base-image-script/debian-bookworm_pt3.sh @@ -1,33 +1,33 @@ #!/bin/bash -# Copyright (c) 2018 fithwum +# Copyright (c) 2025 fithwum # All rights reserved +set -e -echo " " -echo "INFO ! Cleaning up pt2 of script from base image." -rm -frv /debian-bookworm/debian-bookworm_pt2.sh -sleep 1 -echo " " -echo "INFO ! Base image size after cleanup." -du --human-readable --summarize debian-bookworm -sleep 5 -echo " " -echo "INFO ! Creating base image archive." -echo "INFO ! This may take some time." -tar -cjf debian-bookworm.tar.bz2 --directory debian-bookworm . -sleep 1 -echo " " -echo "INFO ! Base image archive." -du --human-readable --summarize debian-bookworm.tar.bz2 -sleep 5 -echo " " -echo "INFO ! Uploading image to ftp server." -ftp-upload -v -h {IP}:{PORT} -u {USER} --password {PASSWORD} -d /mnt/user/FTP debian-bookworm.tar.bz2 -sleep 1 -echo " " -echo "INFO ! Removing temp files." -rm -fr debian-bookworm -rm -frv debian-bookworm.tar.bz2 -echo " " -echo "INFO ! Done." -echo " " -exit +ROOTFS_DIR="${1:-debian-bookworm}" +TARBALL="${ROOTFS_DIR}.tar.bz2" + +echo "[INFO] Unmounting system directories..." +for dir in sys proc dev/pts dev; do + umount -lf "$ROOTFS_DIR/$dir" +done + +echo "[INFO] Removing chroot script..." +rm -f "$ROOTFS_DIR/root/debian-base_pt2.sh" + +echo "[INFO] Showing rootfs size..." +du -sh "$ROOTFS_DIR" + +echo "[INFO] Creating compressed base image..." +tar -cjf "$TARBALL" -C "$ROOTFS_DIR" . + +echo "[INFO] Image archive size:" +du -sh "$TARBALL" + +# Optional: Upload via FTP +# ftp-upload -v -h "$HOST" -u "$USER" --password "$PASS" -d /target/dir "$TARBALL" + +echo "[INFO] Cleaning up..." +rm -rf "$ROOTFS_DIR" +rm -f "$TARBALL" + +echo "[INFO] Done." diff --git a/base-image-script/debian-test_pt1.sh b/base-image-script/debian-test_pt1.sh index ae0136c..3449aca 100644 --- a/base-image-script/debian-test_pt1.sh +++ b/base-image-script/debian-test_pt1.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2025 fithwum +# All rights reserved set -e set -o pipefail diff --git a/base-image-script/debian-test_pt2.sh b/base-image-script/debian-test_pt2.sh index 64a3e1d..02d70c0 100644 --- a/base-image-script/debian-test_pt2.sh +++ b/base-image-script/debian-test_pt2.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2025 fithwum +# All rights reserved echo "[CHROOT] Configuring Debian system..." echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/10-assume_yes diff --git a/base-image-script/debian-test_pt3.sh b/base-image-script/debian-test_pt3.sh index 6014555..f82783e 100644 --- a/base-image-script/debian-test_pt3.sh +++ b/base-image-script/debian-test_pt3.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) 2025 fithwum +# All rights reserved set -e ROOTFS_DIR="${1:-debian-bookworm}"