From de34afa5e0ae8c8b6041e2526962674d8a11f7c1 Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Sun, 31 Mar 2019 21:57:50 -0600 Subject: mkinitramfs:add init linting before starting build This checks the init script for any syntax errors, which could prevent producing an unbootable initramfs archive, should the end user make manual changes to the init script that contain syntax errors. --- mkinitramfs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mkinitramfs b/mkinitramfs index b0b015e..e36763b 100755 --- a/mkinitramfs +++ b/mkinitramfs @@ -191,6 +191,14 @@ function main { local cache='/tmp/initrd' local res_path=/usr/share/mkinitramfs/ + # Ensure init script has no syntax errors (linting process) + if ! bash -n ${res_path}/init; then + printf '\n\nERROR: Syntax errors were found in the init script.\n' + printf 'Please resolve the above issues and try again.\n' + printf 'Exiting to avoid creating an unbootable initramfs.\n\n' + return 1 + fi + # List of binaries to exist in the new initramfs resolve_bins \ bash cat echo ls cryptsetup chmod chown mount sleep umount clear cut \ -- cgit v1.2.3