-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
249 lines (231 loc) · 7.08 KB
/
install
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
244
245
246
247
248
249
#!/usr/bin/env bash
set -e
trap 'exit' INT
### EXPORT ###
# DEFAULT SIZE SUGGESTION
export BOOTSZ='+512M' && export BOOTNO='1'
export ROOTSZ='+50G' && export ROOTNO='2'
export HOMESZ='0' && export HOMENO='3'
### FUNCTIONS ###
br() { for ((i = 1; i <= $(tput cols); i++)); do echo -n -; done; }
tablesize() {
br
echo "$D2E$BOOTNO BOOT = $BOOTSZ"
echo "$D2E$ROOTNO ROOT = $ROOTSZ"
echo "$D2E$HOMENO HOME = $HOMESZ"
br
}
#### STEPS ###
refreshdb() {
pacman -Syy
}
partition() {
lsblk && br
read -rp 'Which drive you want to partition (e.g: /dev/sda): ' D2E
br
echo -e '1. Create New or Edit old table\n2. Skip partitioning [Use old table]'
read -rp ': ' POPT
if [[ $POPT == '1' ]]; then
clear && echo 'Suggestion for table [0 = All left space]:'
tablesize
read -rp 'Want to edit [Y/N]: ' SGYN
if [[ $SGYN =~ ^([Yy][Ee][Ss]|[Yy])$ ]]; then
br
echo -e '0 = Use all free space\nG = Gb\nM = Mb\n* Enter for suggested'
br
echo "Enter size for BOOT | Suggested= $BOOTSZ"
read -re -i "$BOOTSZ" BOOTSZ
br
echo "Enter size for ROOT | Suggested= $ROOTSZ"
read -re -i "$ROOTSZ" ROOTSZ
br
echo "Enter size For HOME | Suggested= $HOMESZ"
read -re -i "$HOMESZ" HOMESZ
fi
clear
tablesize
lsblk
br
read -rep '[1 = Save table] [2 = Edit with cgdisk]: ' FSOK
if [[ $FSOK == '1' ]]; then
# Make table [num:start_block:size] [0=default start]
sgdisk -Z "$D2E"
sgdisk -a 2048 -o "$D2E"
sgdisk --align-end --new "$BOOTNO":0:"$BOOTSZ" --typecode "$BOOTNO":ef00 --change-name "$BOOTNO":"BOOT" "$D2E"
sgdisk --align-end --new "$ROOTNO":0:"$ROOTSZ" --typecode "$ROOTNO":8300 --change-name "$ROOTNO":"ROOT" "$D2E"
sgdisk --align-end --new "$HOMENO":0:"$HOMESZ" --typecode "$HOMENO":8300 --change-name "$HOMENO":"HOME" "$D2E"
elif [[ $FSOK == '2' ]]; then
clear
cgdisk "$D2E"
fi
# Write table
sgdisk -p "$D2E"
partprobe "$D2E"
elif [[ $POPT == '2' ]]; then
true
else
exit
fi
}
mounter() {
# Root
clear && lsblk && br
read -rp 'Which is your ROOT partition: ' ROOTP
read -rep 'Format ROOT [Y/N]: ' ROOTYN
if [[ $ROOTYN =~ ^([Yy][Ee][Ss]|[Yy])$ ]]; then
sleep 3
mkfs.ext4 "$ROOTP"
fi
mount --mkdir -o 'defaults,noatime' "$ROOTP" /mnt
# Boot
clear && lsblk && br
read -rp 'Which is your BOOT partition: ' BOOTP
read -rep 'Format BOOT [Y/N]: ' BOOTYN
if [[ $BOOTYN =~ ^([Yy][Ee][Ss]|[Yy])$ ]]; then
mkfs.fat -F32 "$BOOTP"
fi
mount --mkdir -o 'defaults,noatime,nosuid,nodev' "$BOOTP" /mnt/boot/efi
# Home
clear && lsblk && br
read -rp 'Do you want to mount seperate home partition [Y/N]: ' RESPH
if [[ $RESPH =~ ^([Yy][Ee][Ss]|[Yy])$ ]]; then
read -rp 'Which is your HOME partition: ' HOMEP
read -rp 'Format HOME [Y/N]: ' HOMEYN
if [[ $HOMEYN =~ ^([Yy][Ee][Ss]|[Yy])$ ]]; then
sleep 3
mkfs.ext4 "$HOMEP"
fi
mount --mkdir -o 'defaults,noatime,nosuid,nodev' "$HOMEP" /mnt/home
fi
}
base() {
# Base
pacstrap /mnt --needed base linux-lts linux-firmware intel-ucode
# Extra
pacstrap /mnt --needed xorg-server networkmanager bluez pipewire{,-alsa,-pulse,-jack} wireplumber \
grub efibootmgr sudo git nano
}
fstabgen() {
# Generate Fstab
genfstab -U /mnt >/mnt/etc/fstab
}
chroot() {
askvars() {
echo -e 'Use only small character without symbol\n'
read -rep 'Enter new Username: ' -i 'user' USERN
read -rep 'Enter new Hostname: ' -i 'host' HNAME
read -rep 'Enter new Timezone: ' -i 'Asia/Kolkata' TZONE
echo -e "\nUsername = $USERN\nHostname = $HNAME\nTimezone = $TZONE\n"
read -rep 'Is above data correct? [Y/N]: ' DATAYN
if [[ $DATAYN =~ ^([Yy][Ee][Ss]|[Yy])$ ]]; then true; else clear && askvars; fi
}
# Vars
askvars
# Timezone & Hwclock
arch-chroot /mnt bash -c "ln -sf /usr/share/zoneinfo/$TZONE /etc/localtime"
arch-chroot /mnt bash -c 'hwclock --systohc --utc'
# Localization
sed -i 's|#en_IN.UTF-8|en_IN.UTF-8|g' /mnt/etc/locale.gen
arch-chroot /mnt bash -c 'locale-gen'
echo -e 'LANG=en_IN.UTF-8\nLANGUAGE=en_IN\nLC_ALL=C' >/mnt/etc/locale.conf
# Network configuration
echo "$HNAME" >/mnt/etc/hostname
echo -e "127.0.0.1 $HNAME\n::1 $HNAME\n127.0.1.1 $HNAME.localdomain $HNAME" >/mnt/etc/hosts
# Sudo
arch-chroot /mnt bash -c 'if groups | grep sudo >/dev/null; then true; else groupadd sudo; fi'
sed -i 's/^#\s*\(%wheel\s\+ALL=(ALL:ALL)\s\+ALL\)/\1/' /mnt/etc/sudoers
# Root User
br && echo 'Enter powerfull password for Root'
arch-chroot /mnt bash -c 'until passwd || ((count++ >= 5)); do echo Try-Again; done'
# Normal User
br && echo "Enter powerfull password for new-user $USERN"
arch-chroot /mnt bash -c "useradd -mUG wheel,users,games,power,optical,storage,audio,video -s /bin/bash $USERN"
arch-chroot /mnt bash -c "until passwd $USERN || ((count++ >= 5)); do echo Try-Again; done"
# Bootloader
arch-chroot /mnt bash -c 'grub-install --target=x86_64-efi --efi-directory=/mnt/boot/efi --bootloader-id=Arch'
arch-chroot /mnt bash -c 'grub-mkconfig -o /boot/grub/grub.cfg'
# Services
arch-chroot /mnt bash -c 'systemctl enable --now NetworkManager'
}
deskenv() {
br && echo -e '1. GNOME\n2. DEEPIN\n3. KDE\n4. XFCE\n5. LXQT\n'
read -rp 'Choose a desktop env to install [1-5]: ' DESKTOPENV
if [[ $DESKTOPENV == '1' ]]; then
pacstrap /mnt --needed gnome
arch-chroot /mnt bash -c 'systemctl enable --now gdm'
elif [[ $DESKTOPENV == '2' ]]; then
pacstrap /mnt --needed deepin lightdm
arch-chroot /mnt bash -c 'systemctl enable --now lightdm'
elif [[ $DESKTOPENV == '3' ]]; then
pacstrap /mnt --needed plasma-desktop sddm
arch-chroot /mnt bash -c 'systemctl enable --now sddm'
elif [[ $DESKTOPENV == '4' ]]; then
pacstrap /mnt --needed xfce4 lightdm lightdm-gtk-greeter
arch-chroot /mnt bash -c 'systemctl enable --now lightdm'
elif [[ $DESKTOPENV == '5' ]]; then
pacstrap /mnt --needed lxqt sddm
arch-chroot /mnt bash -c 'systemctl enable --now sddm'
fi
}
unmounter() {
lsblk && br && read -rp 'Unmount all partition [Y/N]: ' UNMOUNTYN
if [ "$UNMOUNTYN" = 'y' ] || [ "$UNMOUNTYN" = 'Y' ]; then
sync && wait
umount -fv /mnt/home && wait
umount -fv /mnt/boot/efi && wait
umount -fv /mnt && wait
swapoff -av && wait
fi
}
rebooter() {
read -rp 'Reboot system [Y/N]: ' REBOOTYN
if [[ $REBOOTYN =~ ^([Yy][Ee][Ss]|[Yy])$ ]]; then
reboot
fi
}
main() {
clear
echo -e '############################'
echo -e '#### ARC ARCH INSTALLER ####'
echo -e '############################\n'
echo -e '1. PacmanDB'
echo -e '2. Partition'
echo -e '3. Format & mount'
echo -e '4. Base'
echo -e '5. Genfstab'
echo -e '6. Chroot'
echo -e '7. Deskenv'
echo -e '8. Unmount'
echo -e '9. Reboot\n'
read -rp 'Enter the number of step [1-8]: ' STEPNO
clear
if [[ $STEPNO == '1' ]]; then
refreshdb
elif [[ $STEPNO == '2' ]]; then
partition
elif [[ $STEPNO == '3' ]]; then
mounter
elif [[ $STEPNO == '4' ]]; then
base
elif [[ $STEPNO == '5' ]]; then
fstabgen
elif [[ $STEPNO == '6' ]]; then
chroot
elif [[ $STEPNO == '7' ]]; then
deskenv
elif [[ $STEPNO == '8' ]]; then
unmounter
elif [[ $STEPNO == '9' ]]; then
rebooter
else
echo 'Invalid number'
exit
fi
# REPEAT
main
}
### START ###
if : >/dev/tcp/8.8.8.8/53; then true; else echo 'Offline [Use iwctl --help]' && exit; fi
timedatectl set-ntp true
main
set +e