auto


Logs | Files | README | README | GitLab


1
commit be892c960d21832afb7e66409590c059b94710cb
2
Author: nvx1 <[email protected]>
3
Date:   Thu Mar 31 08:42:08 2022 +0200
4
5
    Update.
6
---
7
 Auto-PreInstall | 235 ++++++++++++++++++++++++++++++++++++++++----------------
8
 AutoPart        |  36 +++++----
9
 PKGBUILD        |   4 +-
10
 3 files changed, 192 insertions(+), 83 deletions(-)
11
12
diff --git a/Auto-PreInstall b/Auto-PreInstall
13
index 6eb2347..9d64386 100755
14
--- a/Auto-PreInstall
15
+++ b/Auto-PreInstall
16
@@ -41,11 +41,20 @@ genfstab -U /mnt > /mnt/etc/fstab ; }
17
 
18
 #########################################################################################################################################################################################
19
 
20
-srcdir=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd && echo)
21
+lines(){ cat $1|wc -l; }
22
+
23
+selectParts(){ selBoot ; selSwap ; selRootFS ; }
24
 
25
-msg(){ echo "$(tput bold; tput setaf 2)[+] ${*}$(tput sgr0)"; }
26
+err(){ echo >&2 "$(tput bold; tput setaf 1)[-] ERROR: ${*}$(tput sgr0)";exit 1; }
27
 
28
-err(){ echo >&2 "$(tput bold; tput setaf 1)[-] ERROR: ${*}$(tput sgr0)" && exit 1 ; }
29
+dsks=$(mktemp)        ; selDsk=$(mktemp)
30
+selPar=$(mktemp)      ; selPart=$(mktemp)
31
+selSwap=$(mktemp)     ; selBoot=$(mktemp)
32
+selRootFS=$(mktemp)   ; selSwap=$(mktemp)
33
+wholeDisk=$(mktemp)   ; confirm=$(mktemp)
34
+partitions=$(mktemp)
35
+
36
+srcdir=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd && echo)
37
 
38
 warn(){ echo >&2 "$(tput bold; tput setaf 1)[!] WARNING: ${*}$(tput sgr0)"; }
39
 
