Advertisement
theroot

skc.sh

Jul 23rd, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.94 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. sbdir=''
  4. certdir='/usr/local/share/efitools/'
  5. bootdir='/boot'
  6. kernelver=${2}
  7. kernelsrc="/usr/src/linux-${kernelver}-gentoo"
  8. vmzfile="/arch/x86_64/boot/bzImage"
  9. bootfile="${bootdir}/kernel-signed-${kernelver}"
  10. rebuildboot="yes"
  11. bconfig="grub2-mkconfig"
  12. bconfigfile="/boot/grub2/grub.cfg"
  13.  
  14. . /etc/conf.d/skc.conf
  15.  
  16. function sanityCheck() {
  17.  
  18. if [ -d "$kernelsrc" ]
  19. then
  20.         if [ -f $bootfile ]
  21.         then
  22.                 echo -e "\nWARNING - BOOT OUTPUT FILE ( ${bootfile} ) ALREADY EXISTS. \nPLEASE APPEND NEW FILE ENDING ( ex _1 ) AT PROMPT OR [enter] TO OVERWRITE.\n"
  23.                 read newbootfile
  24.         else
  25.                 newbootfile=""
  26.         fi
  27.         bootfile=${bootfile}${newbootfile}
  28.         signKernel
  29. else
  30.         echo -e "\nWARNING - KERNEL SOURCE DIRECTORY ( ${kernelsrc} ) DOES NOT EXIST!\n"
  31. fi
  32.  
  33. }
  34.  
  35. function signKernel() {
  36.  
  37. echo -e "\nSIGNING NEW KERNEL AND COPYING TO BOOT LOCATION\n"
  38.  
  39. ${sbdir}sbsign --key ${certdir}DB.key --cert ${certdir}DB.crt --output ${bootfile} ${kernelsrc}/${vmzfile}
  40.  
  41. if [ $? -eq "0" ]
  42. then
  43.         if [ "${rebuildboot}" = "yes" ]
  44.         then
  45.                 configBoot
  46.         else
  47.                 echo "\nKERNEL IS INSTALLED AND READY TO BOOT!\n"
  48.         fi
  49. else
  50.         echo -e "\nSBSIGN RETURNED AN ERROR!\n"
  51.         exit 1
  52. fi
  53.  
  54. }
  55.  
  56. function configBoot() {
  57.  
  58. echo -e "\nREBUILDING BOOT CONFIG FILE\n"
  59.  
  60. ${bconfig} -o ${bconfigfile} 2>&1 |tee >/dev/null
  61.  
  62. if [ $? -eq "0" ]
  63. then
  64.         echo -e "\nKERNEL IS INSTALLED AND READY TO BOOT!\n"
  65. fi
  66.  
  67. }
  68.  
  69. function helpMe() {
  70.  
  71. echo -e $"\nMain Function:\n   { --install $KNEREL_VER }\n\n"
  72. echo -e "Options:   { --no-bconf } \n\n"
  73. echo -e "EX: '${0} --install 3.10.2'\n"
  74. echo -e "EX: '${0} --install 3.10.2 --no-bconf\n"
  75.  
  76. }
  77.  
  78. if [ "${1}" = "--install" ]
  79. then
  80.         if[ "${3}" = "--no-bconf" ]
  81.         then
  82.                 rebuildboot="no"
  83.         fi
  84.         sanityCheck
  85. else
  86.         helpMe
  87. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement