aboutsummaryrefslogtreecommitdiffsponsor
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2024-04-29 16:35:46 -0500
committerSlack Coder <slackcoder@server.ky>2024-04-29 16:35:46 -0500
commit370c6453f86c77e11b12f096bb36e42bb0f4fe35 (patch)
tree05950912a582766ee2029601674a5f3b8a82f950
parent28613aefdeca15ff5a857adf9d5d2b3dd4fdf53f (diff)
downloadefi-sync-370c6453f86c77e11b12f096bb36e42bb0f4fe35.tar.xz
Improve logging and initrd generation
- Make the Initial RAM disk locations configurable, instead of leaving it to mkinitrd. - Improve logging information. - Reduce wait time to check if package tools are still running.
-rw-r--r--README.md11
-rw-r--r--efi-sync36
2 files changed, 30 insertions, 17 deletions
diff --git a/README.md b/README.md
index dd1f1ad..9982c6d 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,7 @@ Usage: ./efi-sync {install|watch}
```
`efi-sync` watches your kernel path for updates. Once one is detected and the
-package commands have completed, your EFI will be updated. `mkinitrd` to
-update your initial ram disk if its configuration file is present.
+package commands have completed, your EFI will be updated.
## Installation
@@ -33,7 +32,11 @@ Here is an example with the default values:
KERNEL=/boot/vmlinuz
# The path to the EFI kernel.
EFI_KERNEL=/boot/efi/Slackware/vmlinuz
+# The path for the initial ram disk to install.
+INITRD=/boot/initrd.gz
+# The path to the EFI's initial ram disk.
+EFI_INITRD=/boot/efi/Slackware/initrd.gz
```
-If you want the initial ram disk updated, ensure /etc/mkinitrd.conf exists and
-'OUTPUT_IMAGE' is set to the initrd.gz path on your EFI.
+The initial ram disk (initrd) will be built automatically if
+'/etc/mkinitrd.conf' exists.
diff --git a/efi-sync b/efi-sync
index 331ce06..f8be4f4 100644
--- a/efi-sync
+++ b/efi-sync
@@ -22,13 +22,15 @@ graceful_exit () {
load_config() {
KERNEL=/boot/vmlinuz
EFI_KERNEL=/boot/efi/EFI/Slackware/vmlinuz
+ INITRD=/boot/initrd.gz
+ EFI_INITRD=/boot/efi/EFI/Slackware/initrd.gz
if [[ -f /etc/efi-sync.conf ]]; then
source /etc/efi-sync.conf || exit 1
fi
INSTALL_PROGRAMS="slackpkg,upgradepkg,installpkg,removepkg"
- WAIT_TIME=5
+ WAIT_TIME=1
}
log () {
@@ -64,10 +66,18 @@ efi_install () {
if [[ -f /etc/mkinitrd.conf ]]; then
if ! mkinitrd -F -c -k "${KERNEL_VERSION}" >/dev/null 2>&1; then
- log "mkinitrd failed to build and install your initial ramdisk."
+ log "mkinitrd.conf detected but failed to build your initial ramdisk for '${KERNEL_VERSION}'."
return 1
fi
- log "Installed the initial RAM disk for kernel version '${KERNEL_VERSION}'."
+ log "mkinitrd.conf detected and successfully built your initial ramdisk for '${KERNEL_VERSION}'."
+ fi
+
+ if [[ -f "$INITRD" ]] && [[ "$INITRD" != "$EFI_INITRD" ]]; then
+ if [[ "$INITRD" != "$EFI_INITRD" ]] && ! cp -H "$INITRD" "${EFI_INITRD}"; then
+ log "Failed to copy '${INITRD}' into your EFI at '${EFI_INITRD}'."
+ return 1
+ fi
+ log "Installed the initial RAM disk '${INITRD}'."
fi
}
@@ -109,18 +119,18 @@ efi_watch () {
while true; do
touch "$TIMESTAMP_FILE"
- if [[ -f /etc/mkinitrd.conf ]]; then
- local count=0
+ let "count = 0"
+ while [[ $count -lt $WAIT_TIME ]]; do
+ if ps -C "$INSTALL_PROGRAMS" >/dev/null; then
+ let "count = 0"
+ sleep 1
- while [[ $count -lt ${WAIT_TIME} ]]; do
- while ps -C "${INSTALL_PROGRAMS}" >/dev/null; do
- let "count = 0"
- sleep 1
- done
+ continue
+ fi
- let "count = $count + 1"
- done
- fi
+ let "count = $count + 1"
+ sleep 1
+ done
efi_install