40
@@ -55,85 +64,179 @@ mkmnt(){ $(sudo mkdir -p /mnt/home/drives/"$1" >/dev/null 2>&1 && $(mount /dev/"
41
 
42
 fail(){ err "   ERROR! CATASTROPHIC FAILIURE CAPTAIN . . ." ; sleep 2 ; }
43
 
44
-requierments(){ pacman -Syy  figlet lolcat terminus-font sudo   --needed --noconfirm 2>/dev/null && setfont ter-p16n; }
45
+requierments(){ pacman -Syy  figlet lolcat parted sudo   --needed --noconfirm 2>/dev/null && setfont ter-p16n >/dev/null 2>&1 ; }
46
 
47
-welcome(){ clear ; figlet -toc '|-WELCOME-| - TO - |-AUTOLINUX-|' | lolcat ; sleep 1;
48
-    echo -e "\n\n  Please use 'cfdisk' (recommended) or 'fdisk' to partition your drive before running this script.\n  Generally, a 550M EFI partition, a 2-10G swap partition,  and the rest of space dedicated to linux filesystem.\n" ; sleep 5 ; }
49
+welcome(){ clear ; figlet -toc '|-WELCOME-| - TO - |-AUTOLINUX-|' | lolcat ; sleep 1; }
50
 
51
 
52
-pac_conf(){
53
-echo -e "\n# GENERAL OPTIONS\n\n[options]\n\n#RootDir     = /\n#DBPath      = /var/lib/pacman/\n#CacheDir    = /var/cache/pacman/pkg/
54
-#LogFile     = /var/log/pacman.log\n#GPGDir      = /etc/pacman.d/gnupg/\n#HookDir     = /etc/pacman.d/hooks/\nHoldPkg      = pacman glibc
55
-#XferCommand = /usr/bin/curl -L -C - -f -o %o %u\n#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u\n#CleanMethod = KeepInstalled
56
-Architecture = auto\n\n#UseSyslog\nColor\nCheckSpace\nVerbosePkgLists\nILoveCandy\nParallelDownloads = 10\n\n\nSigLevel    = Required DatabaseOptional
57
-LocalFileSigLevel = Optional\n#RemoteFileSigLevel = Required\n\n\n[core]\nInclude = /etc/pacman.d/mirrorlist\n\n[extra]\nInclude = /etc/pacman.d/mirrorlist\n
58
-[community]\nInclude = /etc/pacman.d/mirrorlist\n\n[multilib]\nInclude = /etc/pacman.d/mirrorlist"; } 
59
-
60
 refreshkeys() { \
61
   pacman -U --noconfirm https://gitlab.com/qyp/concise/-/raw/master/concise-keyring-1.0.3-1-any.pkg.tar.xz
62
   /opt/Concise/init.sh ; }
63
 
64
 init(){  
65
-pac_conf > /etc/pacman.conf &&
66
+pacConf /etc/pacman.conf &&
67
 timedatectl set-ntp true ; }
68
 
69
-partitioning(){ 
70
-setfont ter-p16n &&
71
-
72
-echo  -e "\n    Please specify the boot partition:"                                  
73
-read -p "    ( Only the partition name, NOT the full path. )   : /dev/" boot 
74
-case "$boot" in 
75
-	''n) mkfs.vfat /dev/nvme0n1p1 ;;
76
-      s) mkfs.vfat /dev/sda4 ;;
77
-  	  *) mkfs.vfat /dev/"$boot"  
78
-esac 
79
-echo -e "\n    Please specify a swap partition if wanted,"                                  
80
-read -p "    ( Only the partition name, NOT the full path. )  :  /dev/" swap 
81
-case "$swap" in 
82
-	''n)
83
-	mkswap /dev/nvme0n1p2 && swapon /dev/nvme0n1p2 ;;
84
-      s) mkswap /dev/sda3 && swapon /dev/sda3 ;; 
85
-     "") ;; *) mkswap /dev/"$swap" && swapon /dev/"$swap" 
86
-esac
87
-echo -e "\n    Please specify partition name where base system will be installed. "                                 
88
-read -p "    ( Only the partition name, NOT the full path. )   :  /dev/" drive 
89
-case "$drive" in
90
-	''n) mkfs.ext4 /dev/nvme0n1p3 && mount /dev/nvme0n1p3 /mnt ;;
91
-      s) mkfs.ext4 /dev/sda5 && mount /dev/sda5 /mnt ;;
92
-	  *) mkfs.ext4 /dev/"$drive" && mount /dev/"$drive" /mnt 
93
-esac  
94
-
95
-[ ! -d /mnt/boot/EFI ] && mkdir -p /mnt/boot/EFI ;
96
-if [ $boot = n ]; then mount /dev/nvme0n1p1 /mnt/boot/EFI; fi
97
-if [ $boot = s ]; then mount /dev/sda4 /mnt/boot/EFI; fi
98
-mount /dev/$boot /mnt/boot/EFI 2>/dev/null ; clear ; setfont ter-p16n ;
99
-
100
-msg "  Partitioning Completed Successfully!"  || 
101
-err "Partitioning has failed miserably..." && sleep 2 && echo "" ; }
102
-
103
-base_install(){	msg "  Beginning base installation..." ; sleep 2 && setfont ter-p14n ;
104
-
105
-pacstrap /mnt \
106
-    linux-firmware base base-devel --needed --noconfirm &&
107
-    pac_conf > /mnt/etc/pacman.conf && clear && setfont ter-p16n && 
108
-    msg "  The Base Installation was a Success!" && sleep 2 || fail ; }
109
-
110
-post_install(){ echo "" ; msg "  Installing additional system requierments..."; sleep 2 && setfont ter-p14n ;
111
-
112
-pacstrap /mnt \
113
-  git curl zsh wget efibootmgr dosfstools \
114
-  mtools pacman-contrib fzf terminus-font os-prober  \
115
-  bash-completion --needed --noconfirm ; clear ; } 
116
+pacConf(){ \
117
+dialog --infobox "Updating Repos and Keys..." 4 40  
118
+for repo in core extra community multilib; do
119
+grep -q "^\[$repo\]" /etc/pacman.conf || echo "[$repo]
120
+Include = /etc/pacman.d/mirrorlist
121
+" >> $1 ; done ; }
122
+
123
+selDisk(){ \
124
+  dialog --stdout --colors  --title "Partitioning" \
125
+  --menu "       Which drive will be used for the AutoLinux installation?" 30 65 0 \
126
+  "${drives[@]}" > $selDsk
127
+}
128
+
129
+selBoot(){ \
130
+  dialog --stdout --no-cancel --colors  --title "Partitioning" \
131
+  --menu " Which Partition will be used for the bootloader?" 30 65 0 \
132
+  "${parts[@]}"  > $selBoot
133
+}
134
+
135
+selSwap(){ \
136
+  dialog --stdout --colors  --title "Partitioning" \
137
+  --ok-label "Continue" \
138
+  --cancel-label "No Swap" \
139
+  --menu " Which Partition will be used for the swap?" 30 65 0 \
140
+  "${parts[@]}" > $selSwap
141
+}
142
+
143
+selRootFS(){ \
144
+  dialog --stdout --no-cancel --colors  --title "Partitioning" \
145
+  --menu " Which Partition will be used for the root filesystem?" 30 65 0 \
146
+  "${parts[@]}" > $selRootFS
147
+}
148
+
149
+wholeDisk(){ \
150
+  dialog --stdout --colors --extra-button \
151
+  --title "Partitioning" \
152
+  --extra-label "WIPE DISK" \
153
+  --yes-label 'Select Partitions' \
154
+  --no-label 'Go Back' \
155
+  --yesno "Would you like to wipe the entire drive, or manually select partitions?" 6 80 ; 
156
+  echo $? > $wholeDisk
157
+}
158
+
159
+allDisks(){ \
160
+sudo fdisk -l|grep -B 1 "Disk model:"|sed 's/,.*sectors//g;s/://g;s/Disk\s*\///g;s/Disk model //g'|xargs|sed \
161
+'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 ; }
162
+
163
+getDisk(){ \
164
+eval $(sudo fdisk -lo Device,Size,Type|grep $(cat $selDsk) >$selPar ; n=1 ; echo "parts=(" >$selPart
165
+cat $selPar|while read x; do echo "$(sudo head -n $n $selPar|tail -n1|cut -d' ' -f1|sed "s/^/'/;s/$/'/")\
166
+$(echo $x|cut -d' ' -f2-|sed "s/^/\t\'/;s/$/\'/")"|sed '/Disk.*bytes,.*sectors/d'; ((n++)) ; done >>$selPart &&
167
+echo -e ")" >>$selPart) ; source $selPart ; }
168
+
169
+confirm(){ \
170
+  dialog --stdout --colors --title "Partitioning" \
171
+  --yes-label 'NO. Go Back' \
172
+  --no-label 'YES. Continue' \
173
+  --yesno "\\nAre you sure you want to completely wipe $(cat $selDsk)?\\n\\nThis action CANNOT be undone." 9 90 ;
174
+  WIPE=$? ; }
175
+
176
+wipeDisk(){ \
177
+  PRTED="sudo parted -s $(cat $selDsk)"
178
+  sudo wipefs $(cat $selDsk)
179
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)1 - the legacy boot partition, Pease be patient..." 3 80 ;
180
+  $PRTED mklabel gpt >/dev/null 2>&1
181
+  $PRTED mkpart primary 1 3 >/dev/null 2>&1
182
+  $PRTED name 1 legacy >/dev/null 2>&1
183
+  $PRTED set 1 bios_grub on
184
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)2 - the uefi boot partition, Pease be patient..." 3 80 ;
185
+  $PRTED mkpart primary fat32 3MiB 256MiB >/dev/null 2>&1
186
+  $PRTED name 2 boot >/dev/null 2>&1
187
+  $PRTED set 2 boot on
188
+  yes|sudo mkfs.fat -F32 $(cat $selDsk)2 >/dev/null 2>&1
189
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)3 - the swap partition, Pease be patient..." 3 80 ;
190
+  $PRTED mkpart primary 256MiB 4352MiB >/dev/null 2>&1
191
+  $PRTED name 3 swap >/dev/null 2>&1
192
+  $PRTED set 3 swap on
193
+  yes|sudo mkswap $(cat $selDsk)3 >/dev/null 2>&1 ;
194
+  sudo swapon $(cat $selDsk)3 >/dev/null 2>&1
195
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)4 - the root filesystem, Pease be patient..." 3 80 ;
196
+  $PRTED mkpart primary ext4 4352MiB 100% >/dev/null 2>&1
197
+  $PRTED name 4 rootfs >/dev/null 2>&1
198
+  yes|sudo mkfs.ext4 $(cat $selDsk)4 >/dev/null 2>&1 ; }
199
+
200
+definedPartitioning(){ \
201
+  dialog --colors --title "Partitioning" --infobox "Preparing the $(cat $selBoot) - the boot partition, Pease be patient..." 3 80 ;
202
+  yes|sudo mkfs.fat -F32 $(cat $selBoot) >/dev/null 2>&1
203
+  [ -n "$(cat $selSwap)" ] && dialog --colors --title "Partitioning" --infobox "Preparing the $(cat $selSwap) - the swap partition, Pease be patient..." 3 80 ;
204
+  [ -n "$(cat $selSwap)" ] && yes|sudo mkswap $(cat $selSwap) >/dev/null 2>&1
205
+  dialog --colors --title "Partitioning" --infobox "Preparing  $(cat $selRootFS) - the root filesystem, Pease be patient..." 3 80 ;
206
+  yes|sudo mkfs.ext4 $(cat $selRootFS) >/dev/null 2>&1
207
+  [ -n "$(cat $selSwap)" ] && sudo swapon $(cat $selSwap) >/dev/null 2>&1
208
+}
209
+
210
+definedConfirm(){ \
211
+  dialog --colors --title "Partitioning" \
212
+  --yes-label "Im Sure" \
213
+  --no-label "Wait, Go Back" \
214
+  --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 ;
215
+  defConf=$? ; }
216
+
217
+completion(){ dialog --colors --title " ~ AutoLinux ~ " \
218
+  --infobox "Partitioning Completed Successfully! Now continuing to install base system..." 5 85 ; }
219
+
220
+begin(){ \
221
+n=1 ; selDisk || err "User Exited."
222
+getDisk || err "User Exited."
223
+wholeDisk || err "User Exited."
224
+  
225
+case "$(cat $wholeDisk)" in
226
+  1) getDisk && begin ;;
227
+  0) selectParts && definedConfirm && definedPartitioning && wipeType='manual'  
228
+    mount $selRootFS /mnt && completion || err "User Exited.";;  
229
+  3) confirm && case "$(echo $WIPE)" in 
230
+    '0')  begin ;;
231
+    '1')  wipeDisk && completion && sleep 4 && wipeType='automatic'; mount $(cat $selDsk)4 /mnt
232
+  esac ;; 
233
+esac ; }
234
+
235
+base_install(){	\
236
+  for x in linux-firmware base base-devel; do
237
+    dialog --colors --title " ~ AutoLinux ~ " --infobox "Installing $x, the fundaemental system packages..." 3 60 ;
238
+    pacstrap /mnt $x --needed --noconfirm >/dev/null 2>&1 &&
239
+    pacConf /mnt/etc/pacman.conf >/dev/null 2>&1 ; done ; }
240
+
241
+post_install(){ \
242
+  for x in git curl zsh wget efibootmgr dosfstools mtools pacman-contrib fzf terminus-font os-prober bash-completion; do
243
+    dialog --colors --title " ~ AutoLinux ~ " --infobox "Installing $x, needed for the installation..." 3 60 ;
244
+    pacstrap /mnt $x --needed --noconfirm >/dev/null 2>&1 ; clear ; done ; }
245
 
