-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
248 lines (216 loc) · 5.98 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
#!/bin/bash
clear
# color codes
L=$(tput setaf bold)
R=$(tput setaf 1)
G=$(tput setaf 2)
B=$(tput setaf 33)
N=$(tput sgr0)
######################## functions #########################
# function for branding
function call {
echo -ne "${L}${B}
-------------------------------------
| Talha Arch Installer |
| |
| visit: github.com/talha1896 |
-------------------------------------
${N}"
}
# functions for color codes
# for red
function red {
echo "${L}${R}$1${N}"
}
# for blue
function blue {
echo "${L}${B}$1${N}"
}
# for green
function green {
echo "${L}${G}$1${N}"
}
##############################################################
##################### Magic start from here ##################
call
# check internet
ping -c 1 archlinux.org &>/dev/null
if [ $? -eq 1 ]; then
red "[-] Internet not connected"
exit 1
fi
##############################################################
# update mirrors
green "[+] Updating Arch linux mirrors"
sleep 1s
reflector --latest 10 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
blue "[+] Updated"
sleep 1.5s
clear
##############################################################
###################### Installation begins from here #########
# update keyring
call
green "[+] updating keyring"
pacman -Sy --needed --noconfirm archlinux-keyring
blue "[+] updated"
sleep 1s
clear
# Drive configuration
call
green "-------------- Drive configuration -----------------"
red "Gettting disks information. Your general disk configuration should be like :~"
echo "/dev/sda1 filesystem partition size must be above 8gb"
echo "/dev/sda2 swap partition must be 1 gb"
echo "/dev/sda3 boot partition for uefi only. size may be 100mb"
red "if you understand this then press Enter to continue"
read
read -p "Do you want to config your drives as above before proceeding to main steps. (y/n):" choice
case $choice in
y)
green "okay! opening disk configuration tool.wait ...."
sleep 2s
cfdisk
;;
n)
# do noting
;;
esac
clear
call
blue "Your pc has these drives:"
lsblk
red "Double check before proceeding this step will format your drive"
read -p "Write the drive in which you want to install Arch. (eg: /dev/sda1):" drive
green "creating partition"
mkfs.ext4 $drive
mount $drive /mnt
blue "created Arch filesystem drive"
# for swap
read -p "Did you also want to create swap partition? [y/n]: " answerswap
case "$answerswap" in
y | Y | yes | Yes | YES)
green "Enter swap partition (eg: /dev/sda3): "
read swappartition
mkswap "$swappartition"
swapon "$swappartition"
blue "swap partition created"
;;
*)
red "Skipping Swap partition!"
;;
esac
#for uefi
read -p "Is you are installing in uefi system. (y/n):" uefi
case $uefi in
y)
lsblk
read -p "Write the boot partition,which has size around 100mb. (eg. /dev/sda4): " answerefi
mkfs.fat -F 32 "$answerefi"
green "boot partition created"
clear
;;
n)
# do noting
;;
esac
clear
################################# Install base ##############################
call
green "----------- Install base packages -----------------"
blue "Installing ......"
sleep 1s
# install base
pacstrap /mnt base base-devel curl
#generating fstab file
genfstab -U /mnt >> /mnt/etc/fstab &>/dev/null
blue "Installed"
sleep 2s
clear
############################### Post installation #################
call
green "Main installation is finished"
echo "changing script from archiso to newly created system"
sleep 3s
# now start post script
sed '1,/^#part2$/d' install > /mnt/post-install
chmod +x /mnt/post-install
arch-chroot /mnt ./post-install
############################### Install everything ################################
#part2
call
green "----------- Entered in newly created system --------------"
blue "Updating pacman repo"
pacman -Sy
# install kernal
echo "Which processer your pc has:"
blue "[1] intel"
green "[2] amd"
read -p "Which processer your pc has:" choice
case $choice in
1)
pacman -S linux linux-headers intel-ucode --noconfirm
blue "Driver Installed"
sleep 2s
clear
;;
2)
pacman -S linux linux-headers amd-ucode --noconfirm
blue "Driver Installed"
sleep 2s
clear
;;
esac
########################################################
####################### Post installation #################
call
green "----------- Post Installation ---------------"
# set timezone
blue "set time zone"
read -p "write your location (eg: Asia/Karachi):" time
ln -sf /usr/share/zoneinfo/$time /etc/localtime
hwclock --systohc
# hiden default things
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=us" > /etc/vconsole.conf
# set hostname
read -p "Write your pc host name. (eg: Arch):" hostname
echo $hostname > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "::1 localhost" >> /etc/hosts
echo "127.0.1.1 $hostname" >> /etc/hosts
green "Now your pc host name is $hostname"
sleep 2s
clear
###############################
call
green "........ Almost completed........."
# install grub
blue "Installing grub"
sleep 2s
pacman -Sy --needed --noconfirm grub networkmanager efibootmgr
systemctl enable NetworkManager &>/dev/null
green "Enter the drive name to install bootloader in it. (eg: /dev/sda):"
red "Enter drive name only like /dev/sda not like /dev/sda1:"
read grubdrive
grub-install --target=i386-pc $grubdrive
grub-mkconfig -o /boot/grub/grub.cfg
blue "Grub installed"
sleep 3s
clear
call
red "Enter password for root:"
passwd
# add regular user
read "Enter username to add a regular user: " username
useradd -m users -G wheel,audio,video -s /bin/bash $username
blue "Enter password for "$username": "
passwd $username
echo "$username ALL=(ALL) ALL" >> /etc/sudoers.d/$username
green "$username added"
blue "All things are done succesfully"
green "Thank you for using this script.You can reboot your pc now"
read
exit