diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2017-09-27 13:29:14 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-27 13:29:14 +0530 |
commit | 7fa23f447adeeeb01ad14553b615cf67d341396c (patch) | |
tree | 3e3bfde08a52bc31e982d49db81a083ef4fc3e77 /GYGB.sh | |
parent | c62e0ef9351ec6a82621592968a3f850b2d52e2d (diff) |
Fully Updated
Added more methods
Diffstat (limited to 'GYGB.sh')
-rw-r--r-- | GYGB.sh | 217 |
1 files changed, 148 insertions, 69 deletions
@@ -1,86 +1,165 @@ #!/bin/bash set x +trap "remind" 2 + + + +#Making Functions Here +remind(){ + clear + echo -e "\e[1;97;101mYou Should Not Exit like this, to exit enter 99 on the next screen\e[1;92;49m" + echo "" + echo "" + echo "Press Enter" + read j + main-menu +} +ubuntu(){ + echo "Enter the partition name where your distro has been installed" + echo "Eg. sda5" + echo "" + echo "" + ls -l /dev/disk/by-label/ + read XXX + clear + sudo grub-install /dev/$XXX + +} + +debian(){ + echo "Enter the partition name where your distro has been installed" + echo "Eg. sda5" + echo "" + echo "" + ls -l /dev/disk/by-label/ + read XXX + grub-mkdevicemap + grub-install /dev/$XXX + update-grub + +} + + + +header() { + + echo " _______ ____________ "; + echo " / ____\ \/ / ____/ __ )"; + echo " / / __ \ / / __/ __ |"; + echo " / /_/ / / / /_/ / /_/ / "; + echo " \____/ /_/\____/_____/ "; + echo " "; +} +classic(){ + lsblk -o NAME,FSTYPE,MOUNTPOINT,LABEL + echo "Enter the drive name containg your OS in the format sdXY replacing XY with the last two letters" + echo "(Most of the times its type is ext4)"; + echo "eg sda8"; + read linuxpart; + clear + lsblk -o NAME,FSTYPE,MOUNTPOINT,LABEL; + echo "Enter the drive name where EFI is located/mounted in the format sdXY"; + echo "Most of the times its type is vfat"; + echo "eg sda1" + read efipart + clear + echo "Your OS is located on $linuxpart and EFI partitoin is on $efipart Right ?" + echo "If something is wrong then exit the script and run it again, else press enter" + read what + echo "The process is starting.." + sudo mount /dev/$linuxpart /mnt + for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done + sudo mount /dev/$efipart /mnt/boot/efi + sudo chroot /mnt + sudo update-grub + sudo grub-install /dev/sda + sudo update-grub +} + + + +main-menu(){ clear -echo " ______________________________ "; -echo " / _____/\_ _____/\__ ___/ "; -echo "/ \ ___ | __)_ | | "; -echo "\ \_\ \| \ | | "; -echo " \______ /_______ / |____| "; -echo " \/ \/ "; -echo "_____.___.________ ____ _____________ "; -echo "\__ | |\_____ \ | | \______ \ "; -echo " / | | / | \| | /| _/ "; -echo " \____ |/ | \ | / | | \ "; -echo " / ______|\_______ /______/ |____|_ / "; -echo " \/ \/ \/ "; -echo " __________________ ____ _____________ "; -echo " / _____/\______ \ | \______ \ "; -echo "/ \ ___ | _/ | /| | _/ "; -echo "\ \_\ \| | \ | / | | \ "; -echo " \______ /|____|_ /______/ |______ / "; -echo " \/ \/ \/ "; -echo "__________ _____ _________ ____ __. "; -echo "\______ \ / _ \ \_ ___ \| |/ _| "; -echo " | | _/ / /_\ \/ \ \/| < "; -echo " | | \/ | \ \___| | \ "; -echo " |______ /\____|__ /\______ /____|__ \ "; -echo " \/ \/ \/ \/ "; -echo " "; -echo " "; -echo " "; -echo " "; -echo " "; -echo " "; -echo "Hi, I can repair your GRUB by updating it and or installing it" -echo "Disclaimer: IT IS ONLY FOR LAPTOPs/PCs with EFI" +header + +echo -e "\e[1;92;49mHi, I can repair your grub" echo "Hope you like it" -echo Choose any option -echo "1) Repair my grub" -echo "2) Restart" -echo "4) Exit" +echo "Choose an option" +echo -e "1) The Classic Way (FOR EFI SYSTEMS ONLY)" +echo -e "2) The Ubuntu Way \e[1;97;44mFor Ubuntu Distros \e[1;92;49m " +echo -e "3) The Debian Way (For Debian Distros)" +echo -e "" + + + + + +echo -e "98) Restart" +echo -e "99) Exit" read option case $option in + 1) - clear - echo "Cha-Ching" - lsblk -o NAME,FSTYPE,MOUNTPOINT,LABEL - echo "Enter the drive name containg your OS in the format sdXY replacing XY with the last two letters" - echo "(Most of the times its type is ext4)"; - echo "eg sda8"; - read linuxpart; clear - lsblk -o NAME,FSTYPE,MOUNTPOINT,LABEL; - echo "Enter the drive name where EFI is located/mounted in the format sdXY"; - echo "Most of the times its type is vfat"; - echo "eg sda1" - read efipart + classic + clear + echo "All Changes have been applied" + echo "Now Select the restart option after pressing Enter" + read nothing clear - echo "Your OS is located on $linuxpart and EFI partitoin is on $efipart Right ?" - echo "If something is wrong then exit the script and run it again, else press enter" - read what - echo "The process is starting.." - sudo mount /dev/$linuxpart /mnt - for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done - sudo mount /dev/$efipart /mnt/boot/efi - sudo chroot /mnt - sudo update-grub - sudo grub-install /dev/sda - sudo update-grub + main-menu + + ;; +2) clear + ubuntu + echo "All Changes have been applied" + echo "Now Select the restart option after pressing Enter" + read nothing clear - echo "Go Restart, everything has been done" + main-menu ;; -2) + +3) clear + debian + echo "All Changes have been applied" + echo "Now Select the restart option after pressing Enter" + read nothing + clear + main-menu + ;; +98) echo Restarting restart ;; -4) - echo "Sure" +99) + clear exit ;; -*) - echo "Invalid Input, looks like you dont want your grub to be repaired" - echo "Press Enter to Exit" - read exit2 - exit - ;; +*) + clear + echo "Invalid Input, looks like you dont want your grub to be repaired" + echo "" + echo "" + main-menu + ;; esac +} + + + + + + +#Checking Root Permission here + +clear +if [ "$EUID" -ne 0 ] + then echo "Please run as root" + exit +fi + + +clear + +#Start of Program +main-menu |