Package: freedombox-setup
Severity: wishlist
Tags: patch

This patch fixes some errors in the first-run flash-kernel script. They
didn't cause noticeable issues, but caused shellcheck to complain.

--
James
From 13e0a17d0ccdd08ae5175bae396837857bcda551 Mon Sep 17 00:00:00 2001
From: James Valleroy <[email protected]>
Date: Tue, 8 Sep 2015 21:40:25 -0400
Subject: [PATCH] Fix errors in flash-kernel first-run script. 'type' is a
 bashism. Use exit instead of return. Fix use of undefined variable
 mountpoint.

---
 first-run.d/80_flash-kernel | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/first-run.d/80_flash-kernel b/first-run.d/80_flash-kernel
index 9370c87..614c711 100755
--- a/first-run.d/80_flash-kernel
+++ b/first-run.d/80_flash-kernel
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # Update the kernel if package flash-kernel is install unless
 # requested otherwise.
@@ -6,26 +6,27 @@
 . /lib/lsb/init-functions
 
 if ! type flash-kernel > /dev/null 2>&1 ; then
-    return
+    log_warning_msg "Skipped Flashing Kernel: flash-kernel is not installed."
+    exit 0
 fi
 
 if [ -e /var/freedombox/dont-tweak-kernel ]
 then
     log_warning_msg "Skipped Flashing Kernel."
-    return
+    exit 0
 else
     . /usr/lib/freedombox/machine-detect
     if [ "$MACHINE" = "dreamplug" ]; then
-        kernel_version="$(/bin/ls $mountpoint/boot/vmlinuz-*-kirkwood | sort -rn | head -n1 | sed s#$mountpoint/boot/vmlinuz-##)"
+        kernel_version="$(/bin/ls /boot/vmlinuz-*-kirkwood | sort -rn | head -n1 | sed s#/boot/vmlinuz-##)"
     else
         if [ "$MACHINE" = "beaglebone" ]; then
-            kernel_version="$(/bin/ls $mountpoint/boot/vmlinuz-*-armmp | sort -rn | head -n1 | sed s#$mountpoint/boot/vmlinuz-##)"
+            kernel_version="$(/bin/ls /boot/vmlinuz-*-armmp | sort -rn | head -n1 | sed s#/boot/vmlinuz-##)"
         fi
     fi
 
     log_action_begin_msg "Flashing Kernel version $kernel_version "
 
-    if flash-kernel $kernel_version ; then
+    if flash-kernel "$kernel_version" ; then
 	log_action_end_msg 0
     else
 	log_action_end_msg 1
-- 
2.5.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to