246
 cp_scripts(){ cd $srcdir && cp AutoInstall /mnt/tmp/ ; cp AutoInstall  /mnt/usr/bin >/dev/null 2>&1 ; }
247
 
248
-success(){ clear ; setfont ter-p16n && echo -e "" &&
249
+success(){ \
250
 figlet -toc 'Success!'|lolcat ; echo -e "\n" ; sleep 2 && 
251
-arch-chroot /mnt /usr/bin/AutoInstall ; }
252
+arch-chroot /mnt /usr/bin/AutoInstall
253
+}
254
+
255
+
256
+check_root ; requierments ; welcome ; init 
257
+
258
+allDisks ||  err "Could not find any disks."
259
+
260
+begin || err "User Exited." 
261
+
262
+base_install || err "User Exited."
263
+
264
+drives || err "User Exited."
265
+
266
+post_install  || err "User Exited."
267
+
268
+
269
+! [ -d /mnt/boot/EFI ] && mkdir -p /mnt/boot/EFI
270
+
271
+case $wipeType in
272
+  'manual') mount $(cat $selDsk)4 /mnt ;;
273
+  'automatic') mount $(cat $selBoot) /mnt/boot ;;
274
+  *) err "User Exited." ;; esac
275
 
276
-check_root ; requierments ; welcome ; init ; 
277
-partitioning ; base_install && post_install ; drives ; 
278
 cp_scripts ; success && exit 0 || fail && exit 1
