-
Notifications
You must be signed in to change notification settings - Fork 3
/
2-root-install-adduser.sh
201 lines (180 loc) · 5.43 KB
/
2-root-install-adduser.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# set some colors
CNT="[\e[1;36mNOTE\e[0m]"
COK="[\e[1;32mOK\e[0m]"
CER="[\e[1;31mERROR\e[0m]"
CAT="[\e[1;37mATTENTION\e[0m]"
CWR="[\e[1;35mWARNING\e[0m]"
CAC="[\e[1;33mACTION\e[0m]"
# check network
ping -c 3 www.baidu.com >/dev/null
if [ $? -eq 0 ]; then
echo -e "\n$COK network connected..................."
else
echo -e "\n$CER network not connected, You must connect network ......."
exit 1
fi
sleep 1
# set pacman
echo -e "\n$CNT edit pacman.conf ..................."
sleep 1
sed -i 's/#Color/Color/' /etc/pacman.conf
sleep 1
sed -i '/Color/a\\ILoveCandy' /etc/pacman.conf
sleep 1
sed -i 's/#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
sleep 1
cat >>/etc/pacman.conf <<EOF
[archlinuxcn]
Server = https://mirrors.ustc.edu.cn/archlinuxcn/\$arch
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/\$arch
EOF
sleep 1
pacman -Sy
sleep 1
pacman-key --lsign-key "[email protected]"
sleep 1
pacman -S archlinuxcn-keyring
echo -e "\n$CAC archlinuxcn done ..................."
sleep 1
# if install keyring ERROR
read -rep $'[\e[1;37mATTENTION\e[0m] - Is it successful to install ArchlinuxCn Key? (y,n) ' KEY
if [[ $KEY == "N" || $KEY == "n" ]]; then
echo -e "$CNT - Setup starting install archlinuxcn ..................."
rm -rf /etc/pacman.d/gnupg
sleep 1
pacman-key --init
sleep 1
pacman-key --populate archlinux archlinuxcn
echo -e "\n$CAC archlinuxcn done ..................."
sleep 1
fi
# install aur
echo -e "\n$CNT install paru ................ln"
sleep 1
pacman -S paru
sleep 1
sed -i 's/#BottomUp/BottomUp/' /etc/paru.conf
echo -e "\n$CAC paru conf done ..................."
sleep 1
# add user
echo -e "\n$CNT add user ............................."
sleep 1
read -rep $'[\e[1;37mATTENTION\e[0m] - Please enter the user name: ' UUSER
useradd -m -G wheel $UUSER
read -rep $'[\e[1;37mATTENTION\e[0m] - Please enter the user password: ' PASSWD
echo -e "${PASSWD}\n${PASSWD}" | passwd $UUSER
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/g' /etc/sudoers
echo -e "\n$CAC user done ..................."
sleep 1
# add fonts
echo -e "\n$CNT install fonts .........................."
pacman -S noto-fonts noto-fonts-cjk noto-fonts-emoji ttf-noto-nerd ttf-nerd-fonts-symbols ttf-nerd-fonts-symbols-mono ttf-lxgw-wenkai ttf-lxgw-wenkai-mono
echo -e "\n$CAC fonts done ..................."
sleep 1
# add zram
# read -rep $'[\e[1;37mATTENTION\e[0m] - Do you install zram? (y,n) ' ZRAM
# if [[ $ZRAM == "Y" || $ZRAM == "y" ]]; then
# echo -e "$CNT - Setup starting install zram .................."
# pacman -S zram-generator
# sleep 1
# cat > /etc/systemd/zram-generator.conf << EOF
# [zram0]
# zram-size = ram / 2
# compression-algorithm = zstd
# swap-priority = 100
# fs-type = swap
# EOF
# sleep 1
# systemctl daemon-reload
# sleep 1
# systemctl start /dev/nvme0n1p2
# # disable zswap, because kernel default enable zswap.
# sleep 1
# sed -i '/GRUB_CMDLINE_LINUX_DEFAULT=/s/.$/ zswap.enabled=0&/' /etc/default/grub
# sleep 1
# # Optimizing swap on zram
# cat > /etc/sysctl.d/99-vm-zram-parameters.conf <<EOF
# vm.swappiness = 180
# vm.watermark_boost_factor = 0
# vm.watermark_scale_factor = 125
# vm.page-cluster = 0
# EOF
# echo -e "\n$CAC zram done ..................."
# sleep 1
# fi
# add pipewire
echo -e "\n$CNT install pipewire ......................."
sleep 1
pacman -S pipewire wireplumber pipewire-pulse gst-plugin-pipewire pipewire-alsa pipewire-audio pipewire-jack --needed
echo -e "\n$CAC pipewire done ..................."
sleep 1
# add Integrated graphics
echo -e "\n$CNT starting install Integrated graphics Please select your cpu type ......................"
pacman -S mesa libva-utils vulkan-icd-loader vulkan-tools
sleep 1
select graphics in "cpu-intel" "cpu-amd"; do
case $graphics in
"cpu-intel")
pacman -S intel-media-driver vulkan-intel
break
;;
"cpu-amd")
pacman -S libva-mesa-driver vulkan-radeon
break
;;
*)
echo "Input error, please retype"
;;
esac
done
echo -e "\n$CAC Integrated graphics done ..................."
sleep 1
# add fcitx5
echo -e "\n$CNT install fcitx5 ........................."
sleep 1
pacman -S fcitx5-im fcitx5-chinese-addons fcitx5-pinyin-zhwiki fcitx5-pinyin-moegirl
sleep 1
# fix fstab
sed -i 's/subvolid=[0-9]\{3\}/nodiscard/g' /etc/fstab
sleep 1
# config network
echo -e "\n$CNT starting config networkmanager ........................."
cat <<EOF >/etc/NetworkManager/conf.d/20-connectivity.conf
[connectivity]
enabled=false
EOF
echo -e "\n$CAC networkmanager done ..................."
sleep 1
# setup paccache
echo -e "\n$CNT starting setup paccache ........................"
systemctl enable paccache.timer
echo -e "\n$CAC setup paccache done ..................."
sleep 1
# startup net optimize
cat <<EOF >/etc/sysctl.d/20-fast.conf
net.ipv4.tcp_fastopen = 3
EOF
sleep 1
cat <<EOF >/etc/sysctl.d/30-bbr.conf
net.core.default_qdisc = cake
net.ipv4.tcp_congestion_control = bbr
EOF
sleep 1
modprobe tcp_bbr
sleep 1
echo -e "\n$CAC configure net optimize done ..................."
# configure btrfs swapfile
btrfs filesystem mkswapfile --size 16g --uuid clear /swap/swapfile
sleep 1
swapon /swap/swapfile
# edit fstab add swapfile
cat <<EOF >>/etc/fstab
# swapfile
/swap/swapfile none swap defaults 0 0
EOF
sleep 1
echo -e "\n$CAC configure btrfs swapfile done ..................."
# mv script to home
mv ~/arch-scripts /home/$UUSER/
echo -e "\n$COK Has been completed. >>>>>>>>>>>>>>>>> Check fstab, df, lsblk \n"