forked from ChrisTitusTech/ArchTitus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-setup.sh
executable file
·167 lines (149 loc) · 5.93 KB
/
1-setup.sh
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
#!/usr/bin/env bash
source $HOME/zxarch/setup.conf
echo ""
echo "---------------------"
echo " NETWORK SETUP "
echo "---------------------"
pacman -S --noconfirm --needed networkmanager dhclient
systemctl enable --now NetworkManager
echo ""
echo "-----------------------------------------------"
echo " SETTING UP MIRRORS FOR OPTIMAL DOWNLOAD "
echo "-----------------------------------------------"
pacman -S --noconfirm --needed pacman-contrib curl
pacman -S --noconfirm --needed reflector rsync grub arch-install-scripts git
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
nc=$(grep -c ^processor /proc/cpuinfo)
echo "You have " $nc" cores."
echo "-------------------------------------------------"
echo "Changing the makeflags for "$nc" cores."
TOTALMEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
if [[ $TOTALMEM -gt 8000000 ]]; then
sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf
echo "Changing the compression settings for "$nc" cores."
sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf
fi
echo ""
echo "-------------------------------------------"
echo " SETUP LANGUAGE TO US AND SET LOCALE "
echo "-------------------------------------------"
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
timedatectl --no-ask-password set-timezone ${TIMEZONE}
timedatectl --no-ask-password set-ntp 1
localectl --no-ask-password set-locale LANG="en_US.UTF-8" LC_TIME="en_US.UTF-8"
ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
# Set keymaps
localectl --no-ask-password set-keymap ${KEYMAP}
# Add sudo no password rights
sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers
sed -i 's/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers
#Add parallel downloading
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
#Enable multilib
sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf
pacman -Sy --noconfirm --needed
echo ""
echo "-----------------------------------------------"
echo " INSTALLING BASE SYSTEM - PLEASE STANDBY "
echo "-----------------------------------------------"
sed -n '/'$INSTALL_TYPE'/q;p' $HOME/zxarch/pkgs.txt | while read line
do
if [[ ${line} == '--END OF LIST--' ]]; then
continue
fi
echo "INSTALLING: ${line}"
sudo pacman -S --noconfirm --needed ${line}
done
echo "-----------------------------"
echo " INSTALL CPU MICROCODE "
echo "-----------------------------"
proc_type=$(lscpu)
if grep -E "GenuineIntel" <<< ${proc_type}; then
echo "Installing Intel microcode"
pacman -S --noconfirm --needed intel-ucode
proc_ucode=intel-ucode.img
elif grep -E "AuthenticAMD" <<< ${proc_type}; then
echo "Installing AMD microcode"
pacman -S --noconfirm --needed amd-ucode
proc_ucode=amd-ucode.img
fi
echo "--------------------------------"
echo " INSTALL GRAPHICS DRIVERS "
echo "--------------------------------"
gpu_type=$(lspci)
if grep -E "NVIDIA|GeForce" <<< ${gpu_type}; then
pacman -S --noconfirm --needed nvidia
nvidia-xconfig
elif lspci | grep 'VGA' | grep -E "Radeon|AMD"; then
pacman -S --noconfirm --needed xf86-video-amdgpu
elif grep -E "Integrated Graphics Controller" <<< ${gpu_type}; then
pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa
elif grep -E "Intel Corporation UHD" <<< ${gpu_type}; then
pacman -S --needed --noconfirm libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa
fi
echo ""
echo "Done!"
echo ""
# IF SETUP IS WRONG THIS IS RUN
if ! source $HOME/zxarch/setup.conf; then
# Loop through user input until the user gives a valid username
while true
do
read -p "Please enter username:" username
# username regex per response here https://unix.stackexchange.com/questions/157426/what-is-the-regex-to-validate-linux-users
# lowercase the username to test regex
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
then
break
fi
echo "Incorrect username."
done
# convert name to lowercase before saving to setup.conf
echo "username=${username,,}" >> ${HOME}/zxarch/setup.conf
#Set Password
read -p "Please enter password:" password
echo "password=${password,,}" >> ${HOME}/zxarch/setup.conf
# Loop through user input until the user gives a valid hostname, but allow the user to force save
while true
do
read -p "Please name your machine:" name_of_machine
# hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
then
break
fi
# if validation fails allow the user to force saving of the hostname
read -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
if [[ "${force,,}" = "y" ]]
then
break
fi
done
echo "NAME_OF_MACHINE=${name_of_machine,,}" >> ${HOME}/zxarch/setup.conf
fi
echo "-------------------"
echo " ADDING USER "
echo "-------------------"
if [ $(whoami) = "root" ]; then
groupadd libvirt
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash"
# use chpasswd to enter $USERNAME:$password
echo "$USERNAME:$PASSWORD" | chpasswd
echo "$USERNAME password set"
cp -R $HOME/zxarch /home/$USERNAME/
chown -R $USERNAME: /home/$USERNAME/zxarch
echo "zxarch copied to home directory"
# enter $NAME_OF_MACHINE to /etc/hostname
echo $NAME_OF_MACHINE > /etc/hostname
else
echo "You are already a user proceed with aur installs"
fi
if [[ ${FS} == "luks" ]]; then
# Making sure to edit mkinitcpio conf if luks is selected
# add encrypt in mkinitcpio.conf before filesystems in hooks
sed -i 's/filesystems/encrypt filesystems/g' /etc/mkinitcpio.conf
# making mkinitcpio with linux kernel
mkinitcpio -p linux
fi