-
Notifications
You must be signed in to change notification settings - Fork 0
/
anal-installer-installToDisk:bootPartition:systemPartition:.sh
executable file
·151 lines (132 loc) · 4.82 KB
/
anal-installer-installToDisk:bootPartition:systemPartition:.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
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
#!/bin/bash
if [ "x$1" = "x" ]; then
echo "Specify install disk device, boot partition, and system partition"
exit 1
fi
DISKDEVICE="$1"
if [ "x$2" = "x" ]; then
echo "Specify install disk device, boot partition, and system partition"
exit 1
fi
BOOTDEVICE="$2"
if [ "x$3" = "x" ]; then
echo "Specify install disk device, boot partition, and system partition"
exit 1
fi
SYSTEMDEVICE="$3"
# check if /mntsystem is a directory
if ! [ -d /mntsystem ]; then
echo "Error, /mntsystem either does not exist or is not a directory"
exit 1
fi
# check if /mntbootloader is a directory
if ! [ -d /mntbootloader ]; then
echo "Error, /mntbootloader either does not exist or is not a directory"
exit 1
fi
# check if SYSTEMDEVICE is mounted or not, must be unmounted
if findmnt "$SYSTEMDEVICE" >/dev/null; then
echo "Error, $SYSTEMDEVICE is already mounted"
exit 1
fi
# check if /mntsystem is mounted or not, must be unmounted
if findmnt /mntsystem >/dev/null; then
echo "Error, /mntsystem is already mounted"
exit 1
fi
# Let the user format the partition
#mkfs "$ROOTDEVICE"
UUID=$(blkid -s UUID -o value "$SYSTEMDEVICE")
if [ "x$UUID" = "x" ]; then
echo "Unable to get UUID for system device $SYSTEMDEVICE (perhaps needs to be formatted)"
exit 1
fi
if [ "x$BOOTDEVICE" = "x$SYSTEMDEVICE" ]; then
echo "Error, boot device $BOOTDEVICE and system device $SYSTEMDEVICE are the same"
exit 1
fi
# check if BOOTDEVICE is mounted or not, must be unmounted
if findmnt "$BOOTDEVICE" >/dev/null; then
echo "Error, boot device $BOOTDEVICE is already mounted"
exit 1
fi
# check if /mntbootloader is mounted or not, must be unmounted
if findmnt /mntbootloader >/dev/null; then
echo "Error, /mntbootloader is already mounted"
exit 1
fi
# check if partition is vfat
if ! blkid -s TYPE -o value "$BOOTDEVICE" | grep '^vfat$' >/dev/null ; then
echo "Error, boot partition $BOOTDEVICE is not formatted as vfat"
exit 1
fi
BOOTUUID=$(blkid -s UUID -o value "$BOOTDEVICE")
if [ "x$BOOTUUID" = "x" ]; then
echo "Unable to get UUID for boot partition $BOOTDEVICE (perhaps needs to be formatted)"
exit 1
fi
if ! mount "$BOOTDEVICE" /mntbootloader ; then
echo "Error, unable to mount boot partition $BOOTDEVICE (perhaps needs to be formatted)"
exit 1
fi
umount /mntbootloader
SUCCESS=0
if fdisk -l "$DISKDEVICE" | grep '^Disklabel type: dos' >/dev/null ; then
if ! fdisk -l "$DISKDEVICE" | grep "^$BOOTDEVICE *\*" >/dev/null ; then
echo "Error, boot partition $BOOTDEVICE is not bootable"
exit 1
fi
if ! PATH="/root:$PATH" dialog --yes-label "Install" --no-label "Cancel" --defaultno --yesno "Install ANaL?\n\nDisk: $DISKDEVICE\nBoot Partition: $BOOTDEVICE\nSystem Partition: $SYSTEMDEVICE" 12 64 ; then
echo "Installation cancelled"
exit 1
fi
if ! mount "$SYSTEMDEVICE" /mntsystem ; then
echo "Error, unable to mount system partition $SYSTEMDEVICE (perhaps needs to be formatted)"
exit 1
fi
PATH="/root:$PATH" anal-installer-installSystem.sh | PATH="/root:$PATH" dialog --backtitle "Linux Setup" --programbox 'INSTALLING SYSTEM' 8 80
RESULT=${PIPESTATUS[0]}
if [ $RESULT -eq 0 ]; then
PATH="/root:$PATH" anal-installer-configureSystem.sh
PATH="/root:$PATH" anal-installer-installMBRBootloaderToDisk:partition:UUID:.sh "$DISKDEVICE" "$BOOTDEVICE" "$UUID"
SUCCESS=1
fi
umount /mntsystem
sync
elif fdisk -l "$DISKDEVICE" | grep '^Disklabel type: gpt' >/dev/null ; then
if ! fdisk -l "$DISKDEVICE" | grep "^$BOOTDEVICE" | grep ' EFI System$' >/dev/null ; then
echo "Error, boot partition $BOOTDEVICE is not EFI System (ef00)"
exit 1
fi
if ! PATH="/root:$PATH" dialog --yes-label "Install" --no-label "Cancel" --defaultno --yesno "Install ANaL?\n\nDisk: $DISKDEVICE\nBoot Partition: $BOOTDEVICE\nSystem Partition: $SYSTEMDEVICE" 12 64 ; then
echo "Installation cancelled"
exit 1
fi
if ! mount "$SYSTEMDEVICE" /mntsystem ; then
echo "Error, unable to mount system partition $SYSTEMDEVICE (perhaps needs to be formatted)"
exit 1
fi
PATH="/root:$PATH" anal-installer-installSystem.sh | PATH="/root:$PATH" dialog --backtitle "Linux Setup" --programbox 'INSTALLING SYSTEM' 8 80
RESULT=${PIPESTATUS[0]}
if [ $RESULT -eq 0 ]; then
PATH="/root:$PATH" anal-installer-configureSystem.sh
PATH="/root:$PATH" anal-installer-installEFIBootloaderToPartition:UUID:.sh "$BOOTDEVICE" "$UUID"
SUCCESS=1
fi
umount /mntsystem
sync
else
echo "Error, disk $DISKDEVICE should be either MBR or GPT"
exit 1
fi
if [ $SUCCESS -eq 1 ]; then
echo "System installation and configuration is complete."
echo
echo "You may now reboot your system."
exit 0
else
echo "Installation failed."
echo
echo "Better luck next time."
exit 1
fi