279
 
280
+
281
 #########################################################################################################################################################################################
282
 #########################################################################################################################################################################################
283
diff --git a/AutoPart b/AutoPart
284
index 6ddc078..a00f036 100755
285
--- a/AutoPart
286
+++ b/AutoPart
287
@@ -89,31 +89,36 @@ confirm(){ \
288
 
289
 wipeDisk(){ \
290
   PRTED="sudo parted -s $(cat $selDsk)"
291
-  dialog --colors --title "Partitioning" --infobox "Repartitioning $(cat $selDsk). Please be patient..." 3 60 ;
292
-  $PRTED wipefs >/dev/null 2>&1
293
+  sudo wipefs $(cat $selDsk)
294
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)1 - the legacy boot partition, Pease be patient..." 3 80 ;
295
   $PRTED mklabel gpt >/dev/null 2>&1
296
   $PRTED mkpart primary 1 3 >/dev/null 2>&1
297
   $PRTED name 1 legacy >/dev/null 2>&1
298
   $PRTED set 1 bios_grub on
299
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)2 - the uefi boot partition, Pease be patient..." 3 80 ;
300
   $PRTED mkpart primary fat32 3MiB 256MiB >/dev/null 2>&1
301
   $PRTED name 2 boot >/dev/null 2>&1
