Add files

This commit is contained in:
olari
2019-09-29 08:10:04 +03:00
commit a87e157270
2 changed files with 362 additions and 0 deletions

263
install.sh Normal file
View 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[*]}

99
setup.sh Normal file
View File

@@ -0,0 +1,99 @@
#!/bin/bash
set -euxo pipefail
AUR_PACKAGES=(
yaru-{gtk,icon,sound}-theme # Theme from Ubuntu
consolas-font # Monospace font used by Visual Studio
shadowfox-updater # Universal dark mode for Firefox
pup-git # Commandline HTML parser (useful for bash scripts)
ccls # C++ language server
ranger-git # File manager
)
PYTHON_PACKAGES=(
# Web scraping libraries
requests # HTML requests
beautifulsoup4 # HTML parsing
# Statistics libraries
matplotlib # Plotting
numpy # Matrix manipulation
pandas # Data analysis
# Tools
pylint # Python linter
autopep8 # Python formatter
gdbgui # GDB frontend
ueberzug # Terminal image preview (used by ranger)
)
function set_gnome_settings {
# Set yaru theme
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
# Disable animations
gsettings set org.gnome.desktop.sound theme-name Yaru
# Set dvorak-programmer layout
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us+dvp')]"
# Set caps to ctrl
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']"
# Change keyboard delay and speed
gsettings set org.gnome.desktop.peripherals.keyboard delay 250
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 25
# Enable night light
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
# Sort directories before files
gsettings set org.gtk.Settings.FileChooser sort-directories-first true
}
function set_firefox_settings {
local prefs_file=$(ls ~/.mozilla/firefox/*release/prefs.js)
# Make shadowfox work on FF69
sed -i 's/\("toolkit.legacyUserProprefs_fileCustomizations.stylesheets", \)true/\1true/' "${prefs_file}"
sed -i 's/\("browser.in-content.dark-mode", \)false/\1true/' "${prefs_file}"
# Enable some privacy features
sed -i 's/\("privacy.firstparty.isolate", \)false/\1true/' "${prefs_file}"
sed -i 's/\("privacy.resistFingerprinting", \)false/\1true/' "${prefs_file}"
# Disable some spying features
sed -i 's/\("browser.send_pings", \)true/\1false/' "${prefs_file}"
sed -i 's/\("dom.event.clipboardevents.enabled", \)true/\1false/' "${prefs_file}"
sed -i 's/\("media.navigator.enabled.stylesheets", \)true/\1false/' "${prefs_file}"
}
# Check internet connection
ping -w1 -c1 google.com || exit 1
# Enable pacman colors
sudo sed -i 's/#Color/Color/' /etc/pacman.conf
# Install yay if not installed
if ! pacman -Qi yay; then
git clone http://aur.archlinux.org/yay.git
cd yay
makepkg -si --noconfirm
cd ..
rm -rf yay
fi
yay -Sy --noconfirm --needed ${AUR_PACKAGES[*]}
pip install --user ${PYTHON_PACKAGES[*]}
# Install vim-plug
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
set_gnome_settings
set_firefox_settings