Initial
This commit is contained in:
142
bash/arch_install.sh
Executable file
142
bash/arch_install.sh
Executable file
@@ -0,0 +1,142 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user