1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
os-k/boot/grub/grub-install.sh

65 lines
3.1 KiB
Bash
Raw Normal View History

#=----------------------------------------------------------------------------=#
# GNU GPL OS/K #
# #
# Desc: Grub installation script for the OS/K image #
# #
# #
# Copyright © 2018-2019 The OS/K Team #
# #
# This file is part of OS/K. #
# #
# OS/K is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# any later version. #
# #
# OS/K is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY# without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with OS/K. If not, see <https://www.gnu.org/licenses/>. #
#=----------------------------------------------------------------------------=#
#Color codes
CL='\033[0;32m'
CL2='\033[1;36m'
CL3='\033[0m'
NC='\033[1;37m'
set -e #exit if error
echo ${CL2}[grub-install.sh]${NC} Mouting image... \(losetup\)${CL3}
## Prepare Mount
sudo losetup -D > /dev/null
sudo losetup /dev/loop0 $1 > /dev/null # mounting the device block
sudo losetup /dev/loop1 $1 -o 1048576 > /dev/null #mounting the logical partition
echo ${CL2}[grub-install.sh]${NC} Mounting volume... \(mount\)${CL3}
## Mount
if [ -e $2/boot ] 
then
sudo umount $2 > /dev/null
fi
sudo mount /dev/loop1 $2 > /dev/null
echo ${CL2}[grub-install.sh]${NC} Installing grub... \(grub-install\)${CL3}
## Install grub
sudo grub-install -V
sudo grub-install --target=i386-pc --debug --root-directory=$2 --boot-directory=$2/boot --no-floppy --modules="part_msdos biosdisk fat multiboot configfile" /dev/loop0 2> build/grub.log
echo ${CL2}[grub-install.sh]${NC} Copying grub.cfg
sudo cp $3 $2/boot/grub/grub.cfg > /dev/null
echo ${CL2}[grub-install.sh]${NC} Sync image... \(sync\)${CL3}
sync
echo ${CL2}[grub-install.sh]${NC} Unmounting volume... \(umount\)${CL3}
sudo umount /dev/loop1 > /dev/null
echo ${CL2}[grub-install.sh]${NC} Unmounting image... \(losetup\)${CL3}
sudo losetup -D > /dev/null
2019-03-16 22:33:09 +01:00
echo ${CL2}[grub-install.sh]${CL} See grub.log for more informations.${CL3}