Add files
This commit is contained in:
263
install.sh
Normal file
263
install.sh
Normal file
@@ -0,0 +1,263 @@
|
||||
#!/bin/bash
|
||||
set -euxo pipefail
|
||||
|
||||
HOSTNAME="t440p"
|
||||
USERNAME="olari"
|
||||
PASSWORD="redacted"
|
||||
REGION="Europe/Tallinn"
|
||||
KEYMAP="dvorak-programmer"
|
||||
MIRROR="http://mirrors.dotsrc.org/archlinux/\$repo/os/\$arch"
|
||||
DEVICE="/dev/sda"
|
||||
|
||||
PACKAGES=(
|
||||
# Base groups
|
||||
base # Base installation
|
||||
base-devel # Tools for building packages
|
||||
|
||||
# Bootloader
|
||||
grub # Bootloader
|
||||
efibootmgr # EFI support
|
||||
intel-ucode # Intel microcode
|
||||
|
||||
# T440p Drivers
|
||||
xf86-video-intel # Intel video driver
|
||||
xf86-input-synaptics # Touchpad driver
|
||||
|
||||
# Network and audio
|
||||
networkmanager # Network management
|
||||
pulseaudio # Audio management
|
||||
|
||||
# Desktop environment
|
||||
gdm # Display manager
|
||||
gnome-shell # Graphical shell
|
||||
gvfs # Gnome virtual file system
|
||||
gvfs-smb # Samba support for gvfs
|
||||
xdg-user-dirs-gtk # User directory manager
|
||||
nautilus # File manager
|
||||
|
||||
# Fonts
|
||||
ttf-dejavu # General font
|
||||
ttf-liberation # Arial-like font
|
||||
noto-fonts-cjk # Asian characters
|
||||
noto-fonts-emoji # Emoticons
|
||||
|
||||
# Media players
|
||||
mpv # Video player
|
||||
audacious # Music player
|
||||
sxiv # Image viewer
|
||||
zathura # Document viewer
|
||||
zathura-pdf-mupdf # Pdf support for zathura
|
||||
zathura-cb # Comic book support for zathura
|
||||
zathura-djvu # Djvu support for zathura
|
||||
|
||||
# Terminal environment
|
||||
alacritty # Terminal emulator
|
||||
fish # Friendly interactive shell
|
||||
tmux # Terminal multiplexer
|
||||
neovim # Text editor
|
||||
|
||||
# Terminal utils
|
||||
jq # JSON parser
|
||||
git # Version control
|
||||
htop # Process viewer
|
||||
openssh # SSH client and server
|
||||
gnu-netcat # Network utility (for CTF)
|
||||
atool # Archive tool
|
||||
zip unzip # Zip support
|
||||
unrar p7zip # RAR, 7z support
|
||||
|
||||
# Internet
|
||||
firefox # Web browser
|
||||
wget curl # File transfer
|
||||
qbittorrent # Bittorrent client
|
||||
youtube-dl # Video downloader
|
||||
|
||||
# Development
|
||||
python # Scripting language
|
||||
python-pip # Package manager for python
|
||||
clang # C and C++ compiler and tools
|
||||
gcc # C and C++ compiler
|
||||
gdb # Debugger
|
||||
cmake # Build system
|
||||
nodejs # JavaScript runtime
|
||||
yarn # Node package manager
|
||||
|
||||
# Other
|
||||
ntfs-3g # NTFS driver
|
||||
tlp # Laptop power manager
|
||||
)
|
||||
|
||||
SERVICES=(gdm NetworkManager tlp tlp-sleep)
|
||||
|
||||
function 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
|
||||
|
||||
# Format the partitions
|
||||
mkfs.fat -F32 "${DEVICE}1"
|
||||
mkswap "${DEVICE}2"
|
||||
mkfs.ext4 "${DEVICE}3"
|
||||
|
||||
# Mount the partitions
|
||||
swapon "${DEVICE}2"
|
||||
mount "${DEVICE}3" /mnt
|
||||
mkdir /mnt/boot
|
||||
mount "${DEVICE}1" /mnt/boot
|
||||
|
||||
# Create fstab file
|
||||
mkdir /mnt/etc
|
||||
cat <<EOF > /mnt/etc/fstab
|
||||
/dev/sda1 /boot vfat defaults 0 2
|
||||
/dev/sda2 none swap sw 0 0
|
||||
/dev/sda3 / ext4 noatime,discard 0 1
|
||||
EOF
|
||||
}
|
||||
|
||||
function prepare_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...
|
||||
+4G # ... 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
|
||||
|
||||
# Format partitions
|
||||
mkswap "${DEVICE}1"
|
||||
mkfs.ext4 "${DEVICE}2"
|
||||
|
||||
# Fount partition
|
||||
swapon "${DEVICE}1"
|
||||
mount "${DEVICE}2" /mnt
|
||||
|
||||
# Create fstab file
|
||||
mkdir /mnt/etc
|
||||
cat <<EOF > /mnt/etc/fstab
|
||||
/dev/sda1 none swap sw 0 0
|
||||
/dev/sda2 / ext4 noatime,discard 0 1
|
||||
EOF
|
||||
}
|
||||
|
||||
# Check internet connection
|
||||
ping -w1 -c1 google.com || exit 1
|
||||
|
||||
# Enable network time synchronization
|
||||
timedatectl set-ntp true
|
||||
|
||||
# Prepare disk according to boot mode
|
||||
if [[ -d /sys/firmware/efi/efivars ]]; then
|
||||
prepare_disk_uefi
|
||||
else
|
||||
prepare_disk_dos
|
||||
fi
|
||||
|
||||
# Set mirror and install system
|
||||
sed -i "1iServer = ${MIRROR}" /etc/pacman.d/mirrorlist
|
||||
pacstrap /mnt ${PACKAGES[*]}
|
||||
|
||||
# Set language and keymap
|
||||
echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf
|
||||
echo "KEYMAP=${KEYMAP}" > /mnt/etc/vconsole.conf
|
||||
|
||||
# Set hostname and create /etc/hosts
|
||||
echo "${HOSTNAME}" > /mnt/etc/hostname
|
||||
cat <<EOF > /mnt/etc/hosts
|
||||
127.0.0.1 localhost
|
||||
::1 localhost
|
||||
127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}
|
||||
EOF
|
||||
|
||||
# Set timezone and sync clock
|
||||
arch-chroot /mnt ln -sf /usr/share/zoneinfo/"${REGION}" /etc/localtime
|
||||
arch-chroot /mnt hwclock --systohc
|
||||
|
||||
# Generate locale
|
||||
arch-chroot /mnt sed -i '1ien_US.UTF-8 UTF-8' /etc/locale.gen
|
||||
arch-chroot /mnt locale-gen
|
||||
|
||||
# Install bootloader
|
||||
if [[ -d /sys/firmware/efi/efivars ]]; then
|
||||
arch-chroot /mnt grub-install \
|
||||
--target=x86_64-efi \
|
||||
--efi-directory=/boot \
|
||||
--bootloader-id=grub
|
||||
else
|
||||
arch-chroot /mnt grub-install "${DEVICE}"
|
||||
fi
|
||||
|
||||
# Configure bootloader
|
||||
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
# Create user
|
||||
arch-chroot /mnt useradd -m -G wheel -s /bin/bash "${USERNAME}"
|
||||
|
||||
# Enable nopasswd sudo for wheel group
|
||||
arch-chroot /mnt sed -i '1i%wheel ALL=(ALL) NOPASSWD: ALL' /etc/sudoers
|
||||
|
||||
# Set user credentials
|
||||
echo "${USERNAME}:${PASSWORD}" | chpasswd --root /mnt
|
||||
echo "root:${PASSWORD}" | chpasswd --root /mnt
|
||||
|
||||
# Change user shell to fish
|
||||
arch-chroot /mnt chsh -s /usr/bin/fish "${USERNAME}"
|
||||
|
||||
# Enable services
|
||||
arch-chroot /mnt systemctl enable ${SERVICES[*]}
|
||||
|
||||
Reference in New Issue
Block a user