Refactor arch install script

This commit is contained in:
olari
2019-04-14 02:43:46 +03:00
parent cbf6cd3f07
commit b1c23bd28b
4 changed files with 263 additions and 208 deletions

View File

@@ -1,142 +0,0 @@
#!/bin/bash
# Discard on use
rm $0
KEYMAP="dvorak-programmer"
DEVICE="/dev/sda"
HOSTNAME=""
USER="olari"
USER_PASS=""
ROOT_PASS=""
REGION="Europe/Tallinn"
MIRROR="http://mirrors.dotsrc.org/archlinux/\$repo/os/\$arch"
partition_disk() {
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${DEVICE}
g # Create gpt partition table.
## Create partitions
n # Create efi partition...
1 # ... at index 1...
# ... at default start pos...
+512M # ... with 512MB size.
n # Create swap partition...
2 # ... at index 2...
# ... at default start pos...
+4G # ... with 4G size.
n # Create root partition...
3 # ... at index 3...
# ... at default start pos...
# ... with max size.
## Set partition types
t # Change parition type...
1 # ... of the efi partition...
1 # ... to "1 EFI System".
t # Change partition type...
2 # ... of the swap partition...
19 # ... to "19 Linux swap".
t # Change partition type...
3 # ... of the root partition...
20 # ... to "20 Linux filesystem"
w # Write changes
q # Quit
EOF
}
format_partitions() {
mkfs.fat -F32 ${DEVICE}1
mkswap ${DEVICE}2
swapon ${DEVICE}2
mkfs.ext4 ${DEVICE}3
}
mount_partitions() {
mount ${DEVICE}3 /mnt
mkdir /mnt/boot
mount ${DEVICE}1 /mnt/boot
}
set_pacman_mirror() {
sed -i "1iServer = $MIRROR" /etc/pacman.d/mirrorlist
}
create_fstab() {
cat <<EOT > /mnt/etc/fstab
/dev/sda1 /boot vfat defaults 0 2
/dev/sda2 none swap sw 0 0
/dev/sda3 / ext4 noatime,discard 0 1
EOT
}
create_chroot_script() {
cat <<EOT > /mnt/chroot_script.sh
#!/bin/sh
# Discard on use
rm $0
# Sync clock
ln -sf /usr/share/zoneinfo/${REGION} /etc/localtime
hwclock --systohc
# Generate locale
sed -i '1ien_US.UTF-8 UTF-8' /etc/locale.gen
locale-gen
# Set locale options
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=${KEYMAP}" > /etc/vconsole.conf
# Set hostname
echo "${HOSTNAME}" > /etc/hostname
# Set up hosts file
echo -e "127.0.0.1 localhost\n::1 localhost\n127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}" > /etc/hosts
# Install Gnome
pacman -S --noconfirm gnome
systemctl enable gdm
systemctl enable NetworkManager
# Set up bootloader
pacman -S --noconfirm efibootmgr intel-ucode grub
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg
# Set root password
echo "root:${ROOT_PASS}" | chpasswd
# Create user and set password
useradd -m -G wheel -s /bin/bash ${USER}
echo "${USER}:${USER_PASS}" | chpasswd
# Enable sudo for wheel group
sed -i '1i%wheel ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
exit
EOT
chmod +x /mnt/chroot_script.sh
}
timedatectl set-ntp true
partition_disk
format_partitions
mount_partitions
set_pacman_mirror
pacstrap /mnt base base-devel
create_fstab
create_chroot_script
arch-chroot /mnt /bin/sh chroot_script.sh
reboot

View File

@@ -1,66 +0,0 @@
#!/bin/bash
# Discard on use
rm $0
DRIVER_PACKAGES=(
xf86-video-
xf86-input-
)
install_packages() {
PACKAGES=(
ttf-dejavu
ttf-liberation
noto-fonts-cjk
noto-fonts-emoji
p7zip
unrar
unzip
mpv
feh
zathura
zathura-djvu
zathura-pdf-mupdf
zathura-cb
audacious
termite
ranger
neofetch
htop
tmux
ntfs-3g
vim
firefox
youtube-dl
openssh
wget
curl
transmission
gcc
gdb
cmake
code
)
PACKAGES += DRIVER_PACKAGES
yay -S --noconfirm ${PACKAGES[*]}
}
install_yay() {
sudo pacman -Syyu --noconfirm git
git clone https://aur.archlinux.org/yay.git ~/temp_yay
cd ~/temp_yay
makepkg -si
cd
rm -rf ~/temp_yay
}
install_yay
install_packages

247
bash/install_arch.sh Executable file
View File

