aboutsummaryrefslogtreecommitdiff
path: root/GYGB.sh
blob: 0fcbc390dd6918e7d399062114f15140aba52ad0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
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 ""
	read -p "Press [Enter] key..."
	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 -p "Press [Enter] key to start the process..."
	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
header

echo -e "\e[1;92;49mHi, I can repair your grub"
echo "Hope you like it"
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
				classic
				clear
				echo "All Changes have been applied"
				echo "Now Select the restart option after pressing Enter"
				read -p "Press [Enter] key...'
				clear
				main-menu

		;;
2)			clear
				ubuntu
				echo "All Changes have been applied"
				echo "Now Select the restart option after pressing Enter"
				read -p "Press [Enter] key...'
				clear
				main-menu
		;;

3)		clear
			debian
			echo "All Changes have been applied"
			echo "Now Select the restart option after pressing Enter"
				read -p "Press [Enter] key...'
			clear
			main-menu
		;;
98)
	echo	Restarting
	sudo reboot

	;;
99)
	clear
	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