Modified scripts for Debian Buster. Added ISO image creation.
This commit is contained in:
parent
5516f681a1
commit
30c7a0612a
13
README.md
13
README.md
@ -5,3 +5,16 @@ WMI Rescue is small Linux image based on Debian distribution.
|
||||
Default root password is "wmi".
|
||||
|
||||
Download binary images from http://rescue.wmi.amu.edu.pl.
|
||||
|
||||
|
||||
|
||||
Scripts for Debian Buster were tested on Ubuntu 18.04.
|
||||
|
||||
Required packages:
|
||||
* debootstrap
|
||||
* dosfstools
|
||||
* squashfs-tools
|
||||
* unzip
|
||||
* grub-pc-bin
|
||||
* grub-efi-amd64-bin
|
||||
* xorriso
|
||||
|
28
buster-amd64/bin/basefs_init
Executable file
28
buster-amd64/bin/basefs_init
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
DEBIAN_CODENAME=$2
|
||||
LANG=C
|
||||
|
||||
mkdir ${TARGET}
|
||||
|
||||
debootstrap --arch=amd64 --variant=minbase ${DEBIAN_CODENAME} ${TARGET} http://httpredir.debian.org/debian
|
||||
|
||||
cat << EOF > ${TARGET}/etc/apt/sources.list
|
||||
deb http://httpredir.debian.org/debian ${DEBIAN_CODENAME} main contrib non-free
|
||||
deb http://security.debian.org/ ${DEBIAN_CODENAME}/updates main contrib non-free
|
||||
EOF
|
||||
|
||||
cat << EOF > ${TARGET}/etc/apt/apt.conf.d/80small
|
||||
APT::Install-Recommends '0';
|
||||
APT::Install-Suggests '0';
|
||||
EOF
|
||||
|
||||
echo wmirescue > ${TARGET}/etc/hostname
|
||||
|
||||
echo 'root:wmi' | chroot ${TARGET} chpasswd
|
||||
|
||||
chroot ${TARGET} apt-get update
|
||||
chroot ${TARGET} apt-get upgrade --yes
|
||||
chroot ${TARGET} apt-get clean
|
||||
|
44
buster-amd64/bin/dist_ipxe
Executable file
44
buster-amd64/bin/dist_ipxe
Executable 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
|
244
buster-amd64/bin/dist_iso
Executable file
244
buster-amd64/bin/dist_iso
Executable file
@ -0,0 +1,244 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION=$1
|
||||
ARCH=$2
|
||||
OUTPUT=$3
|
||||
NOFIRMWARE=$4
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
||||
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
|
||||
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 -e "Preparing memtest...\n"
|
||||
|
||||
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 -e "Preparing GRUB...\n"
|
||||
|
||||
TEMP_DIR_GRUB=$(mktemp -d)
|
||||
|
||||
#BIOS
|
||||
cp 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; 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
|
||||
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
|
||||
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 /rescue/firmware.img
|
||||
}
|
||||
|
||||
menuentry "wmirescue-$ARCH-serial" {
|
||||
linux /rescue/$ARCH/vmlinuz console=ttyS0,115200n8
|
||||
initrd /rescue/$ARCH/initrd.img /rescue/firmware.img
|
||||
}
|
||||
|
||||
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 /rescue/firmware.img
|
||||
}
|
||||
|
||||
menuentry "wmirescue-$ARCH-serial" {
|
||||
linux /rescue/$ARCH/vmlinuz console=ttyS0,115200n8
|
||||
initrd /rescue/$ARCH/initrd.img /rescue/firmware.img
|
||||
}
|
||||
|
||||
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 -e "\nGenerating iso...\n"
|
||||
|
||||
#genisoimage -o ${OUTPUT}/${FILENAME} -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table "$TEMP_DIR"
|
||||
#isohybrid.pl ${OUTPUT}/${FILENAME}
|
||||
|
||||
#xorriso -as mkisofs \
|
||||
# -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
|
||||
# -c isolinux/boot.cat \
|
||||
# -b isolinux/isolinux.bin \
|
||||
# -no-emul-boot \
|
||||
# -boot-load-size 4 \
|
||||
# -boot-info-table \
|
||||
# -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 \
|
||||
# "$TEMP_DIR"
|
||||
|
||||
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}"
|
23
buster-amd64/bin/helperfs_config
Executable file
23
buster-amd64/bin/helperfs_config
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
KERNEL_VERSION=$2
|
||||
LANG=C
|
||||
|
||||
FIRMWARES="firmware-bnx2 firmware-bnx2x firmware-cavium firmware-linux-free \
|
||||
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 --yes install busybox-static linux-image-${KERNEL_VERSION}
|
||||
chroot ${TARGET} apt-get --yes install linux-headers-${KERNEL_VERSION}
|
||||
chroot ${TARGET} apt-get --yes install zfs-dkms
|
||||
chroot ${TARGET} apt-get --yes install ${FIRMWARES}
|
||||
chroot ${TARGET} umount /proc
|
82
buster-amd64/bin/ramdisk_config
Executable file
82
buster-amd64/bin/ramdisk_config
Executable 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
buster-amd64/bin/ramdisk_make
Executable file
13
buster-amd64/bin/ramdisk_make
Executable 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
buster-amd64/bin/ramdisk_modules
Executable file
28
buster-amd64/bin/ramdisk_modules
Executable 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
buster-amd64/bin/rootfs_clear
Executable file
42
buster-amd64/bin/rootfs_clear
Executable 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
|
||||
|
81
buster-amd64/bin/rootfs_config
Executable file
81
buster-amd64/bin/rootfs_config
Executable file
@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
|
||||
TARGET=$1
|
||||
DEBIAN_CODENAME=$2
|
||||
LANG=C
|
||||
VERSION="$(date +%g.%m)"
|
||||
|
||||
SOFTWARE="acl acpi-support-base attr bash-completion bind9-host binutils \
|
||||
bridge-utils bsdmainutils debootstrap dmidecode dosfstools ethtool file gddrescue gdisk \
|
||||
hddtemp hdparm ifenslave iproute2 iputils-ping less lsof lvm2 lzip mdadm \
|
||||
mtr-tiny netcat-traditional net-tools ntfs-3g 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
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
chroot ${TARGET} apt-get --yes install ${SOFTWARE}
|
||||
chroot ${TARGET} systemctl enable systemd-networkd.service
|
||||
chroot ${TARGET} systemctl enable systemd-resolved.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]
|
||||
|
||||
[Network]
|
||||
DHCP=both
|
||||
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
|
||||
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
|
||||
for i in zfs; do
|
||||
cp ${TARGET}/usr/share/bash-completion/completions/${i} ${TARGET}/etc/bash_completion.d/
|
||||
done
|
13
buster-amd64/bin/rootfs_mksquashfs
Executable file
13
buster-amd64/bin/rootfs_mksquashfs
Executable 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
buster-amd64/media/black.png
Normal file
BIN
buster-amd64/media/black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 B |
62
buster-amd64/mkrescue
Executable file
62
buster-amd64/mkrescue
Executable file
@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
|
||||
TARGET=$1
|
||||
VERSION=$(date +%g.%m)
|
||||
OUTPUT=${TARGET}/output/${VERSION}
|
||||
DEBIAN_CODENAME='buster'
|
||||
KERNEL_VERSION='4.19.0-5-amd64'
|
||||
ARCH='amd64'
|
||||
|
||||
if [ -z "${TARGET}" ]; then
|
||||
echo "Usage: $0 <work_dir>"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
|
||||
mkdir ${TARGET}
|
||||
mkdir ${TARGET}/ramdisk
|
||||
mkdir ${TARGET}/firmware
|
||||
mkdir -p ${OUTPUT}/netboot/${ARCH}
|
||||
|
||||
./bin/basefs_init ${TARGET}/basefs ${DEBIAN_CODENAME}
|
||||
|
||||
cp -a ${TARGET}/basefs ${TARGET}/rootfs
|
||||
cp -a ${TARGET}/basefs ${TARGET}/helperfs
|
||||
|
||||
./bin/helperfs_config ${TARGET}/helperfs ${KERNEL_VERSION}
|
||||
|
||||
# ROOTFS
|
||||
|
||||
mkdir -p ${TARGET}/rootfs/lib/modules
|
||||
rsync -aS ${TARGET}/helperfs/lib/modules/ ${TARGET}/rootfs/lib/modules/
|
||||
./bin/rootfs_config ${TARGET}/rootfs ${DEBIAN_CODENAME}
|
||||
./bin/rootfs_clear ${TARGET}/rootfs
|
||||
./bin/rootfs_mksquashfs ${TARGET}/rootfs ${TARGET}/ramdisk/rootfs.squash
|
||||
|
||||
# RAMDISK
|
||||
|
||||
mkdir -p ${TARGET}/ramdisk/bin
|
||||
mkdir -p ${TARGET}/ramdisk/dev
|
||||
mkdir -p ${TARGET}/ramdisk/lib/modules
|
||||
mkdir -p ${TARGET}/ramdisk/proc
|
||||
mkdir -p ${TARGET}/ramdisk/sys
|
||||
cp ${TARGET}/helperfs/bin/busybox ${TARGET}/ramdisk/bin/busybox
|
||||
./bin/ramdisk_modules ${TARGET}/ramdisk ${TARGET}/rootfs ${KERNEL_VERSION}
|
||||
./bin/ramdisk_config ${TARGET}/ramdisk ${KERNEL_VERSION}
|
||||
./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
|
||||
./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 .
|
||||
./bin/dist_ipxe ${VERSION} ${OUTPUT}
|
||||
./bin/dist_ipxe ${VERSION} ${OUTPUT} --nofirmware
|
||||
./bin/dist_iso ${VERSION} ${ARCH} ${OUTPUT}
|
||||
./bin/dist_iso ${VERSION} ${ARCH} ${OUTPUT} --nofirmware
|
Loading…
Reference in New Issue
Block a user