summaryrefslogtreecommitdiff
path: root/make-boot-image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'make-boot-image.sh')
-rwxr-xr-xmake-boot-image.sh165
1 files changed, 73 insertions, 92 deletions
diff --git a/make-boot-image.sh b/make-boot-image.sh
index 2980e3a..18cbe01 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -9,16 +9,16 @@ WORKDIR=./work # Must not be with "nodev" mount option
DLDIR=./downloads
OUTDIR=./out
#OUTUSB=/dev/sdb # If enabled, it could wreck everything there !
-LEGACY=y # make USB bootable key compatible with non UEFI-BIOS
-DEVEL_MODE=y # Adds debugging tools in the generated image
-INCLUDE_TCPDUMP=y # tcpdump costs few Mb with libcrypto
+LEGACY=n # make USB bootable key compatible with non UEFI-BIOS
+DEVEL_MODE=n # Adds debugging tools in the generated image
+INCLUDE_TCPDUMP=n # tcpdump costs few Mb with libcrypto
ROOTCMD=sudo
WGET="wget" # "wget --no-check-certificate" could help but is a security concern
# You probably need to tweak version numbers if you have an HTTP 404 - Not found error
KERNEL_TARBALL_URL=https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.19.17.tar.xz
KCONFIGLIB_MAIN_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/v10.36.0/kconfiglib.py
KCONFIGLIB_PATCH_URL=https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch
-#NIC_FIRMWARE_URL=http://fr.archive.ubuntu.com/ubuntu/pool/main/l/linux-firmware/nic-firmware_1.169_all.udeb
+NIC_FIRMWARE_URL=http://fr.archive.ubuntu.com/ubuntu/pool/main/l/linux-firmware/linux-firmware_1.173.5_all.deb
BUSYBOX_BIN_URL=https://busybox.net/downloads/binaries/1.26.2-defconfig-multiarch/busybox-x86_64
PCI_IDS_URL=https://pci-ids.ucw.cz/v2.2/pci.ids
USB_IDS_URL=https://usb-ids.gowdy.us/usb.ids
@@ -196,8 +196,8 @@ while more_work and i < passes:
if sym.name in ['EFI_STUB', 'EARLY_PRINTK_EFI', 'EFI_VARS', 'DELL_RBU', 'USB_XHCI_HCD', 'IKCONFIG']:
more_work = sset(sym) or more_work
- # Support soft RAID (linux) and hard RAID (some cards)
- if sym.name in ['DM_RAID', 'SCSI_LOWLEVEL', 'MEGARAID_SAS', 'MEGARAID_NEWGEN']:
+ # Support FUSE, soft RAID (linux) and hard RAID (some cards)
+ if sym.name in ['FUSE_FS', 'DM_RAID', 'SCSI_LOWLEVEL', 'MEGARAID_SAS', 'MEGARAID_NEWGEN']:
more_work = sset(sym) or more_work
# If --debug passed as arg, make kernel aware of virtual drivers (used for testing eficast on qemu/kvm)
@@ -292,7 +292,7 @@ fi
if [ ! -s "$WORKDIR/initrd/etc/keys.bmap" ]
then
# FIXME fails on Debian 9 and 10
- #$ROOTCMD dumpkeys | $ROOTCMD loadkeys -b > "$WORKDIR/initrd/etc/keys.bmap"
+ $ROOTCMD dumpkeys | $ROOTCMD loadkeys -ub > "$WORKDIR/initrd/etc/keys.bmap"
cp -a /etc/localtime "$WORKDIR/initrd/etc/"
fi
@@ -372,11 +372,15 @@ then [ -s "$DLDIR/pci.ids" ] || $WGET -O "$DLDIR/pci.ids" "$PCI_IDS_URL"
cp "$DLDIR/pci.ids" "$WORKDIR/initrd/usr/share/misc/"
fi
-#if [ ! -d "$WORKDIR/initrd/lib/firmware" ]
-#then [ -s "$DLDIR/nic-firmware.deb" ] || $WGET -O "$DLDIR/nic-firmware.deb" "$NIC_FIRMWARE_URL"
-# dpkg -x "$DLDIR/nic-firmware.deb" "$WORKDIR/initrd/"
-# find "$WORKDIR/initrd/lib/firmware/" \( -name 'ipw*' -o -name 'brcmfmac*' -o -name '*wifi*' \) -print0 | xargs -r0 rm -v
-#fi
+if [ ! -d "$WORKDIR/firmware" ]
+then [ -s "$DLDIR/nic-firmware.deb" ] || $WGET -O "$DLDIR/nic-firmware.deb" "$NIC_FIRMWARE_URL"
+ mkdir -p "$WORKDIR/firmware"
+ dpkg -x "$DLDIR/nic-firmware.deb" "$WORKDIR/firmware/"
+fi
+if [ ! -d "$WORKDIR/initrd/lib/firmware/rtl_nic" ]
+then mkdir -p "$WORKDIR/initrd/lib/firmware"
+ cp -r "$WORKDIR/firmware/lib/firmware/rtl_nic" "$WORKDIR/initrd/lib/firmware/"
+fi
echo $VERSION > "$WORKDIR/initrd/etc/eficast_version"
@@ -446,37 +450,49 @@ network_show() {
setterm -bold off
}
-autorun() {
- echo_color green black "$1-autorun.sh script will run on tmux-main-pane now"
- read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
-
- # tmux since 2.x absolutly wants a working UTF-8 locale (C.UTF-8 is okay)
- # pane-border-* options are supported since tmux 2.3
- tmux \
- new-session -d "/etc/rc.d/tmux-main-pane $1" \; \
- set -g pane-border-status top \; \
- set -g pane-border-format " #T " \; \
- set-window-option status off \; \
- split-window -t %0 -l1 -b pigz-watch progression
-
- if [ $(tput lines) -gt 30 ]
- then tmux \
- split-window -t %0 -l5 mpstat-watch cpu-softintr \; \
- split-window -t %0 -l10 iostat-watch cpu-disk \; \
- split-window -h -p26 pstree-watch processes \; \
- split-window -t -1 iftop-watch network
+autorun_cleanup() {
+ if [ -f /run/rescue ]
+ then rm /run/rescue
+ echo_color green black "function autorun() is exiting. Spawn rescue_shell now"
+ rescue_shell
fi
+}
- tmux select-pane -t:.0 \; attach
+autorun() {
+ trap autorun_cleanup INT TERM EXIT
+ echo_color green black "$1-autorun.sh script will run on now"
+ read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
- # Hack to keep the error flow intact
- if [ -r /run/autorun_res ]
- then res=$(cat /run/autorun_res)
- rm /run/autorun_res
- else res=1
- fi
- echo_color green black "tmux-main-pane exit code : $res"
- return $res
+ case $1 in
+ initrd) echo -ne "\e]2;initrd-autorun.sh\007" # Term title (tmux)
+ message initrd autorun
+ source /etc/rc.d/initrd-autorun.sh
+ ;;
+ nfs) source nfs-mount
+ if [ $? -ne 0 ]
+ then echo_color white red "----- NFS server : not mounted ------"
+ echo_color green black "Check for failure above. Exiting rescue shell will retry everything"
+ false; cleanup
+ fi
+ if ! [ -x /mnt/nfs/nfs-autorun.sh ]
+ then echo_color white red "----- NFS server : missing script ------"
+ echo_color green black "Check nfs-autorun.sh : should be present, readable and executable"
+ ls -l /mnt/nfs
+ false; cleanup
+ fi
+ echo_color white green "----- NFS server ready ------"
+ message nfs autorun
+ echo -ne "\e]2;nfs-autorun.sh\007" # Term title (tmux)
+ cd /mnt/nfs
+ # don't use source here, exit in inner script will skip cleanup routine (and rescue_shell)
+ ./nfs-autorun.sh
+ ;;
+ *) echo "Usage : $0 (nfs|initrd)"
+ false;;
+ esac
+ res=$?
+ [ $res -eq 0 ] || touch /run/rescue
+ echo_color green black "function autorun() return code : $res"
}
notes() {
@@ -566,8 +582,22 @@ coldplugging() {
}
network_up() {
- ip -oneline link | grep DOWN | cut -d: -f2 | grep -v sit | while read iface
+ ip -oneline link | grep DOWN | cut -d: -f2 | grep -v sit | grep -v lo | while read iface
do
+ # BugFix Intel 217LM + WakeOnLan + dual-boot Windows 10
+ # After Windows hibernation or fast boot powerdown, link goes up but no network packets go out of the chip
+ d=/sys/class/net/$iface/device
+ if [ 0x153a = $(cat $d/device) ]
+ then echo 1 \> $d/reset
+ echo 1 > $d/reset
+ fi
+ # BugFix Realtek 8168 + dual-boot Windows 10
+ # After reboot to linux, linux kernel don't load firmware, link never came up
+ if [ 0x8168 = $(cat $d/device) ]
+ then echo 1 \> $d/reset
+ echo 1 > $d/reset
+ fi
+
echo ip link set dev $iface up
ip link set dev $iface up
done
@@ -598,7 +628,7 @@ network_conf
network_show
machine_info
-touch /run/nosound
+#touch /run/nosound
autorun nfs && eficast_end
#autorun initrd && eficast_end
set +v
@@ -618,54 +648,6 @@ else touch /run/rescue
/etc/rc.d/rc2
fi
EOF
-add_initrd_script "/etc/rc.d/tmux-main-pane" <<"EOF"
-# Drop a in-tmux rescue shell in case of failure, prevents clearing screen with valuable informations
-source /etc/rc.d/funcs # Load helper functions
-# Helper to trap user interruption and error cases
-# Will exit the entire tmux, leaving last error code availble in a file
-cleanup() {
- res=$?
- echo $res > /run/autorun_res
- if [ $res -ne 0 ]
- then rm /run/rescue
- echo_color green black "/etc/rc.d/tmux-main-pane is exiting. Spawn rescue_shell in tmux now"
- rescue_shell
- fi
- tmux kill-server
- exit
-}
-trap cleanup INT TERM
-
-case $1 in
- initrd) echo -ne "\e]2;initrd-autorun.sh\007" # Term title (tmux)
- message initrd autorun
- source /etc/rc.d/initrd-autorun.sh
- ;;
- nfs) source nfs-mount
- if [ $? -ne 0 ]
- then echo_color white red "----- NFS server : not mounted ------"
- echo_color green black "Check for failure above. Exiting rescue shell will retry everything"
- false; cleanup
- fi
- if ! [ -x /mnt/nfs/nfs-autorun.sh ]
- then echo_color white red "----- NFS server : missing script ------"
- echo_color green black "Check nfs-autorun.sh : should be present, readable and executable"
- ls -l /mnt/nfs
- false; cleanup
- fi
- echo_color white green "----- NFS server ready ------"
- message nfs autorun
- echo -ne "\e]2;nfs-autorun.sh\007" # Term title (tmux)
- cd /mnt/nfs
- # don't use source here, exit in inner script will skip cleanup routine (and rescue_shell)
- ./nfs-autorun.sh
- ;;
- *) echo "Usage : $0 (nfs|initrd)"
- false;;
-esac
-cleanup
-# Don't add code between esac and cleanup, $? is used
-EOF
add_initrd_script "/sbin/hotplug" <<"EOF"
# Be verbose for PCI cards, be silent for the rest (many many things), log everything
# No support for change or remove events
@@ -721,8 +703,7 @@ EOF
add_initrd_script "/bin/pstree-watch" <<"EOF"
echo -ne "\e]2;$*\007" # Term title (tmux)
while true; do
- pid=$(pidof tmux-main-pane | tr ' ' '\n' | sort -n | head -n1)
- [ -n "$pid" ] && watch -t "pstree -p $pid"
+ watch -t "pstree"
sleep 1
done
EOF