-
Notifications
You must be signed in to change notification settings - Fork 0
/
UEFI-rebooter.sh
51 lines (40 loc) · 889 Bytes
/
UEFI-rebooter.sh
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
#!/bin/bash
# Setup default cofinuration values
# first parameter - lable of record
#
# --setfirst - set first in boot order
#
# --bootnext - set BootNext
if [ "$#" -lt "1" ]; then
echo "$0: few arguments"
return
fi
#$1 - lable of boot record
LABLE=$1 #"Windows Boot Manager"
# Get LABLE boot number.
NUMBER=$(efibootmgr | sed "/Boot[0-9].*$LABLE/!d;s/Boot//;s/\*.*//")
#check select number
if [ -z "$NUMBER" ]; then
echo "$0: $LABLE - no such lable in boot list."
return
fi
#set first in boot order
set_first()
{
# Make new boot order with LABLE in top.
OPT=$NUMBER,$(efibootmgr | sed "/BootOrder:/!d;s/BootOrder: //;s/\*.*//;s/.$NUMBER//")
# Add new boot options.
efibootmgr --bootorder $OPT
}
#will be reboot at once
bootnext()
{
efibootmgr --bootnext $NUMBER
}
if [ "$2" = "--bootnext" ]; then
bootnext
else
set_first
fi
#reboot system
reboot