From 3f3fd1a851677fd9400bf4e5484ee000487c6834 Mon Sep 17 00:00:00 2001
From: James Meyer <james.meyer@operamail.com>
Date: Sun, 26 Aug 2012 11:52:53 -0500
Subject: LinHES-config: mv_install.  fix grub2  defaults file on install.  set
 timeout to 0 and hidden for 5

---
 abs/core/LinHES-config/mv_install.py | 46 +++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/abs/core/LinHES-config/mv_install.py b/abs/core/LinHES-config/mv_install.py
index 260a275..af7d8a6 100755
--- a/abs/core/LinHES-config/mv_install.py
+++ b/abs/core/LinHES-config/mv_install.py
@@ -857,21 +857,55 @@ def fstab_it(install_type):
 def grub_it():
     logging.info("______Start of grub install______")
     cmd = "chroot %s grub-install --target=i386-pc --recheck --debug /dev/%s"  %(data_config.MOUNTPOINT,hostoptions["rootdisk"])
-    logging.info("Running grub-install")
+    logging.info("    Running grub-install")
     runcmd(cmd)
 
     cmd = "  mkinitcpio  -g %s/boot/initramfs-linux.img" %(data_config.MOUNTPOINT)
     logging.info("Running mkinitcpio")
     runcmd(cmd)
+    newgrub = []
+    grubfile = data_config.MOUNTPOINT+"/etc/default/grub"
+    try:
+        f = open(grubfile,  'r')
+        oldgrub = f.readlines()
+
+        f.close()
+    except:
+        logging.debug("    Couldn't open grub file for reading")
+        pass
+
+    time_line   = "GRUB_TIMEOUT="
+    hidden_time = "GRUB_HIDDEN_TIMEOUT="
+    color_line  = "GRUB_COLOR"
+
+    for line in oldgrub:
+        new_line=line
+        if line.find(time_line) != -1 :
+            new_line="GRUB_TIMEOUT=0\n"
+
+        if line.find(color_line) != -1 :
+            new_line=line.lstrip('''#''')
+
+        if line.find(hidden_time) != -1 :
+            new_line="GRUB_HIDDEN_TIMEOUT=5\n"
+
+        newgrub.append(new_line)
+
+    if len(newgrub) > 0:
+        try:
+            f = open(grubfile,  'w')
+            for line in newgrub:
+                logging.debug(line)
+                f.write(line)
+            f.close()
+        except:
+            logging.debug("    Couldn't open grub file for writing")
+
 
 
     cmd="chroot %s grub-mkconfig -o /boot/grub/grub.cfg" %data_config.MOUNTPOINT
     runcmd(cmd)
-    #rootuuid = find_uuid(hostoptions["rootpartition"])
-    #cmd = "  mkinitcpio -b %s -g %s/boot/kernel26.img" %(data_config.MOUNTPOINT, data_config.MOUNTPOINT)
-    #cmd = "  mkinitcpio  -g %s/boot/initramfs-linux.img" %(data_config.MOUNTPOINT)
-    #logging.info("Running mkinitcpio")
-    #runcmd(cmd)
+
 
 def grub_it1():
     logging.info("______Start of grub install______")
-- 
cgit v0.12

