From ab89f382f1b3492a299c58fd34f1e010e556a88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Tue, 5 Apr 2016 11:30:21 +0200 Subject: [PATCH] Various improvements to memtest-setup, e.g. now exits with error if run by non root user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jaroslav Škarvada --- memtest-setup | 25 +++++++++++++++++++++---- memtest86+.spec | 6 +++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/memtest-setup b/memtest-setup index 2522ad1..b674171 100755 --- a/memtest-setup +++ b/memtest-setup @@ -18,6 +18,12 @@ G2TEMPL="20_memtest86+" # GRUB 2 environment file CONF_FILE="/etc/memtest86+.conf" +# GRUB legacy configuration file +GRUBCONF="/boot/grub/grub.conf" + +# GRUB2 configuration file +GRUB2CFG="/boot/grub2/grub.cfg" + # GRUB2 environment variable to control image type CONF_VAR="INSTALL_ELF" @@ -33,7 +39,7 @@ It supports both GRUB 2 and GRUB Legacy (i.e. GRUB 0.9x). In case of GRUB 2 it installs GRUB 2 template into /etc/grub.d and GRUB 2 config needs to be regenerated manually by running: -grub2-mkconfig -o /boot/grub2/grub.cfg +grub2-mkconfig -o $GRUB2CFG This is not done automatically because it could overwrite any custom changes in /boot/grub2/grub.cfg. @@ -61,11 +67,17 @@ else fi if [ -d /sys/firmware/efi ]; then - echo "memtest86+ does not support EFI platforms." + echo "ERROR: memtest86+ does not support EFI platforms." exit 254 fi -if [ -f /boot/grub2/grub.cfg ]; then +if [ ! -r "$GRUBCONF" -a ! -r "$GRUB2CFG" ]; then + echo "ERROR: unable to read grub configuration file. Do you have enough permissions?" + echo "Try to run as root." + exit 249 +fi + +if [ -f "$GRUB2CFG" ]; then echo "GRUB 2 detected, installing template..." if [ ! -d /etc/grub.d ]; then echo "ERROR: unable to find /etc/grub.d" @@ -89,11 +101,16 @@ if [ -f /boot/grub2/grub.cfg ]; then chmod a+x /etc/grub.d/$G2TEMPL echo "GRUB 2 template installed." echo "Do not forget to regenerate your grub.cfg by:" - echo " # grub2-mkconfig -o /boot/grub2/grub.cfg" + echo " # grub2-mkconfig -o $GRUB2CFG" else MTVERSION=`rpm -q --qf '%{version}' $PNAME` MTPATH="/boot/$ENAME-$MTVERSION" + if [ ! -r "$GRUBCONF" ]; then + echo "ERROR: $GRUBCONF not found or not readable." + exit 252 + fi + MENT=`cat /boot/grub/grub.conf | grep "$ENAME-$MTVERSION"` &> /dev/null if [ "$MENT" != "" ]; then echo "$MTPATH is already configured. Exiting..." diff --git a/memtest86+.spec b/memtest86+.spec index 0988825..0602480 100644 --- a/memtest86+.spec +++ b/memtest86+.spec @@ -9,7 +9,7 @@ Name: memtest86+ Version: 5.01 -Release: 14%{?dist} +Release: 15%{?dist} License: GPLv2 Summary: Stand-alone memory tester for x86 and x86-64 computers Group: System Environment/Base @@ -122,6 +122,10 @@ fi %{_mandir}/man8/*.8.gz %changelog +* Tue Apr 5 2016 Jaroslav Škarvada - 5.01-15 +- Various improvements to memtest-setup, e.g. now exits with error if + run by non root user + * Tue Feb 23 2016 Jaroslav Škarvada - 5.01-14 - Removed some spec artifacts (like buildroot cleaning) - Fixed malformed "Loading" banner