-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-setup.sh
186 lines (175 loc) · 7.52 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env bash
echo -ne "
-------------------------------------------------------------------------
d8b 888b 888 888 .d88888b. .d8888b.
Y8P 8888b 888 888 d88P" "Y88b d88P Y88b
88888b 888 888 888 888 Y88b.
888 888Y88b 888 8888b. 888888 888 888 888d888 .d88b. 888 888 "Y888b.
888 888 Y88b888 "88b 888 888 888 888P" d8P Y8b 888 888 "Y88b.
888 888 Y88888 .d888888 888 888 888 888 88888888 888 888 "888
888 888 Y8888 888 888 Y88b. Y88b 888 888 Y8b. Y88b. .d88P Y88b d88P
888 888 Y888 "Y888888 "Y888 "Y88888 888 "Y8888 "Y88888P" "Y8888P"
-------------------------------------------------------------------------
Automated iNatureOS Installer
SCRIPTHOME: iNatureOS
-------------------------------------------------------------------------
"
source /root/iNatureOS/setup.conf
echo -ne "
-------------------------------------------------------------------------
Network Setup
-------------------------------------------------------------------------
"
pacman -S networkmanager dhclient --noconfirm --needed
systemctl enable --now NetworkManager
echo -ne "
-------------------------------------------------------------------------
Setting up mirrors for optimal download
-------------------------------------------------------------------------
"
pacman -S --noconfirm pacman-contrib curl
pacman -S --noconfirm reflector rsync grub btrfs-progs arch-install-scripts git
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
nc=$(grep -c ^processor /proc/cpuinfo)
echo -ne "
-------------------------------------------------------------------------
You have " $nc" cores. And
changing the makeflags for "$nc" cores. Aswell as
changing the compression settings.
-------------------------------------------------------------------------
"
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
sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf
fi
echo -ne "
-------------------------------------------------------------------------
Setup Language to US and set locale
-------------------------------------------------------------------------
"
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
sed -i 's/^#sr_RS UTF-8/sr_RS UTF-8/' /etc/locale.gen
sed -i 's/^#sr_RS@latin UTF-8/sr_RS@latin 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_GB.UTF-8" LC_PAPER="en_GB.UTF-8" LC_MEASUREMENT="en_GB.UTF-8"
# 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
#Add parallel downloading
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
#Enable multilib
sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf
pacman -Sy --noconfirm
echo -ne "
-------------------------------------------------------------------------
Installing Base System
-------------------------------------------------------------------------
"
cat /root/iNatureOS/pkg-files/pacman-pkgs.txt | while read line
do
echo "INSTALLING: ${line}"
sudo pacman -S --noconfirm --needed ${line}
done
echo -ne "
-------------------------------------------------------------------------
Installing Microcode
-------------------------------------------------------------------------
"
# determine processor type and install microcode
proc_type=$(lscpu)
if grep -E "GenuineIntel" <<< ${proc_type}; then
echo "Installing Intel microcode"
pacman -S --noconfirm intel-ucode
proc_ucode=intel-ucode.img
elif grep -E "AuthenticAMD" <<< ${proc_type}; then
echo "Installing AMD microcode"
pacman -S --noconfirm amd-ucode
proc_ucode=amd-ucode.img
fi
echo -ne "
-------------------------------------------------------------------------
Installing Graphics Drivers
-------------------------------------------------------------------------
"
# Graphics Drivers find and install
gpu_type=$(lspci)
if grep -E "NVIDIA|GeForce" <<< ${gpu_type}; then
pacman -S nvidia --noconfirm --needed
nvidia-xconfig
elif lspci | grep 'VGA' | grep -E "Radeon|AMD"; then
pacman -S xf86-video-amdgpu --noconfirm --needed
elif grep -E "Integrated Graphics Controller" <<< ${gpu_type}; then
pacman -S libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa --needed --noconfirm
elif grep -E "Intel Corporation UHD" <<< ${gpu_type}; then
pacman -S libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa --needed --noconfirm
fi
#SETUP IS WRONG THIS IS RUN
if ! source /root/iNatureOS/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}/iNatureOS/setup.conf
#Set Password
read -p "Please enter password:" password
echo "password=${password,,}" >> ${HOME}/iNatureOS/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:" nameofmachine
# hostname regex (!!couldn't find spec for computer name!!)
if [[ "${nameofmachine,,}" =~ ^[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 "nameofmachine=${nameofmachine,,}" >> ${HOME}/iNatureOS/setup.conf
fi
echo -ne "
-------------------------------------------------------------------------
Adding User
-------------------------------------------------------------------------
"
if [ $(whoami) = "root" ]; then
groupadd libvirt
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
# use chpasswd to enter $USERNAME:$password
echo "$USERNAME:$PASSWORD" | chpasswd
cp -R /root/iNatureOS /home/$USERNAME/
chown -R $USERNAME: /home/$USERNAME/iNatureOS
# enter $nameofmachine to /etc/hostname
echo $nameofmachine > /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
echo -ne "
-------------------------------------------------------------------------
SYSTEM READY FOR 2-user.sh
-------------------------------------------------------------------------
"