Initial support for Bookworm.
This commit is contained in:
parent
f7a096794d
commit
ffa67a01f9
45
bookworm-amd64/bin/basefs_init
Normal file
45
bookworm-amd64/bin/basefs_init
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
DEBIAN_CODENAME=$2
|
||||
LANG=C
|
||||
|
||||
APT_PARAM=''
|
||||
STDOUT='/dev/stdout'
|
||||
if [ !$MKRESCUE_VERBOSE ]; then
|
||||
APT_PARAM='-qq -o=Dpkg::Use-Pty=0';
|
||||
STDOUT='/dev/null';
|
||||
fi
|
||||
|
||||
mkdir ${TARGET}
|
||||
|
||||
debootstrap --arch=amd64 --variant=minbase ${DEBIAN_CODENAME} ${TARGET} http://httpredir.debian.org/debian > $STDOUT
|
||||
|
||||
cat << EOF > ${TARGET}/etc/apt/sources.list
|
||||
deb http://deb.debian.org/debian ${DEBIAN_CODENAME} main contrib non-free non-free-firmware
|
||||
deb http://deb.debian.org/debian-security/ ${DEBIAN_CODENAME}-security main contrib non-free non-free-firmware
|
||||
deb http://deb.debian.org/debian ${DEBIAN_CODENAME}-updates main contrib non-free non-free-firmware
|
||||
deb http://deb.debian.org/debian ${DEBIAN_CODENAME}-backports main contrib non-free non-free-firmware
|
||||
EOF
|
||||
|
||||
cat << EOF > ${TARGET}/etc/apt/apt.conf.d/80small
|
||||
APT::Install-Recommends '0';
|
||||
APT::Install-Suggests '0';
|
||||
EOF
|
||||
|
||||
cat << EOF > ${TARGET}/etc/apt/preferences.d/backports
|
||||
Package: *
|
||||
Pin: release n=bookworm-backports
|
||||
Pin-Priority: 500
|
||||
EOF
|
||||
|
||||
echo wmirescue > ${TARGET}/etc/hostname
|
||||
|
||||
echo 'root:wmi' | chroot ${TARGET} chpasswd
|
||||
|
||||
chroot ${TARGET} mount -t devpts devpts /dev/pts
|
||||
chroot ${TARGET} apt-get $APT_PARAM update > $STDOUT
|
||||
chroot ${TARGET} apt-get $APT_PARAM --yes install apt-utils > $STDOUT
|
||||
chroot ${TARGET} apt-get $APT_PARAM upgrade --yes > $STDOUT
|
||||
chroot ${TARGET} apt-get $APT_PARAM clean > $STDOUT
|
||||
chroot ${TARGET} umount /dev/pts
|
44
bookworm-amd64/bin/dist_ipxe
Normal file
44
bookworm-amd64/bin/dist_ipxe
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
|
||||
VERSION=$1
|
||||
OUTPUT=$2
|
||||
NOFIRMWARE=$3
|
||||
|
||||
|
||||
LINE_FIRMWARE="initrd \${base}/\${version}/netboot/firmware.img"
|
||||
FILENAME="wmirescue.ipxe"
|
||||
|
||||
|
||||
if [ "${NOFIRMWARE}" = "--nofirmware" ]; then
|
||||
LINE_FIRMWARE=""
|
||||
FILENAME="wmirescue-nofirmware.ipxe"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
cat << EOF > ${OUTPUT}/${FILENAME}
|
||||
#!ipxe
|
||||
|
||||
:retry_dhcp
|
||||
dhcp || goto retry_dhcp
|
||||
|
||||
set version ${VERSION}
|
||||
set base http://rescue.wmi.amu.edu.pl/archive/
|
||||
|
||||
echo Detecting architecture
|
||||
cpuid --ext 29 && set arch amd64 || set arch i386
|
||||
|
||||
iseq \${arch} amd64 && goto boot ||
|
||||
echo WMI Rescue supports only the amd64 architecture
|
||||
exit
|
||||
|
||||
:boot
|
||||
|
||||
echo Booting WMI Rescue \${version} \${arch}
|
||||
|
||||
kernel \${base}/\${version}/netboot/\${arch}/vmlinuz
|
||||
initrd \${base}/\${version}/netboot/\${arch}/initrd.img
|
||||
${LINE_FIRMWARE}
|
||||
boot
|
||||
EOF
|
231
bookworm-amd64/bin/dist_iso
Normal file
231
bookworm-amd64/bin/dist_iso
Normal file
@ -0,0 +1,231 @@
|
||||
#!/bin/sh
|
||||
|
||||
VERSION=$1
|
||||
ARCH=$2
|
||||
OUTPUT=$3
|
||||
NOFIRMWARE=$4
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
SCRIPTDIR="$(dirname "$(realpath "$0")")"
|
||||
|
||||
APPEND_FIRMWARE="/rescue/firmware.img"
|
||||
FILENAME="wmirescue_$ARCH.iso"
|
||||
|
||||
mkdir -p $TEMP_DIR/boot/bios/i386-pc
|
||||
mkdir -p $TEMP_DIR/boot/bios/fonts
|
||||
mkdir -p $TEMP_DIR/boot/efi/fonts
|
||||
mkdir -p $TEMP_DIR/memtest
|
||||
mkdir -p $TEMP_DIR/rescue/$ARCH
|
||||
|
||||
if [ "${NOFIRMWARE}" = "--nofirmware" ]; then
|
||||
APPEND_FIRMWARE=""
|
||||
FILENAME="wmirescue_$ARCH-nofirmware.iso"
|
||||
else
|
||||
cp ${OUTPUT}/netboot/firmware.img $TEMP_DIR/rescue
|
||||
fi
|
||||
|
||||
cp ${OUTPUT}/netboot/${ARCH}/vmlinuz $TEMP_DIR/rescue/$ARCH
|
||||
cp ${OUTPUT}/netboot/${ARCH}/initrd.img $TEMP_DIR/rescue/$ARCH
|
||||
|
||||
|
||||
#memtest
|
||||
|
||||
echo "Preparing memtest..."
|
||||
echo
|
||||
|
||||
TEMP_DIR_MEMTEST=$(mktemp -d)
|
||||
|
||||
#BIOS
|
||||
wget -q http://www.memtest.org/download/5.01/memtest86+-5.01.zip -P ${TEMP_DIR_MEMTEST}
|
||||
unzip -q ${TEMP_DIR_MEMTEST}/memtest86+-5.01.zip -d ${TEMP_DIR_MEMTEST}
|
||||
cp ${TEMP_DIR_MEMTEST}/memtest86+-5.01.bin "$TEMP_DIR/memtest/memtest.bin"
|
||||
|
||||
#EFI
|
||||
mkdir ${TEMP_DIR_MEMTEST}/mountpoint
|
||||
wget -q https://www.memtest86.com/downloads/memtest86-usb.zip -P ${TEMP_DIR_MEMTEST}
|
||||
unzip -q ${TEMP_DIR_MEMTEST}/memtest86-usb.zip -d ${TEMP_DIR_MEMTEST}
|
||||
losetup -o $((2048*512)) /dev/loop0 ${TEMP_DIR_MEMTEST}/memtest86-usb.img
|
||||
mount /dev/loop0 ${TEMP_DIR_MEMTEST}/mountpoint
|
||||
cp ${TEMP_DIR_MEMTEST}/mountpoint/EFI/BOOT/BOOTX64.efi "$TEMP_DIR/memtest/memtest86.efi"
|
||||
umount ${TEMP_DIR_MEMTEST}/mountpoint
|
||||
losetup -d /dev/loop0
|
||||
|
||||
rm -r "${TEMP_DIR_MEMTEST}"
|
||||
|
||||
|
||||
#GRUB
|
||||
|
||||
echo
|
||||
echo "Preparing GRUB..."
|
||||
echo
|
||||
|
||||
TEMP_DIR_GRUB=$(mktemp -d)
|
||||
|
||||
#BIOS
|
||||
cp ${SCRIPTDIR}/../media/black.png $TEMP_DIR/boot/
|
||||
cp /usr/share/grub/unicode.pf2 $TEMP_DIR/boot/bios/fonts/
|
||||
|
||||
grub-mkimage -O i386-pc -p /boot/bios/ -o ${TEMP_DIR_GRUB}/core.img iso9660 biosdisk
|
||||
|
||||
#cp -r /usr/lib/grub/i386-pc/* $TEMP_DIR/boot/bios/i386-pc
|
||||
#rm $TEMP_DIR/boot/bios/i386-pc/*.img
|
||||
for module in normal boot extcmd crypto terminal gettext bufio \
|
||||
linux video relocator mmap vbe video_fb \
|
||||
linux16 \
|
||||
gfxterm font gfxmenu trig bitmap_scale bitmap video_colors \
|
||||
png verifiers; do
|
||||
cp /usr/lib/grub/i386-pc/${module}.mod $TEMP_DIR/boot/bios/i386-pc
|
||||
done;
|
||||
|
||||
cat /usr/lib/grub/i386-pc/cdboot.img ${TEMP_DIR_GRUB}/core.img > $TEMP_DIR/boot/bios/grub.img
|
||||
cat /usr/lib/grub/i386-pc/boot.img ${TEMP_DIR_GRUB}/core.img > ${TEMP_DIR_GRUB}/embedded.img
|
||||
|
||||
#EFI
|
||||
cp /usr/share/grub/unicode.pf2 $TEMP_DIR/boot/efi/fonts/
|
||||
grub-mkimage -C xz -O x86_64-efi -p /boot/efi/ -o "${TEMP_DIR_GRUB}/bootx64.efi" linux chain iso9660 normal all_video gfxterm gfxmenu png linuxefi
|
||||
truncate -s $(($(stat --printf="%s" ${TEMP_DIR_GRUB}/bootx64.efi) + 24576)) ${TEMP_DIR_GRUB}/efi.img
|
||||
mkfs.vfat ${TEMP_DIR_GRUB}/efi.img
|
||||
mkdir ${TEMP_DIR_GRUB}/mountpoint
|
||||
mount ${TEMP_DIR_GRUB}/efi.img ${TEMP_DIR_GRUB}/mountpoint/
|
||||
mkdir -p ${TEMP_DIR_GRUB}/mountpoint/efi/boot
|
||||
cp ${TEMP_DIR_GRUB}/bootx64.efi ${TEMP_DIR_GRUB}/mountpoint/efi/boot/
|
||||
umount ${TEMP_DIR_GRUB}/mountpoint
|
||||
|
||||
#CONFIG
|
||||
cat << EOF > $TEMP_DIR/boot/bios/grub.cfg
|
||||
insmod linux
|
||||
insmod linux16
|
||||
loadfont unicode
|
||||
insmod all_video
|
||||
insmod gfxterm
|
||||
terminal_output gfxterm
|
||||
|
||||
set timeout=30
|
||||
insmod png
|
||||
set theme="/boot/theme.txt"
|
||||
|
||||
menuentry "wmirescue-$ARCH" {
|
||||
linux /rescue/$ARCH/vmlinuz
|
||||
initrd /rescue/$ARCH/initrd.img $APPEND_FIRMWARE
|
||||
}
|
||||
|
||||
menuentry "wmirescue-$ARCH-serial" {
|
||||
linux /rescue/$ARCH/vmlinuz console=ttyS0,115200n8
|
||||
initrd /rescue/$ARCH/initrd.img $APPEND_FIRMWARE
|
||||
}
|
||||
|
||||
menuentry "memtest" {
|
||||
linux16 /memtest/memtest.bin
|
||||
}
|
||||
EOF
|
||||
|
||||
cat << EOF > $TEMP_DIR/boot/efi/grub.cfg
|
||||
loadfont unicode
|
||||
insmod gfxterm
|
||||
terminal_output gfxterm
|
||||
|
||||
set timeout=30
|
||||
insmod png
|
||||
set theme="/boot/theme.txt"
|
||||
|
||||
menuentry "wmirescue-$ARCH" {
|
||||
linux /rescue/$ARCH/vmlinuz
|
||||
initrd /rescue/$ARCH/initrd.img $APPEND_FIRMWARE
|
||||
}
|
||||
|
||||
menuentry "wmirescue-$ARCH-serial" {
|
||||
linux /rescue/$ARCH/vmlinuz console=ttyS0,115200n8
|
||||
initrd /rescue/$ARCH/initrd.img $APPEND_FIRMWARE
|
||||
}
|
||||
|
||||
menuentry "memtest" {
|
||||
chainloader /memtest/memtest86.efi
|
||||
}
|
||||
EOF
|
||||
|
||||
cat << EOF > $TEMP_DIR/boot/theme.txt
|
||||
title-text: ""
|
||||
desktop-color: "#000000"
|
||||
desktop-image: "black.png"
|
||||
terminal-left: "0"
|
||||
terminal-top: "0"
|
||||
terminal-width: "100%"
|
||||
terminal-height: "100%"
|
||||
terminal-border: "0"
|
||||
|
||||
+ label {
|
||||
text = "WMI Rescue $VERSION"
|
||||
left = 0%
|
||||
top = 5%
|
||||
width = 100%
|
||||
align = "center"
|
||||
color = "#fff" }
|
||||
+ label {
|
||||
text = "Booting in %d seconds"
|
||||
left = 0%
|
||||
top = 5%+24
|
||||
width = 100%
|
||||
align = "center"
|
||||
id = "__timeout__"
|
||||
color = "#999" }
|
||||
+ boot_menu {
|
||||
left = 7%
|
||||
top = 15%
|
||||
width = 100%
|
||||
item_height = 24
|
||||
item_spacing = 0
|
||||
item_padding = 0
|
||||
item_icon_space = 0
|
||||
icon_width = 0
|
||||
item_color = "#999"
|
||||
selected_item_color = "#fff" }
|
||||
+ label {
|
||||
text = "Serial console parameters: baud rate: 115200, parity: no, bits: 8"
|
||||
left = 7%
|
||||
top = 95%-120
|
||||
width = 100%
|
||||
color = "#999" }
|
||||
+ label {
|
||||
text = "https://rescue.wmi.amu.edu.pl/"
|
||||
left = 7%
|
||||
top = 95%-72
|
||||
width = 100%
|
||||
color = "#999" }
|
||||
+ label {
|
||||
text = "Copyright (C) by Mateusz Hromada <ruanda@ruanda.pl>"
|
||||
left = 7%
|
||||
top = 95%-48
|
||||
width = 100%
|
||||
color = "#999" }
|
||||
+ label {
|
||||
text = "Copyright (C) by Tomasz Zaworski <zawoor@wmi.amu.edu.pl.pl>"
|
||||
left = 7%
|
||||
top = 95%-24
|
||||
width = 100%
|
||||
color = "#999" }
|
||||
EOF
|
||||
|
||||
echo
|
||||
echo "Generating iso..."
|
||||
echo
|
||||
|
||||
xorriso -as mkisofs \
|
||||
-quiet \
|
||||
-b boot/bios/grub.img \
|
||||
-no-emul-boot \
|
||||
-boot-load-size 4 \
|
||||
-boot-info-table \
|
||||
--embedded-boot ${TEMP_DIR_GRUB}/embedded.img \
|
||||
-eltorito-alt-boot \
|
||||
-e "--interval:appended_partition_2:all::" \
|
||||
-no-emul-boot \
|
||||
-isohybrid-gpt-basdat \
|
||||
-o "${OUTPUT}/${FILENAME}" \
|
||||
-append_partition 2 0xef ${TEMP_DIR_GRUB}/efi.img \
|
||||
-partition_cyl_align all \
|
||||
-partition_offset 16 \
|
||||
-iso_mbr_part_type 0x83 \
|
||||
"$TEMP_DIR"
|
||||
|
||||
rm -rf "${TEMP_DIR}"
|
||||
rm -rf "${TEMP_DIR_GRUB}"
|
34
bookworm-amd64/bin/helperfs_config
Normal file
34
bookworm-amd64/bin/helperfs_config
Normal file
@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
KERNEL_VERSION=$2
|
||||
KERNEL_REPO=$3
|
||||
LANG=C
|
||||
|
||||
APT_PARAM=''
|
||||
STDOUT='/dev/stdout'
|
||||
if [ !$MKRESCUE_VERBOSE ]; then
|
||||
APT_PARAM='-qq -o=Dpkg::Use-Pty=0';
|
||||
STDOUT='/dev/null';
|
||||
fi
|
||||
|
||||
|
||||
FIRMWARES1="firmware-linux-free"
|
||||
FIRMWARES2="firmware-bnx2 firmware-bnx2x firmware-cavium \
|
||||
firmware-misc-nonfree firmware-myricom firmware-netxen firmware-qlogic \
|
||||
firmware-realtek"
|
||||
|
||||
cat << EOF > $TARGET/usr/sbin/policy-rc.d
|
||||
#!/bin/sh
|
||||
#echo "All runlevel operations denied by policy" >&2
|
||||
exit 101
|
||||
EOF
|
||||
chmod a+x $TARGET/usr/sbin/policy-rc.d
|
||||
|
||||
chroot ${TARGET} mount -t proc proc /proc
|
||||
chroot ${TARGET} apt-get $APT_PARAM --yes install busybox-static > $STDOUT
|
||||
chroot ${TARGET} apt-get $APT_PARAM --yes install -t ${KERNEL_REPO} linux-image-${KERNEL_VERSION} linux-headers-${KERNEL_VERSION} > $STDOUT
|
||||
chroot ${TARGET} apt-get $APT_PARAM --yes install -t ${KERNEL_REPO} zfs-dkms > $STDOUT
|
||||
chroot ${TARGET} apt-get $APT_PARAM --yes install ${FIRMWARES1} > $STDOUT
|
||||
chroot ${TARGET} apt-get $APT_PARAM --yes install -t ${KERNEL_REPO} ${FIRMWARES2} > $STDOUT
|
||||
chroot ${TARGET} umount /proc
|
82
bookworm-amd64/bin/ramdisk_config
Normal file
82
bookworm-amd64/bin/ramdisk_config
Normal file
@ -0,0 +1,82 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
KERNEL_VERSION=$2
|
||||
LANG=C
|
||||
|
||||
cat << EOF > ${TARGET}/message
|
||||
** WMI Rescue Linux (amd64) booting **
|
||||
EOF
|
||||
|
||||
for cmd in cat echo find insmod mkdir mount sh switch_root tar; do
|
||||
ln -s busybox ${TARGET}/bin/${cmd}
|
||||
done
|
||||
|
||||
cat << EOF > ${TARGET}/init
|
||||
#!/bin/sh
|
||||
# WMI Rescue Linux init script.
|
||||
# (C)2011 Michał Siejak <masterm@wmi.amu.edu.pl>
|
||||
# (C)2012-2017 Mateusz Hromada <ruanda@wmi.amu.edu.pl>
|
||||
# (C)2019 Tomasz Zaworski <zawoor@wmi.amu.edu.pl>
|
||||
|
||||
# Print message banner
|
||||
cat /message
|
||||
|
||||
# Mount virtual filesystems
|
||||
mount -t proc proc /proc
|
||||
mount -t sysfs sysfs /sys
|
||||
mount -t devtmpfs devfs /dev
|
||||
|
||||
# Create dev directories
|
||||
mkdir -p /dev/pts
|
||||
mkdir -p /dev/shm
|
||||
|
||||
# Create mount points
|
||||
mkdir /rootfs
|
||||
mkdir /mnt
|
||||
mkdir /mnt/squashfs
|
||||
mkdir /mnt/tmpfs
|
||||
|
||||
# Load modules
|
||||
modprobe loop
|
||||
modprobe squashfs
|
||||
modprobe overlay
|
||||
|
||||
# Mount root filesystem
|
||||
echo "INITRAMFS: Mounting overlayfs branches ..."
|
||||
mount -t squashfs -o loop,ro /rootfs.squash /mnt/squashfs
|
||||
mount -t tmpfs -o mode=755,rw tmpfs /mnt/tmpfs
|
||||
mkdir /mnt/tmpfs/rw
|
||||
mkdir /mnt/tmpfs/work
|
||||
mount -t overlay -o rw,workdir=/mnt/tmpfs/work,upperdir=/mnt/tmpfs/rw,lowerdir=/mnt/squashfs overlay /rootfs
|
||||
|
||||
# Extract any addon packages
|
||||
if [ -n "\$(find . -maxdepth 1 -name '*.tar')" ]; then
|
||||
for i in /*.tar; do
|
||||
echo "INITRAMFS: Extracting: \$i ..."
|
||||
tar x -f \$i -C /rootfs
|
||||
done
|
||||
fi
|
||||
|
||||
echo "INITRAMFS: Preparing rootfs environment ..."
|
||||
# Move aufs branches to new root
|
||||
mkdir -p /rootfs/media/.squashfs
|
||||
mkdir -p /rootfs/media/.tmpfs
|
||||
mount --move /mnt/squashfs /rootfs/media/.squashfs
|
||||
mount --move /mnt/tmpfs /rootfs/media/.tmpfs
|
||||
|
||||
# Move virtual filesystems to new root
|
||||
mount --move /proc /rootfs/proc
|
||||
mount --move /sys /rootfs/sys
|
||||
mount --move /dev /rootfs/dev
|
||||
|
||||
# Switch to new root filesystem
|
||||
echo "INITRAMFS: Switching to new rootfs ..."
|
||||
exec switch_root -c /dev/console /rootfs /sbin/init
|
||||
|
||||
# Should not reach here
|
||||
echo "INITRAMFS: Could not switch to new rootfs! System halted."
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
chmod a+x ${TARGET}/init
|
13
bookworm-amd64/bin/ramdisk_make
Normal file
13
bookworm-amd64/bin/ramdisk_make
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
RAMDISK=$2
|
||||
|
||||
|
||||
if [ ! -d "${RAMDISK}" ]; then
|
||||
echo "Usage: $0 <ramdisk_img> <ramdisk_dir>"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
echo "Generating initramfs..."
|
||||
(cd ${RAMDISK}; find . | cpio -H newc -o | gzip -1) > ${TARGET}
|
28
bookworm-amd64/bin/ramdisk_modules
Normal file
28
bookworm-amd64/bin/ramdisk_modules
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
ROOTFS=$2
|
||||
KERNEL_VERSION=$3
|
||||
|
||||
if [ ! -d "$TARGET" -o ! -d "$ROOTFS" ]; then
|
||||
echo "Usage: $0 <ramdisk_dir> <rootfs_dir> <version>"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
add_module() {
|
||||
for kmod in $(modprobe --dirname=${ROOTFS} --set-version="${KERNEL_VERSION}" --ignore-install --quiet --show-depends "$1" | awk '/^insmod/ { print $2 }'); do
|
||||
path=$(realpath --relative-to ${ROOTFS} ${kmod})
|
||||
if [ -e $TARGET/$path ]; then
|
||||
continue
|
||||
fi
|
||||
mkdir -p $TARGET/$(dirname $path)
|
||||
cp $kmod $TARGET/$(dirname $path)
|
||||
done
|
||||
}
|
||||
|
||||
echo "Loading modules..."
|
||||
for i in loop squashfs overlay; do
|
||||
add_module $i
|
||||
done
|
||||
mkdir -p $TARGET/lib/modules/${KERNEL_VERSION}/
|
||||
cp ${ROOTFS}/lib/modules/${KERNEL_VERSION}/modules.dep $TARGET/lib/modules/${KERNEL_VERSION}/
|
42
bookworm-amd64/bin/rootfs_clear
Normal file
42
bookworm-amd64/bin/rootfs_clear
Normal file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
|
||||
CLEANDIRS="\
|
||||
tmp \
|
||||
usr/doc \
|
||||
usr/include \
|
||||
usr/info \
|
||||
usr/man \
|
||||
usr/share/doc \
|
||||
usr/share/doc-base \
|
||||
usr/share/groff \
|
||||
usr/share/info \
|
||||
usr/share/locale \
|
||||
usr/share/man \
|
||||
var/cache/apt/archives \
|
||||
var/cache/man \
|
||||
var/lib/apt/lists \
|
||||
var/tmp"
|
||||
|
||||
if [ ! -d "${TARGET}" ]; then
|
||||
echo "Usage: $0 <rootfs_dir>"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
echo "Cleaning up ${TARGET}..."
|
||||
|
||||
find ${TARGET} -name \*~ -delete
|
||||
for dir in ${CLEANDIRS}; do
|
||||
rm -rf ${TARGET}/${dir}/*
|
||||
done
|
||||
rm -f ${TARGET}/var/cache/apt/*.bin
|
||||
rm -f ${TARGET}/root/.{bash_history,viminfo}
|
||||
|
||||
mkdir -p ${TARGET}/var/lib/apt/lists/partial
|
||||
mkdir -p ${TARGET}/var/cache/apt/archives/partial
|
||||
|
||||
for file in $(find ${TARGET}/var/log -type f); do
|
||||
: > ${file}
|
||||
done
|
||||
|
107
bookworm-amd64/bin/rootfs_config
Normal file
107
bookworm-amd64/bin/rootfs_config
Normal file
@ -0,0 +1,107 @@
|
||||
#!/bin/bash
|
||||
|
||||
TARGET=$1
|
||||
DEBIAN_CODENAME=$2
|
||||
LANG=C
|
||||
VERSION="$(date +%g.%m)"
|
||||
|
||||
APT_PARAM=''
|
||||
STDOUT='/dev/stdout'
|
||||
if [ !$MKRESCUE_VERBOSE ]; then
|
||||
APT_PARAM='-qq -o=Dpkg::Use-Pty=0';
|
||||
STDOUT='/dev/null'
|
||||
fi
|
||||
|
||||
SOFTWARE="acl acpi-support-base attr bash-completion bind9-host binutils \
|
||||
bridge-utils bsdmainutils ca-certificates debootstrap dialog \
|
||||
dmidecode dosfstools ethtool fdisk file gddrescue gdisk \
|
||||
hddtemp hdparm ifenslave iproute2 iputils-ping less lsof lvm2 lzip mdadm \
|
||||
mtr-tiny netcat-traditional net-tools ntfs-3g nvme-cli parted pciutils pixz procps \
|
||||
psmisc rsync screen scrub smartmontools ssh strace sysstat tar tcpdump \
|
||||
telnet traceroute tree usbutils vim vlan wget xz-utils systemd systemd-sysv \
|
||||
nfs-common ipxe grub-pc grub-efi-amd64-bin efibootmgr pv mtools xfsprogs \
|
||||
zfsutils-linux "
|
||||
|
||||
cat << EOF > ${TARGET}/usr/sbin/policy-rc.d
|
||||
#!/bin/sh
|
||||
#echo "All runlevel operations denied by policy" >&2
|
||||
exit 101
|
||||
EOF
|
||||
chmod a+x $TARGET/usr/sbin/policy-rc.d
|
||||
|
||||
chroot ${TARGET} apt-get $APT_PARAM --yes install ${SOFTWARE} > $STDOUT
|
||||
chroot ${TARGET} systemctl enable systemd-networkd.service
|
||||
chroot ${TARGET} systemctl enable systemd-resolved.service
|
||||
chroot ${TARGET} systemctl enable acpid.service
|
||||
|
||||
rm ${TARGET}/usr/sbin/policy-rc.d
|
||||
|
||||
echo "Etc/UTC" > ${TARGET}/etc/timezone
|
||||
chroot ${TARGET} dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
cat << EOF > ${TARGET}/etc/motd
|
||||
|
||||
WARNING: Authorized access only!
|
||||
|
||||
EOF
|
||||
cat << EOF > ${TARGET}/etc/issue
|
||||
WMI Rescue Linux (based on Debian GNU/Linux ${DEBIAN_CODENAME^})
|
||||
Version ${VERSION} AMD64
|
||||
|
||||
EOF
|
||||
|
||||
#disable console blanking
|
||||
#(consoleblank=0 as kernel param or setterm -blank 0)
|
||||
#current value can be checked in /sys/module/kernel/parameters/consoleblank
|
||||
echo -ne "\033[9;0]" >> ${TARGET}/etc/issue
|
||||
|
||||
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' ${TARGET}/etc/ssh/sshd_config
|
||||
cat << EOF > ${TARGET}/etc/systemd/network/all.network
|
||||
[Match]
|
||||
Name=*
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
EOF
|
||||
cat << EOF > ${TARGET}/etc/systemd/resolved.conf
|
||||
[Resolve]
|
||||
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
|
||||
EOF
|
||||
rm ${TARGET}/etc/resolv.conf
|
||||
ln -s /run/systemd/resolve/resolv.conf ${TARGET}/etc/resolv.conf
|
||||
rm ${TARGET}/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service
|
||||
#use old network device names
|
||||
ln -s /dev/null ${TARGET}/etc/systemd/network/99-default.link
|
||||
cat << EOF > ${TARGET}/etc/systemd/system/ssh-session-cleanup.service
|
||||
[Unit]
|
||||
Description=OpenBSD Secure Shell session cleanup
|
||||
Wants=network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/bin/true
|
||||
ExecStop=/usr/lib/openssh/ssh-session-cleanup
|
||||
RemainAfterExit=yes
|
||||
Type=oneshot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
chroot ${TARGET} systemctl enable ssh-session-cleanup.service
|
||||
cat << EOF > ${TARGET}/etc/screenrc
|
||||
startup_message off
|
||||
defscrollback 5000
|
||||
EOF
|
||||
cat << EOF > ${TARGET}/etc/sysctl.d/60-panic.conf
|
||||
kernel.panic = 5
|
||||
kernel.panic_on_oops = 1
|
||||
EOF
|
||||
sed -i 's/" let g:skip_defaults_vim = 1/let g:skip_defaults_vim = 1/g' ${TARGET}/etc/vim/vimrc
|
||||
rsync -avS ${TARGET}/etc/skel/ ${TARGET}/root/
|
||||
|
||||
|
||||
echo zfs >> ${TARGET}/etc/modules
|
||||
|
||||
mkdir ${TARGET}/etc/bash_completion.d
|
||||
cp ${TARGET}/usr/share/bash-completion/completions/zfs ${TARGET}/etc/bash_completion.d/
|
||||
|
13
bookworm-amd64/bin/rootfs_mksquashfs
Normal file
13
bookworm-amd64/bin/rootfs_mksquashfs
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
DEST=$2
|
||||
|
||||
if [ ! -d "${TARGET}" ]; then
|
||||
echo "Usage: $0 <rootfs_dir> <squashfs_image>"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
echo "Generating squashfs..."
|
||||
rm -f ${DEST}
|
||||
mksquashfs ${TARGET} ${DEST} -comp xz -b 1M -no-exports -noI -Xbcj x86
|
BIN
bookworm-amd64/media/black.png
Normal file
BIN
bookworm-amd64/media/black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 B |
89
bookworm-amd64/mkrescue
Normal file
89
bookworm-amd64/mkrescue
Normal file
@ -0,0 +1,89 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
VERSION=$(date +%g.%m)
|
||||
OUTPUT=${TARGET}/output/${VERSION}
|
||||
DEBIAN_CODENAME='bookworm'
|
||||
KERNEL_VERSION='6.1.0-9-amd64'
|
||||
KERNEL_REPO="bookworm"
|
||||
ARCH='amd64'
|
||||
|
||||
QUIET=1
|
||||
export MKRESCUE_VERBOSE=1
|
||||
|
||||
export LANGUAGE=C
|
||||
export LANG=C
|
||||
export LC_ALL=C
|
||||
|
||||
umask 022
|
||||
|
||||
if [ -z "${TARGET}" ]; then
|
||||
echo "Usage: $0 <work_dir>"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
SCRIPTDIR="$(dirname "$(realpath "$0")")"
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
mkdir ${TARGET}
|
||||
mkdir ${TARGET}/ramdisk
|
||||
mkdir ${TARGET}/firmware
|
||||
mkdir -p ${OUTPUT}/netboot/${ARCH}
|
||||
|
||||
if [ !$QUIET ]; then echo '\n### Executing basefs_init ###'; fi
|
||||
${SCRIPTDIR}/bin/basefs_init ${TARGET}/basefs ${DEBIAN_CODENAME}
|
||||
|
||||
cp -a ${TARGET}/basefs ${TARGET}/rootfs
|
||||
cp -a ${TARGET}/basefs ${TARGET}/helperfs
|
||||
|
||||
if [ !$QUIET ]; then echo '\n### Executing helperfs_config ###'; fi
|
||||
${SCRIPTDIR}/bin/helperfs_config ${TARGET}/helperfs ${KERNEL_VERSION} ${KERNEL_REPO}
|
||||
|
||||
# ROOTFS
|
||||
|
||||
mkdir -p ${TARGET}/rootfs/lib/modules
|
||||
rsync -aS ${TARGET}/helperfs/lib/modules/ ${TARGET}/rootfs/lib/modules/
|
||||
if [ !$QUIET ]; then echo '\n### Executing rootfs_config ###'; fi
|
||||
${SCRIPTDIR}/bin/rootfs_config ${TARGET}/rootfs ${DEBIAN_CODENAME}
|
||||
if [ !$QUIET ]; then echo '\n### Executing rootfs_clear ###'; fi
|
||||
${SCRIPTDIR}/bin/rootfs_clear ${TARGET}/rootfs
|
||||
if [ !$QUIET ]; then echo '\n### Executing rootfs_mksquashfs ###'; fi
|
||||
${SCRIPTDIR}/bin/rootfs_mksquashfs ${TARGET}/rootfs ${TARGET}/ramdisk/rootfs.squash
|
||||
|
||||
# RAMDISK
|
||||
|
||||
mkdir -p ${TARGET}/ramdisk/bin
|
||||
mkdir -p ${TARGET}/ramdisk/dev
|
||||
mkdir -p ${TARGET}/ramdisk/usr/lib/modules
|
||||
ln -s usr/lib ${TARGET}/ramdisk/lib
|
||||
mkdir -p ${TARGET}/ramdisk/proc
|
||||
mkdir -p ${TARGET}/ramdisk/sys
|
||||
cp ${TARGET}/helperfs/bin/busybox ${TARGET}/ramdisk/bin/busybox
|
||||
if [ !$QUIET ]; then echo '\n### Executing ramdisk_modules ###'; fi
|
||||
${SCRIPTDIR}/bin/ramdisk_modules ${TARGET}/ramdisk ${TARGET}/rootfs ${KERNEL_VERSION}
|
||||
if [ !$QUIET ]; then echo '\n### Executing ramdisk_config ###'; fi
|
||||
${SCRIPTDIR}/bin/ramdisk_config ${TARGET}/ramdisk ${KERNEL_VERSION}
|
||||
if [ !$QUIET ]; then echo '\n### Executing ramdisk_make ###'; fi
|
||||
${SCRIPTDIR}/bin/ramdisk_make ${OUTPUT}/netboot/${ARCH}/initrd.img ${TARGET}/ramdisk
|
||||
|
||||
# FIRMWARE
|
||||
tar cf ${TARGET}/firmware/firmware.tar --owner=root --group=root -C ${TARGET}/helperfs ./lib/firmware
|
||||
if [ !$QUIET ]; then echo '\n### Executing ramdisk_make ###'; fi
|
||||
${SCRIPTDIR}/bin/ramdisk_make ${OUTPUT}/netboot/firmware.img ${TARGET}/firmware
|
||||
|
||||
# KERNEL
|
||||
|
||||
cp ${TARGET}/helperfs/boot/vmlinuz-${KERNEL_VERSION} ${OUTPUT}/netboot/${ARCH}/vmlinuz
|
||||
|
||||
|
||||
# DIST
|
||||
tar cvf ${OUTPUT}/wmirescue_${ARCH}-netboot.tar -C ${OUTPUT}/netboot .
|
||||
if [ !$QUIET ]; then echo '\n### Executing dist_ipxe ###'; fi
|
||||
${SCRIPTDIR}/bin/dist_ipxe ${VERSION} ${OUTPUT}
|
||||
if [ !$QUIET ]; then echo '\n### Executing dist_ipxe --nofirmware ###'; fi
|
||||
${SCRIPTDIR}/bin/dist_ipxe ${VERSION} ${OUTPUT} --nofirmware
|
||||
if [ !$QUIET ]; then echo '\n### Executing dist_iso ###'; fi
|
||||
${SCRIPTDIR}/bin/dist_iso ${VERSION} ${ARCH} ${OUTPUT}
|
||||
if [ !$QUIET ]; then echo '\n### Executing dist_iso --nofirmware ###'; fi
|
||||
${SCRIPTDIR}/bin/dist_iso ${VERSION} ${ARCH} ${OUTPUT} --nofirmware
|
Loading…
Reference in New Issue
Block a user