Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- sbdir=''
- certdir='/usr/local/share/efitools/'
- bootdir='/boot'
- kernelver=${2}
- kernelsrc="/usr/src/linux-${kernelver}-gentoo"
- vmzfile="/arch/x86_64/boot/bzImage"
- bootfile="${bootdir}/kernel-signed-${kernelver}"
- rebuildboot="yes"
- bconfig="grub2-mkconfig"
- bconfigfile="/boot/grub2/grub.cfg"
- . /etc/conf.d/skc.conf
- function sanityCheck() {
- if [ -d "$kernelsrc" ]
- then
- if [ -f $bootfile ]
- then
- echo -e "\nWARNING - BOOT OUTPUT FILE ( ${bootfile} ) ALREADY EXISTS. \nPLEASE APPEND NEW FILE ENDING ( ex _1 ) AT PROMPT OR [enter] TO OVERWRITE.\n"
- read newbootfile
- else
- newbootfile=""
- fi
- bootfile=${bootfile}${newbootfile}
- signKernel
- else
- echo -e "\nWARNING - KERNEL SOURCE DIRECTORY ( ${kernelsrc} ) DOES NOT EXIST!\n"
- fi
- }
- function signKernel() {
- echo -e "\nSIGNING NEW KERNEL AND COPYING TO BOOT LOCATION\n"
- ${sbdir}sbsign --key ${certdir}DB.key --cert ${certdir}DB.crt --output ${bootfile} ${kernelsrc}/${vmzfile}
- if [ $? -eq "0" ]
- then
- if [ "${rebuildboot}" = "yes" ]
- then
- configBoot
- else
- echo "\nKERNEL IS INSTALLED AND READY TO BOOT!\n"
- fi
- else
- echo -e "\nSBSIGN RETURNED AN ERROR!\n"
- exit 1
- fi
- }
- function configBoot() {
- echo -e "\nREBUILDING BOOT CONFIG FILE\n"
- ${bconfig} -o ${bconfigfile} 2>&1 |tee >/dev/null
- if [ $? -eq "0" ]
- then
- echo -e "\nKERNEL IS INSTALLED AND READY TO BOOT!\n"
- fi
- }
- function helpMe() {
- echo -e $"\nMain Function:\n { --install $KNEREL_VER }\n\n"
- echo -e "Options: { --no-bconf } \n\n"
- echo -e "EX: '${0} --install 3.10.2'\n"
- echo -e "EX: '${0} --install 3.10.2 --no-bconf\n"
- }
- if [ "${1}" = "--install" ]
- then
- if[ "${3}" = "--no-bconf" ]
- then
- rebuildboot="no"
- fi
- sanityCheck
- else
- helpMe
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement