-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathsetup.sh
executable file
·132 lines (107 loc) · 3.73 KB
/
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
#!/usr/bin/bash
# print command before executing, and exit when any command fails
set -xe
hostname=arch
# regular user name
username=arch
# password for regular user. Password for root will not be set
password=123456
# Timezone
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc --utc
# Locale
sed -i 's/^#en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
sed -i 's/^#zh_CN.GB18030/zh_CN.GB18030/' /etc/locale.gen
sed -i 's/^#zh_CN.UTF-8/zh_CN.UTF-8/' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
# Hostname
echo $hostname > /etc/hostname
# Install intel-ucode for Intel CPU
is_intel_cpu=$(lscpu | grep 'Intel' &> /dev/null && echo 'yes' || echo '')
if [[ -n "$is_intel_cpu" ]]; then
pacman -S --noconfirm intel-ucode --overwrite=/boot/intel-ucode.img
fi
# Bootloader
# Use system-boot for EFI mode, and grub for others
if [[ -d "/sys/firmware/efi/efivars" ]]; then
bootctl install
cat <<EOF > /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root=/dev/sda2 rw
EOF
cat <<EOF > /boot/loader/loader.conf
default arch
timeout 3
editor no
EOF
if [[ -z "$is_intel_cpu" ]]; then
sed -i '/intel-ucode/d' /boot/loader/entries/arch.conf
fi
# remove leading spaces
sed -i 's#^ \+##g' /boot/loader/entries/arch.conf
sed -i 's#^ \+##g' /boot/loader/loader.conf
# modify root partion in loader conf
root_partition=$(mount | grep 'on / ' | cut -d' ' -f1)
root_partition=$(df / | tail -1 | cut -d' ' -f1)
sed -i "s#/dev/sda2#$root_partition#" /boot/loader/entries/arch.conf
else
disk=$(df / | tail -1 | cut -d' ' -f1 | sed 's#[0-9]\+##g')
pacman --noconfirm -S grub os-prober
grub-install --target=i386-pc "$disk"
grub-mkconfig -o /boot/grub/grub.cfg
fi
# Config sudo
# allow users of group wheel to use sudo
sed -i 's/^# %wheel ALL=(ALL) ALL$/%wheel ALL=(ALL) ALL/' /etc/sudoers
# Create regular user
useradd -m -g users -G wheel -s /bin/bash $username
echo "$username:$password" | chpasswd
# Desktop Environment
# xorg
pacman -S --noconfirm xorg-server
# graphics driver
nvidia=$(lspci | grep -e VGA -e 3D | grep 'NVIDIA' 2> /dev/null || echo '')
amd=$(lspci | grep -e VGA -e 3D | grep 'AMD' 2> /dev/null || echo '')
intel=$(lspci | grep -e VGA -e 3D | grep 'Intel' 2> /dev/null || echo '')
if [[ -n "$nvidia" ]]; then
pacman -S --noconfirm nvidia
fi
if [[ -n "$amd" ]]; then
pacman -S --noconfirm xf86-video-amdgpu
fi
if [[ -n "$intel" ]]; then
pacman -S --noconfirm xf86-video-intel
fi
if [[ -n "$nvidia" && -n "$intel" ]]; then
pacman -S --noconfirm bumblebee
gpasswd -a $username bumblebee
systemctl enable bumblebeed
fi
# touchpad driver
# Seem no more needed as xf86-input-libinput can be a drop-in replacement
# if grep -q 'Synaptics TouchPad' /proc/bus/input/devices; then
# pacman -S --noconfirm xf86-input-synaptics
# fi
# gnome
pacman -S --noconfirm gdm gnome-shell gnome-shell-extensions gnome-keyring seahorse gnome-backgrounds \
gnome-control-center gnome-font-viewer xdg-user-dirs-gtk \
gnome-power-manager gnome-system-monitor gnome-terminal nautilus gvfs-mtp eog evince \
file-roller gnome-tweaks networkmanager
# Native browser connector for integration with extensions.gnome.org
pacman -S --noconfirm chrome-gnome-shell
# start gnome by default
systemctl enable gdm
systemctl enable NetworkManager
# compression/decompression tools
pacman -S --noconfirm unrar p7zip
# useful shell utils
pacman -S --noconfirm bash-completion vim bind-tools dos2unix rsync wget git tree
pacman -S --noconfirm net-tools whois screen inotify-tools perl-rename recode
pacman -S --noconfirm openbsd-netcat
# Use vim instead vi
ln -s /usr/bin/vim /usr/local/bin/vi