302
   $PRTED set 2 boot on
303
+  yes|sudo mkfs.fat -F32 $(cat $selDsk)2 >/dev/null 2>&1
304
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)3 - the swap partition, Pease be patient..." 3 80 ;
305
   $PRTED mkpart primary 256MiB 4352MiB >/dev/null 2>&1
306
   $PRTED name 3 swap >/dev/null 2>&1
307
   $PRTED set 3 swap on
308
+  yes|sudo mkswap $(cat $selDsk)3 >/dev/null 2>&1 ;
309
+  sudo swapon $(cat $selDsk)3 >/dev/null 2>&1
310
+  dialog --colors --title "Partitioning" --infobox "Preparing $(cat $selDsk)4 - the root filesystem, Pease be patient..." 3 80 ;
311
   $PRTED mkpart primary ext4 4352MiB 100% >/dev/null 2>&1
312
   $PRTED name 4 rootfs >/dev/null 2>&1
313
-  yes|sudo mkfs.fat -F32 $(cat $selDsk)2 >/dev/null 2>&1
314
-  yes|sudo mkswap $(cat $selDsk)3 >/dev/null 2>&1 ;
315
-  yes|sudo mkfs.ext4 $(cat $selDsk)4 >/dev/null 2>&1 ; 
316
-  sudo swapon $(cat $selDsk)3 >/dev/null 2>&1 ; }
317
+  yes|sudo mkfs.ext4 $(cat $selDsk)4 >/dev/null 2>&1 ; }
318
 