@@ -0,0 +1,247 @@
#!/bin/bash
KEYMAP="dvorak-programmer"
DEVICE="/dev/sda"
USE_UEFI=true
HOSTNAME=""
USER="olari"
USER_PASS=""
ROOT_PASS=""
REGION="Europe/Tallinn"
MIRROR="http://mirrors.dotsrc.org/archlinux/\$repo/os/\$arch"
PACKAGES=(
# base groups
base
base-devel
# bootloader
grub
intel-ucode
efibootmgr
# drivers
xf86-video-intel
# network & audio
networkmanager
pulseaudio
# desktop environment
gdm # display manager
gnome-shell # session
gvfs # automount system
gvfs-smb # samba support
sushi # file preview
file-roller # archive tool
nautilus # file browser
xdg-user-dirs-gtk # filesystem manager
# fonts
ttf-dejavu
ttf-liberation
noto-fonts-cjk
noto-fonts-emoji
# media players
mpv
feh
zathura
zathura-pdf-mupdf
zathura-cb
audacious
# terminal apps
termite
tmux
vim
git
ranger
htop
openssh
youtube-dl
wget
neofetch
# other
firefox # web browser
fish # better shell
ntfs-3g # support for ntfs partitons
tlp # power manager
)
prepare_disk_uefi() {
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${DEVICE}
g # Create gpt partition table.
## Create partitions
n # Create efi partition...
1 # ... at index 1...
# ... at default start pos...
+512M # ... with 512MB size.
n # Create swap partition...
2 # ... at index 2...
# ... at default start pos...
+4G # ... with 4G size.
n # Create root partition...
3 # ... at index 3...
# ... at default start pos...
# ... with max size.
## Set partition types
t # Change parition type...
1 # ... of the efi partition...
1 # ... to "1 EFI System".
t # Change partition type...
2 # ... of the swap partition...
19 # ... to "19 Linux swap".
t # Change partition type...
3 # ... of the root partition...
20 # ... to "20 Linux filesystem"
w # Write changes
q # Quit
EOF
mkfs.fat -F32 ${DEVICE}1
mkswap ${DEVICE}2
swapon ${DEVICE}2
mkfs.ext4 ${DEVICE}3
mount ${DEVICE}3 /mnt
mkdir /mnt/boot
mount ${DEVICE}1 /mnt/boot
cat <<EOT > /mnt/etc/fstab
/dev/sda3 / ext4 noatime,discard 0 1
/dev/sda1 /boot vfat defaults 0 2
/dev/sda2 none swap sw 0 0
EOT
}
partition_disk_dos() {
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk ${DEVICE}
o # Create dos partition table.
## Create partitions
n # Create swap partition...
# ... with default type...
1 # ... at index 1...
# ... at default start pos...
+8G # ... with 8G size.
n # Create root partition...
# ... with default type...
2 # ... at index 2...
# ... at default start pos...
# ... with default size.
## Set partition types
t # Change parition type...
1 # ... of the swap partuition...
82 # ... to "82 Linux swap".
t # Change partition type...
2 # ... of the root partition...
83 # ... to "83 Linux".
a # Set bootable flag...
2 # ... on the root partition.
w # Write changes
q # Quit
EOF
mkswap ${DEVICE}1
swapon ${DEVICE}1
mkfs.ext4 ${DEVICE}2
mount ${DEVICE}2 /mnt
cat <<EOT > /mnt/etc/fstab
/dev/sda2 / ext4 noatime,discard 0 1
/dev/sda1 none swap sw 0 0
EOT
}
create_chroot_script() {
cat <<EOT > /mnt/chroot_script.sh
#!/bin/sh
# Discard on use
rm $0
# Sync clock
ln -sf /usr/share/zoneinfo/${REGION} /etc/localtime
hwclock --systohc
# Generate locale
sed -i '1ien_US.UTF-8 UTF-8' /etc/locale.gen
locale-gen
# Set locale options
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo "KEYMAP=${KEYMAP}" > /etc/vconsole.conf
# Set hostname
echo "${HOSTNAME}" > /etc/hostname
# Set up hosts file
echo -e "127.0.0.1 localhost\n::1 localhost\n127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}" > /etc/hosts
# Set up bootloader
if [[ ${USE_UEFI} == true ]]; then
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg
else
grub-install ${DEVICE}
grub-mkconfig -o /boot/grub/grub.cfg
fi
# Set root password
echo "root:${ROOT_PASS}" | chpasswd
# Create user and set password
useradd -m -G wheel -s /bin/bash ${USER}
echo "${USER}:${USER_PASS}" | chpasswd
# Enable sudo for wheel group
sed -i '1i%wheel ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
# Install yay
su - ${USER} -c 'git clone https://aur.archlinux.org/yay.git; cd yay; makepkg -si; cd ..; rm -rf yay'
chsh -s /usr/bin/fish olari
# Enable services
systemctl enable gdm
systemctl enable NetworkManager
systemctl enable tlp
systemctl enable tlp-sleep
exit
EOT
chmod +x /mnt/chroot_script.sh
}
timedatectl set-ntp true
if [[ $USE_UEFI == true ]]; then
prepare_disk_uefi
else
prepare_disk_dos
fi
sed -i "1iServer = $MIRROR" /etc/pacman.d/mirrorlist
pacstrap /mnt ${PACKAGES[*]}
create_chroot_script
arch-chroot /mnt /bin/sh chroot_script.sh
reboot

16
bash/setup_gnome.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
yay -S yaru-gtk-theme yaru-sound-theme gnome-shell-extension-ubuntu-dock
yay -S yaru-icon-theme # needs to be installed seperately for some reason
#gsettings set org.gnome.desktop.interface enable-animations false
gsettings set org.gnome.desktop.interface gtk-theme Yaru-dark
gsettings set org.gnome.desktop.interface cursor-theme Yaru
gsettings set org.gnome.desktop.interface icon-theme Yaru
gsettings set org.gnome.desktop.sound sound-theme Yaru
gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us+dvp')]"
gsettings set org.gnome.desktop.input-sources xkb-options "['compose:lctrl', 'ctrl:nocaps', 'altwin:alt_super_win']"
gsettings set org.gnome.shell enabled-extensions "['ubuntu-dock@ubuntu.com']"