[4/4] iucode-tool: rewrite init script

Message ID 20181104210241.20237-5-casantos@datacom.com.br
State Accepted
Commit 9e323088cb179f6b3d8bcb9ec388eb41c1d018e4
Headers show
Series
  • update/improve intel-microcode and iucode-tool
Related show

Commit Message

Carlos Santos Nov. 4, 2018, 9:02 p.m.
- Indent with tabs.
- Use a function for start.
- Use a dummy function that reports OK for stop, restart and reload.
- Pass "-q" to iucode_tool to inhipt usual output taht would otherwise
  interfere with the operation status report.

Signed-off-by: Carlos Santos <casantos@datacom.com.br>
---
 package/iucode-tool/S00iucode-tool | 37 +++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 14 deletions(-)

Comments

Peter Korsgaard Nov. 12, 2018, 9:47 p.m. | #1
>>>>> "Carlos" == Carlos Santos <casantos@datacom.com.br> writes:

 > - Indent with tabs.
 > - Use a function for start.
 > - Use a dummy function that reports OK for stop, restart and reload.
 > - Pass "-q" to iucode_tool to inhipt usual output taht would otherwise

s/inhipt/inhibit/
s/taht/that/

>   interfere with the operation status report.

 > Signed-off-by: Carlos Santos <casantos@datacom.com.br>
 > ---
 >  package/iucode-tool/S00iucode-tool | 37 +++++++++++++++++++-----------
 >  1 file changed, 23 insertions(+), 14 deletions(-)

 > diff --git a/package/iucode-tool/S00iucode-tool b/package/iucode-tool/S00iucode-tool
 > index a97b33c045..eb9f93ad6e 100644
 > --- a/package/iucode-tool/S00iucode-tool
 > +++ b/package/iucode-tool/S00iucode-tool
 > @@ -5,19 +5,28 @@
 
 >  MICROCODE_DIR="/lib/firmware/intel-ucode"
 
 > +start() {
 > +	printf 'Starting iucode-tool: '
 > +	/usr/sbin/iucode_tool -q -k "$MICROCODE_DIR"
 > +	status="$?"
 > +	if [ "$status" = 0 ]; then
 > +		echo "OK"
 > +	else
 > +		echo "FAIL"
 > +	fi
 > +	return "$status"
 > +}
 > +
 > +dummy() {
 > +	echo "$1" | sed 's/^./\U&\E/;s/p/pp/;s/$/ing iucode-tool: OK/'

This is IMHO not very readable, and busybox sed doesn't like it:

# echo 'stop' | sed 's/^./\U&\E/;s/p/pp/;s/$/ing iucode-tool: OK/'
UsEtopping iucode-tool: OK

So I've dropped this and committed to next, thanks.

> +}
 > +
 >  case "$1" in
 > -  start)
 > -	echo "Starting iucode-tool:"
 > -	/usr/sbin/iucode_tool -k "$MICROCODE_DIR"
 > -	echo "done"
 > -	;;
 > -  stop)
 > -	;;
 > -  restart|reload)
 > -	;;
 > -  *)
 > -	echo "Usage: $0 {start|stop|restart}"
 > -	exit 1
 > +	start)
 > +		start;;
 > +	stop|restart|reload)
 > +		dummy "$1";;
 > +	*)
 > +		echo "Usage: $0 {start|stop|restart}"

You forgot to document "reload".

Patch

diff --git a/package/iucode-tool/S00iucode-tool b/package/iucode-tool/S00iucode-tool
index a97b33c045..eb9f93ad6e 100644
--- a/package/iucode-tool/S00iucode-tool
+++ b/package/iucode-tool/S00iucode-tool
@@ -5,19 +5,28 @@ 
 
 MICROCODE_DIR="/lib/firmware/intel-ucode"
 
+start() {
+	printf 'Starting iucode-tool: '
+	/usr/sbin/iucode_tool -q -k "$MICROCODE_DIR"
+	status="$?"
+	if [ "$status" = 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+dummy() {
+	echo "$1" | sed 's/^./\U&\E/;s/p/pp/;s/$/ing iucode-tool: OK/'
+}
+
 case "$1" in
-  start)
-	echo "Starting iucode-tool:"
-	/usr/sbin/iucode_tool -k "$MICROCODE_DIR"
-	echo "done"
-	;;
-  stop)
-	;;
-  restart|reload)
-	;;
-  *)
-	echo "Usage: $0 {start|stop|restart}"
-	exit 1
+	start)
+		start;;
+	stop|restart|reload)
+		dummy "$1";;
+	*)
+		echo "Usage: $0 {start|stop|restart}"
+		exit 1
 esac
-
-exit $?