diff options
author | Aaron Ball <nullspoon@oper.io> | 2019-03-31 21:57:50 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2019-03-31 21:57:50 -0600 |
commit | de34afa5e0ae8c8b6041e2526962674d8a11f7c1 (patch) | |
tree | bbf32d2b25467c0182913aeff4afc88c0af350d5 | |
parent | 80b483858121166e76c94a60f62126215a757c52 (diff) | |
download | mkinitramfs-de34afa5e0ae8c8b6041e2526962674d8a11f7c1.tar.gz mkinitramfs-de34afa5e0ae8c8b6041e2526962674d8a11f7c1.tar.xz |
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.
-rwxr-xr-x | mkinitramfs | 8 |
1 files changed, 8 insertions, 0 deletions
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 \ |