Various improvements to memtest-setup, e.g. now exits with error if run by non root user

Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
This commit is contained in:
Jaroslav Škarvada 2016-04-05 11:30:21 +02:00
parent aa2158d546
commit ab89f382f1
2 changed files with 26 additions and 5 deletions

View File

@ -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..."

View File

@ -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 <jskarvad@redhat.com> - 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 <jskarvad@redhat.com> - 5.01-14
- Removed some spec artifacts (like buildroot cleaning)
- Fixed malformed "Loading" banner