-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoCleanInstall
More file actions
executable file
·243 lines (186 loc) · 11.3 KB
/
autoCleanInstall
File metadata and controls
executable file
·243 lines (186 loc) · 11.3 KB
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env bash
#########################################################################################################################################################################################
## A U T O L I N U X B O O T S T R A P S C R I P T ##
#########################################################################################################################################################################################
# _ _ _ __ _ _ #
# /.\ _ _ FJ_ ____ FJ / J _ _ _ _ _ FJ LJ #
# //_\\ J | | LJ _| F __ J J | LFJ J ' \ J J | | L J \/ F #
# / ___ \ | | | || |-' | |--| | | | J L | |\\ | | | | | / \ #
# / L___J \ F L__J JF |__-.F L__J J F L_____ J L F L \ JJ F L__J J / /\ \ #
# J__L J__J\____,__\_____J\______/J________LJ__LJ__L \\J__LJ\____,__LJ__//\\__L #
# |__L J__|J____,__J_____FJ______F|________||__||__L J__| J____,__F|__/ \__| #
#########################################################################################################################################################################################
#########################################################################################################################################################################################
trap 'lastCommand=$currentCommand; currentCommand=$BASH_COMMAND' DEBUG
trap 'echo $lastCommand' EXIT QUIT STOP ERR
drives(){
## If you would like to include any additional drives or partitions
## in the file system table, please use the 'mkmnt' command, followed
## by a name for the folder in which you would like it to be mounted,
## followed by the name of partition ( NOT THE FULL PATH ). The 3 words
## should be seperated by a single space in between them.
## For example: ' mkmnt newFolderName partition/driveName '
## : ' mkmnt myFolder sda1 '
# mkmnt
# mkmnt
# mkmnt
## If you have any extra swap partitions you would like to turn on,
## insert them below, following '/dev/' for every line below..
# swapon /dev/
# swapon /dev/
# swapon /dev/
genfstab -U /mnt > /mnt/etc/fstab ; }
#########################################################################################################################################################################################
lines(){ cat $1|wc -l; }
selectParts(){ selBoot ; selSwap ; selRootFS ; }
err(){ echo >&2 "$(tput bold; tput setaf 1)[-] ERROR: ${*}$(tput sgr0)";exit 1; }
dsks=$(mktemp) ; selDsk=$(mktemp)
selPar=$(mktemp) ; selPart=$(mktemp)
selSwap=$(mktemp) ; selBoot=$(mktemp)
selRootFS=$(mktemp) ; selSwap=$(mktemp)
wholeDisk=$(mktemp) ; confirm=$(mktemp)
partitions=$(mktemp) ; chRootDir=$(mktemp)
srcdir=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd && echo)
warn(){ echo >&2 "$(tput bold; tput setaf 1)[!] WARNING: ${*}$(tput sgr0)"; }
check_root(){ [ "$(id -u)" -ne 0 ] && err "root priviledges are required to run this script."; }
mkmnt(){ $(sudo mkdir -p /mnt/home/drives/"$1" >/dev/null 2>&1 && $(mount /dev/"$2" /mnt/home/drives/"$1") >/dev/null 2>&1) ; }
fail(){ err " ERROR! CATASTROPHIC FAILIURE CAPTAIN . . ." ; sleep 2 ; }
requierments(){ pacman -Syy figlet lolcat parted sudo --needed --noconfirm 2>/dev/null && setfont ter-p16n >/dev/null 2>&1 ; }
welcome(){ clear ; figlet -toc '|-WELCOME-| - TO - |-AUTOLINUX-|' | lolcat ; sleep 1; }
refreshkeys() { \
pacman -U --noconfirm https://gitlab.com/a4to/concise/-/raw/master/concise-keyring-1.0.3-1-any.pkg.tar.xz >/dev/null 2>&1
/opt/Concise/init.sh >/dev/null 2>&1 ; }
init(){
pacConf /etc/pacman.conf &&
timedatectl set-ntp true ; }
pacConf(){ \
dialog --infobox "Updating Repos and Keys..." 4 40
for repo in core extra community multilib; do
grep -q "^\[$repo\]" /etc/pacman.conf || echo "[$repo]
Include = /etc/pacman.d/mirrorlist
" >> $1 ; done ; }
selDisk(){ \
dialog --stdout --colors --title "Partitioning" \
--menu " Which drive will be used for the AutoLinux installation?" 30 65 0 \
"${drives[@]}" > $selDsk
}
selBoot(){ \
dialog --stdout --no-cancel --colors --title "Partitioning" \
--menu " Which Partition will be used for the bootloader?" 30 65 0 \
"${parts[@]}" > $selBoot
}
selSwap(){ \
dialog --stdout --colors --title "Partitioning" \
--ok-label "Continue" \
--cancel-label "No Swap" \
--menu " Which Partition will be used for the swap?" 30 65 0 \
"${parts[@]}" > $selSwap
}
selRootFS(){ \
dialog --stdout --no-cancel --colors --title "Partitioning" \
--menu " Which Partition will be used for the root filesystem?" 30 65 0 \
"${parts[@]}" > $selRootFS
}
wholeDisk(){ \
dialog --stdout --colors --extra-button \
--title "Partitioning" \
--extra-label "WIPE DISK" \
--yes-label 'Select Partitions' \
--no-label 'Go Back' \
--yesno "Would you like to wipe the entire drive, or manually select partitions?" 6 80 ;
echo $? > $wholeDisk
}
allDisks(){ \
sudo fdisk -l|grep -B 1 "Disk model:"|sed 's/,.*sectors//g;s/://g;s/Disk\s*\///g;s/Disk model //g'|xargs|sed \
's/ -- /\n/g;s/dev/"\/dev/g;s/\n/"\n/g;s/^/drives=(\n/g;s/$/"\n)/g'|sed 's/ /" "/;s/iB /iB /' >$dsks ; source $dsks ; }
getDisk(){ \
eval $(sudo fdisk -lo Device,Size,Type|grep $(cat $selDsk) >$selPar ; n=1 ; echo "parts=(" >$selPart
cat $selPar|while read x; do echo "$(sudo head -n $n $selPar|tail -n1|cut -d' ' -f1|sed "s/^/'/;s/$/'/")\
$(echo $x|cut -d' ' -f2-|sed "s/^/\t\'/;s/$/\'/")"|sed '/Disk.*bytes,.*sectors/d'; ((n++)) ; done >>$selPart &&
echo -e ")" >>$selPart) ; source $selPart ; }
confirm(){ \
dialog --stdout --colors --title "Partitioning" \
--yes-label 'NO. Go Back' \
--no-label 'YES. Continue' \
--yesno "\\nAre you sure you want to completely wipe $(cat $selDsk)?\\n\\nThis action CANNOT be undone." 9 90 ;
WIPE=$? ; }
wipeDisk(){ \
PRTED="sudo parted -s $(cat $selDsk)"
sudo wipefs $(cat $selDsk)
dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)1 - the legacy boot partition, Pease be patient..." 3 80 ;
$PRTED mklabel gpt >/dev/null 2>&1
$PRTED mkpart primary 1 3 >/dev/null 2>&1
$PRTED name 1 legacy >/dev/null 2>&1
$PRTED set 1 bios_grub on
dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)2 - the uefi boot partition, Pease be patient..." 3 80 ;
$PRTED mkpart primary fat32 3MiB 256MiB >/dev/null 2>&1
$PRTED name 2 boot >/dev/null 2>&1
$PRTED set 2 boot on
yes|sudo mkfs.fat -F32 $(cat $selDsk)2 >/dev/null 2>&1
dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)3 - the swap partition, Pease be patient..." 3 80 ;
$PRTED mkpart primary 256MiB 4352MiB >/dev/null 2>&1
$PRTED name 3 swap >/dev/null 2>&1
$PRTED set 3 swap on
yes|sudo mkswap $(cat $selDsk)3 >/dev/null 2>&1 ;
sudo swapon $(cat $selDsk)3 >/dev/null 2>&1
dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)4 - the root filesystem, Pease be patient..." 3 80 ;
$PRTED mkpart primary ext4 4352MiB 100% >/dev/null 2>&1
$PRTED name 4 rootfs >/dev/null 2>&1
yes|sudo mkfs.ext4 $(cat $selDsk)4 >/dev/null 2>&1 ; }
definedPartitioning(){ \
dialog --colors --title "Partitioning" --infobox "Preparing the $(cat $selBoot) - the boot partition, Pease be patient..." 3 80 ;
yes|sudo mkfs.fat -F32 $(cat $selBoot) >/dev/null 2>&1
[ -n "$(cat $selSwap)" ] && dialog --colors --title "Partitioning" --infobox "Preparing the $(cat $selSwap) - the swap partition, Pease be patient..." 3 80 ;
[ -n "$(cat $selSwap)" ] && yes|sudo mkswap $(cat $selSwap) >/dev/null 2>&1
dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selRootFS) - the root filesystem, Pease be patient..." 3 80 ;
yes|sudo mkfs.ext4 $(cat $selRootFS) >/dev/null 2>&1
[ -n "$(cat $selSwap)" ] && sudo swapon $(cat $selSwap) >/dev/null 2>&1
}
definedConfirm(){ \
dialog --colors --title "Partitioning" \
--yes-label "Wait, Go Back" \
--no-label "Im Sure" \
--yesno "\\nAre you happy with your selection?\\n\\n1. Boot Partition: $(cat $selBoot)\\n2. Swap Partition: $(cat $selSwap)\\n3. Root File System: $(cat $selRootFS)\\n\\nOnce you have confirmed, there in no going back." 14 80 ;
defConf=$? ; }
completion(){ dialog --colors --title " ~ AutoLinux ~ " \
--infobox "Partitioning Completed Successfully! Now continuing to install base system..." 5 85 ; }
begin(){ \
n=1 ; selDisk || err "User Exited."
getDisk || err "User Exited."
wholeDisk || err "User Exited."
case "$(cat $wholeDisk)" in
1) getDisk && begin ;;
0) selectParts ; definedConfirm && [ $defConf -eq 0 ] && begin ||
[ $defConf -eq 1 ] && definedPartitioning && wipeType='manual' ;;
3) confirm && case "$(echo $WIPE)" in
'0') begin ;;
'1') wipeDisk && wipeType='automatic'; mount $(cat $selDsk)4 /mnt ;;
esac ;; esac ; }
base_install(){ \
for x in linux-firmware base base-devel; do
dialog --colors --title " ~ AutoLinux ~ " --infobox "Installing $x, part of the fundaemental system packages..." 3 80 ;
pacstrap /mnt $x --needed --noconfirm >/dev/null 2>&1 &&
pacConf /mnt/etc/pacman.conf >/dev/null 2>&1 ; done ; }
post_install(){ \
for x in efibootmgr dosfstools mtools pacman-contrib os-prober; do
dialog --colors --title " ~ AutoLinux ~ " --infobox "Installing $x, needed for the installation..." 3 80 ;
pacstrap /mnt $x --needed --noconfirm >/dev/null 2>&1 ; clear ; done ; }
cp_scripts(){ cd $srcdir && mkdir -p /mnt/tmp/AUTO && cp autoInstall /mnt/tmp/AUTO >/dev/null 2>&1 ; }
success(){ \
figlet -toc 'Success!'|lolcat ; echo -e "\n" ; sleep 2
}
check_root ; requierments ; welcome ; init
allDisks || err "Could not find any disks."
begin
case "$wipeType" in
'manual') sudo mount $(cat $selRootFS) /mnt && completion && sleep 3 ||
! [ -d /mnt/boot/EFI ] && mkdir -p /mnt/boot/EFI; sudo mount $(cat $selBoot) /mnt/boot/EFI ;;
'automatic') sudo mount $(cat $selDsk)4 /mnt && completion && sleep 3 ||
! [ -d /mnt/boot/EFI ] && mkdir -p /mnt/boot/EFI; sudo mount $(cat $selDsk)2 /mnt/boot/EFI ;;
esac
base_install || err "User Exited."
drives || err "User Exited."
post_install || err "User Exited."
cp_scripts && success && arch-chroot /mnt bash /tmp/AUTO/autoInstall && exit 0 || fail && exit 1
#########################################################################################################################################################################################
#########################################################################################################################################################################################