319
 definedPartitioning(){ \
320
-  dialog --colors --title "Partitioning" --infobox "Repartitioning $(cat $selDsk). Please be patient..." 3 60 ;
321
+  dialog --colors --title "Partitioning" --infobox "Preparing the $(cat $selBoot) - the boot partition, Pease be patient..." 3 80 ;
322
   yes|sudo mkfs.fat -F32 $(cat $selBoot) >/dev/null 2>&1
323
+  [ -n "$(cat $selSwap)" ] && dialog --colors --title "Partitioning" --infobox "Preparing the $(cat $selSwap) - the swap partition, Pease be patient..." 3 80 ;
324
   [ -n "$(cat $selSwap)" ] && yes|sudo mkswap $(cat $selSwap) >/dev/null 2>&1
325
+  dialog --colors --title "Partitioning" --infobox "Preparing  $(cat $selRootFS) - the root filesystem, Pease be patient..." 3 80 ;
326
   yes|sudo mkfs.ext4 $(cat $selRootFS) >/dev/null 2>&1
327
-  sudo swapon $(cat $selSwap) >/dev/null 2>&1
328
+  [ -n "$(cat $selSwap)" ] && sudo swapon $(cat $selSwap) >/dev/null 2>&1
329
 }
330
 
331
 definedConfirm(){ \
332
@@ -123,7 +128,8 @@ definedConfirm(){ \
333
   --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 ;
334
   defConf=$? ; }
335
 
336
-completion(){ dialog --colors --title "Partitioning" --infobox "Partitioning has Completed Successfully!" 3 60 ; }
337
+completion(){ dialog --colors --title " ~ AutoLinux ~ " \
338
+  --infobox "Partitioning Completed Successfully! Now continuing to install base system..." 5 85 ; }
339
 
340
 begin(){ \
341
 n=1 ; selDisk || err "User Exited."
342
@@ -132,12 +138,12 @@ wholeDisk || err "User Exited."
343
   
344
 case "$(cat $wholeDisk)" in
345
   1) getDisk && begin ;;
346
-  0) selectParts && definedConfirm && 
347
-    definedPartitioning && completion || err "User Exited." ;;
348
-  3) confirm &&  \
349
-    [ $WIPE -eq 0 ] && begin ;
350
-    [ $WIPE -eq 1 ] && wipeDisk && 
351
-      completion || err "User Exited." ;;
352
+  0) selectParts && definedConfirm && definedPartitioning && wipeType='manual'  
353
+    mount $selRootFS /mnt && completion || err "User Exited.";;  
354
+  3) confirm && case "$(echo $WIPE)" in 
355
+    '0')  begin ;;
356
+    '1')  wipeDisk && completion && sleep 4 && wipeType='automatic'; mount $(cat $selDsk)4 /mnt
357
+  esac ;; 
358
 esac ; }
359
 
360
 allDisks ||  err "Could not find any disks." ;
361
diff --git a/PKGBUILD b/PKGBUILD
362
index 66a1588..fac6f25 100644
363
--- a/PKGBUILD
364
+++ b/PKGBUILD
365
@@ -2,13 +2,13 @@
366
 # ---
367
 _pkgname=AutoLinux
368
 pkgname=auto
369
-pkgver=2.0.2
370
+pkgver=2.1.1
371
 pkgrel=1
372
 pkgdesc='AutoLinux bootstrap scripts, with optional riced configs for the AutoLinux platform'
373
 arch=(x86_64)
374
 url="https://gitlab.com/qYp/${_pkgname}"
375
 license=('MIT')
376
-depends=(dialog)
377
+depends=(dialog parted)
378
 makedepends=(git)                 
379
 source=("git+$url.git")
380
 sha256sums=('SKIP')