1
- #! /bin/sh
1
+ #! /bin/zsh
2
+
3
+ select_disk ()
4
+ {
5
+ disks=()
6
+ for device in $( lsblk -prndo NAME) ; do
7
+ disk_size=$( lsblk -prndo SIZE $device )
8
+ disks+=($device $disk_size )
9
+ done
10
+ local disk
11
+ local result
12
+ disk=$( dialog --title " Disc selection" --stdout --menu " Select a disk from the list to install ArchLinux" 16 32 1 ${disks[@]} )
13
+ result=$?
14
+ echo $disk
15
+ return $result
16
+ }
17
+
18
+ set_user_pswd ()
19
+ {
20
+ local pswd
21
+ local result
22
+ local warning
23
+ locale confirm_pswd
24
+ while : ; do
25
+ pswd=$( dialog --title " Setting a password for the user " $1 --stdout --insecure --passwordbox " ${warning} enter password" 16 48)
26
+ result=$?
27
+ [ $result -eq 1 ] && exit $result
28
+ [ ! -z $pswd ] && break
29
+ warning=" Empty Password!\n"
30
+ done
31
+ warning=" "
32
+ while : ; do
33
+ confirm_pswd=$( dialog --title " Setting a password for the user " $1 --stdout --insecure --passwordbox " ${warning} Confirm the password" 16 48)
34
+ result=$?
35
+ [ $result -eq 1 ] && exit $result
36
+ [ $confirm_pswd = $pswd ] && break
37
+ warning=" Passwords Do No Match!\n"
38
+ done
39
+ echo $pswd
40
+ return $result
41
+ }
42
+
43
+ set_user_name ()
44
+ {
45
+ local user_name
46
+ local result
47
+ local warning
48
+ while : ; do
49
+ user_name=$( dialog --title " Creating a user" --stdout --inputbox " ${warning} Enter your new username" 16 48)
50
+ result=$?
51
+ [ $result -eq 1 ] && exit $result
52
+ [[ $user_name =~ ^[A-Za-z]\W * ]] && break
53
+ warning=" Empty or incorrect username!\n"
54
+ # break
55
+ done
56
+ echo $user_name
57
+ return $result
58
+ }
2
59
3
60
clear
61
+ pacman -Sy dialog --noconfirm
62
+ if [ $? -ne 0 ]; then
63
+ echo -e " package \" dialog\" is not installed" ; exit
64
+ fi
65
+ [ -n " $( mount | grep /mnt) " ] && umount -R /mnt
66
+ dialog --title ArchInstall --ok-label " go" --msgbox \
67
+ " This is the Arch Linux installation script.\nNext, enter all the data necessary for installation.\nThe Cancel button aborts the script" 16 48
4
68
5
- disk=" /dev/sda "
6
- root_pswd=" 0000 "
7
- user_name=" user "
8
- user_pswd=" 1111 "
69
+ disk=$( select_disk ) ; [ $? -eq 1 ] && exit
70
+ root_pswd=$( set_user_pswd " root " ) ; [ $? -eq 1 ] && exit
71
+ user_name=$( set_user_name ) ; [ $? -eq 1 ] && exit
72
+ user_pswd=$( set_user_pswd " $user_name " ) ; [ $? -eq 1 ] && exit
9
73
10
- wipefs -a $disk
11
- parted $disk mklabel gpt mkpart EFI 1049kB 106MB set 1 boot on mkpart ArchLinux 106MB 100%
12
- mkfs.vfat -n EFI $disk " 1"
13
- mkfs.btrfs -f -L ArchLinux $disk " 2"
74
+ clear
75
+ disk_s=${disk// \/ / \\\/ }
76
+ part_efi=$( lsblk -prno NAME | sed -n " /$disk_s \w\w*/p" | sed -n 1p)
77
+ part_root=$( lsblk -prno NAME | sed -n " /$disk_s \w\w*/p" | sed -n 2p)
78
+ echo -e " g\nn\n\n\n+300M\nn\n\n\n\nw" | fdisk -w always -W always $disk
79
+ mkfs.vfat -n EFI $part_efi
80
+ mkfs.btrfs -f -L ArchLinux $part_root
14
81
15
- mount $disk " 2 " /mnt
82
+ mount $part_root /mnt
16
83
btrfs subvolume create /mnt/@
17
84
btrfs subvolume create /mnt/@home
18
85
umount /mnt
19
86
20
- mount -o noatime,compress=zstd:3,discard=async ,subvol=@ $disk " 2 " /mnt
21
- mount --mkdir -o noatime $disk " 1 " /mnt/boot/efi
22
- mount --mkdir -o noatime,compress=zstd:3,discard,subvol=@home $disk " 2 " /mnt/home
87
+ mount -o noatime,compress=zstd:3,discard,subvol=@ $part_root /mnt
88
+ mount --mkdir -o noatime $part_efi /mnt/boot/efi
89
+ mount --mkdir -o noatime,compress=zstd:3,discard,subvol=@home $part_root /mnt/home
23
90
24
- pacstrap /mnt base linux linux-firmware btrfs-progs intel-ucode nano grub networkmanager sudo htop neofetch
91
+ pacstrap /mnt base linux linux-firmware btrfs-progs intel-ucode grub networkmanager sudo nano htop neofetch
25
92
# efibootmgr
26
93
27
94
genfstab -U /mnt | sed " s/subvolid=[[:digit:]]\+,//" > /mnt/etc/fstab
@@ -44,5 +111,5 @@ arch-chroot /mnt locale-gen
44
111
echo " LANG=ru_RU.UTF-8" > /mnt/etc/locale.conf
45
112
echo " FONT=cyr-sun16" > /mnt/etc/vconsole.conf
46
113
47
- echo -e " \n\n=======Installation completed!======= "
48
-
114
+ umount -R /mnt
115
+ dialog --infobox ' Installation completed! ' 4 32
0 commit comments