1
0
Fork 0

reorganize everything

pull/1/head
overlisted 2 years ago
parent 33e6a7f0ed
commit 2e0e619851
Signed by: me
GPG Key ID: 1ACCDCC0429C9737

@ -1,23 +1,37 @@
![Logo](./logo.png)
# rach lunx
The most Arch Linux installer
## Disclaimer
please don't be mad at me if this script deletes something important
## How
## Usage
0. Choose a [custom script](./custom) (optional)
1. Boot into the Arch installer image
2. `mkcd /tmp/rach`
3. `curl overli.st/rach | tar -xz && ./rach.sh <disk>`
4. Install your microcode and [configure the timezone, locales and the hostname](https://wiki.archlinux.org/title/Installation_guide#Time_zone)
3. `curl overli.st/rach | tar -xz && ./rach.sh base <disk>`
4. [Configure the timezone, locales and the hostname](https://wiki.archlinux.org/title/Installation_guide#Time_zone)
5. Ctrl + D
6. `reboot`
7. Log in as root with the password `1`
8. `/usr/share/rach/rachuser.sh <username>`
6. Log in as `root`
7. `/usr/share/rach/rach.sh userspace <username> [custom script]`
## Design
## Why
h
The whole installer is built in a way that allows for very easy debugging. By
simply sourcing the `tasks.sh` file, you get immediate access to all the
individual steps of the installation process.
All tasks are prefixes with one of the following environments:
- `iso`: Shell that you get in the installer ISO image
- `chroot`: Chroot shell inside of the half-baked system root
- `root`: Root shell in the booted system
- `user`: User shell in the booted system
## Custom
Feel free to send me pull requests with your own `custom/` scripts

@ -1,2 +1,2 @@
export CUSTOM_YAY="$CUSTOM_YAY
custom_yay="$custom_yay
extra/mesa extra/amdvlk extra/libva-mesa-driver"

@ -1,2 +1,2 @@
export CUSTOM_YAY="$CUSTOM_YAY
custom_yay="$custom_yay
extra/gst-libav extra/ffmpeg"

@ -1,4 +1,4 @@
export CUSTOM_YAY="$CUSTOM_YAY
custom_yay="$custom_yay
aur/adwaita-qt
extra/gnome-session extra/gdm extra/gnome-control-center
extra/xdg-user-dirs-gtk extra/gnome-terminal extra/gnome-software
@ -9,4 +9,4 @@ export CUSTOM_YAY="$CUSTOM_YAY
extra/pipewire-pulse extra/pipewire-jack extra/wireplumber extra/dconf-editor
extra/nautilus"
export CUSTOM_ENABLE=gdm
custom_enable=gdm

@ -1,4 +1,4 @@
export CUSTOM_SHELL=/bin/zsh
custom_shell=/bin/zsh
export CUSTOM_YAY="$CUSTOM_YAY
custom_yay="$custom_yay
extra/zsh"

@ -1,9 +1,12 @@
export CUSTOM_SHELL=/bin/sh
custom_shell=/bin/sh
export CUSTOM_YAY="$CUSTOM_YAY
custom_yay="$custom_yay
"
export CUSTOM_FLATPAK="$CUSTOM_FLATPAK
custom_flatpak="$custom_flatpak
"
custom_enable="$custom_enable
"
function custom_post() {

@ -3,7 +3,7 @@ source .base_amdgpu.sh
source .base_codecs.sh
source .base_zsh.sh
export CUSTOM_YAY="$CUSTOM_YAY
custom_yay="$custom_yay
aur/vscodium-bin aur/ttf-twemoji aur/nerd-fonts-jetbrains-mono
community/neovim community/virt-manager community/ttf-dejavu community/rustup
community/inter-font community/glfw-wayland
@ -12,7 +12,7 @@ export CUSTOM_YAY="$CUSTOM_YAY
extra/noto-fonts extra/qemu extra/noto-fonts-cjk
multilib/steam"
export CUSTOM_FLATPAK="$CUSTOM_FLATPAK
custom_flatpak="$custom_flatpak
org.gnome.Weather//stable
org.gnome.Epiphany.Devel//
org.telegram.desktop//beta

@ -1,81 +1,49 @@
#!/bin/bash
# Usage:
# rach.sh <disk>
# disk - Target disk (/dev/sda)
set -e
PKG_KERNEL="linux-zen linux-firmware amd-ucode intel-ucode"
PKG_SYSTEM="base dbus-broker networkmanager ufw flatpak libvirt zram-generator"
PKG_PROGRAMS="opendoas wget curl git nano rsync docker"
PKG_DEVEL="linux-zen-headers base-devel go"
PACKAGES="$PKG_KERNEL $PKG_SYSTEM $PKG_DEVEL $PKG_PROGRAMS"
ENABLE="systemd-resolved systemd-homed NetworkManager avahi-daemon libvirtd ufw
docker"
RACH=/usr/share/rach
if [ $1 = "chrooted" ]; then
bootctl install
cp $RACH/systemd-boot/loader.conf /boot/loader/
cp $RACH/systemd-boot/arch.conf /boot/loader/entries/
systemctl disable dbus
systemctl enable dbus-broker $ENABLE
ln -sf /usr/bin/doas /usr/bin/sudo
cp $RACH/doas.conf /etc/doas.conf
chmod 0400 /etc/doas.conf
# zram-generator enables itself
cp $RACH/zram-generator.conf /etc/systemd/zram-generator.conf
cat $RACH/pacman.conf.append >> /etc/pacman.conf
pacman -Sy
usermod --password $(echo 1 | openssl passwd -1 -stdin) root
if [ -d /usr/share/rach ]; then
rach=/usr/share/rach
else
export EFI_PART=1
export ROOT_PART=2
function fdisk_commands() {
echo "g"
echo "n"
echo "$EFI_PART" # part num
echo "" # first sector
echo "+256M" # last sector
echo "t"
# echo "$EFI_PART" # part num
echo "1" # type number
echo "n"
echo "$ROOT_PART" # part num
echo "" # first sector
echo "" # last sector
echo "t"
echo "$ROOT_PART" # part num
echo "23" # type number
echo "w"
}
fdisk_commands | fdisk -W always $1 # -W gets rid of that annoying y/n prompt
mkfs.vfat $1$EFI_PART
mkfs.ext4 $1$ROOT_PART -L archroot
mount $1$ROOT_PART /mnt
mkdir /mnt/boot
mount $1$EFI_PART /mnt/boot
pacstrap /mnt $PACKAGES
genfstab -U /mnt >> /mnt/etc/fstab
rach=$(pwd)
fi
mv /tmp/rach /mnt/$RACH
arch-chroot /mnt $RACH/rach.sh chrooted
arch-chroot /mnt # interactive
source $rach/tasks.sh
function task() {
printf "%s\n===> %8s $2\n\n" "$(tput setaf 9)" "($1)"
$1_$2 ${@:3}
}
if [ $1 = "base" ]; then
task iso partitions $2
task iso packages
task iso fstab
task iso usr_rach
task iso chroot "/usr/share/rach/rach.sh _chrooted"
task iso chroot
task iso reboot
elif [ $1 = "userspace" ]; then
task root root_pass
task root home_save $2
task root user $2
task root ufw
task root ntp
task root flatpak
task root login $2 $rach/rach.sh _logged_in
echo "\n\n\nReboot whenever you're ready."
elif [ $1 = "_chrooted" ]; then
task chroot systemd_boot
task chroot services
task chroot doas
task chroot zram
task chroot pacman
task chroot root_pass
elif [ $1 = "_logged_in" ]; then
task user load_custom $2
task user yay $custom_yay
task user flatpak $custom_flatpak
task user enable $custom_enable
task user shell $custom_shell
fi

@ -1,49 +0,0 @@
#!/bin/bash
# Usage:
# rachlogin.sh [custom]
# custom - Path to the custom config script
set -e
RACH=/usr/share/rach
FLATPAK_REPOS=(
"flathub https://flathub.org/repo/flathub.flatpakrepo"
"flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo"
"gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo"
"webkit https://software.igalia.com/flatpak-refs/webkit-sdk.flatpakrepo"
)
if [ -z $1 ]; then
source $RACH/custom/noop.sh
else
PATH="$PATH:$RACH/custom" source $RACH/custom/$1
fi
cd /tmp
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si --noconfirm
yay --noconfirm --sudo doas -S archlinux-keyring
yay --noconfirm -R sudo || sudo rm /usr/bin/sudo
yay --noconfirm --sudo doas -S aur/yay aur/opendoas-sudo $CUSTOM_YAY
for ((i = 0; i < ${#FLATPAK_REPOS[@]}; i++)); do
flatpak remote-add --user --if-not-exists ${FLATPAK_REPOS[$i]}
done
# i don't want any apps accidentally getting installed under root
sudo flatpak remote-delete flathub && echo "Removed root flathub"
for app in $CUSTOM_FLATPAK; do
flatpak install --noninteractive --user $app
done
custom_post
[ -z "$CUSTOM_ENABLE" ] || sudo systemctl enable $CUSTOM_ENABLE
homectl update $(whoami) --shell=$CUSTOM_SHELL
sudo reboot now

@ -1,29 +0,0 @@
#!/bin/bash
# Usage:
# rachuser.sh <username> [custom]
# username - Username of the created user
# custom - Path to the custom config script
set -e
RACH=/usr/share/rach
passwd -d root
mv /home/$1 /home/$1.old && echo "Moved old home"
groupadd docker && echo "Created group docker"
homectl create \
--storage=directory \
--member-of=libvirt \
--member-of=docker \
--member-of=wheel \
$1
ufw enable
timedatectl set-ntp true
homectl activate $1
# i hate this
echo "Please run machinectl shell --uid $(id -u $1) and $RACH/rachlogin.sh (optionally with the name of the custom config)"
homectl with $1 sh

@ -0,0 +1,207 @@
### iso
# $1 - disk device
function iso_partitions() {
efi_part=1
root_part=2
function fdisk_commands() {
echo "g"
echo "n"
echo "$efi_part" # part num
echo "" # first sector
echo "+256M" # last sector
echo "t"
# echo "$efi_part" # part num
echo "1" # type number
echo "n"
echo "$root_part" # part num
echo "" # first sector
echo "" # last sector
echo "t"
echo "$root_part" # part num
echo "23" # type number
echo "w"
}
fdisk_commands | fdisk -W always $1 # -W gets rid of that annoying y/n prompt
mkfs.vfat $1$efi_part
mkfs.ext4 $1$root_part -L archroot
mount $1$root_part /mnt
mkdir /mnt/boot
mount $1$efi_part /mnt/boot
}
function iso_packages() {
packages=(
linux-zen linux-firmware amd-ucode intel-ucode
base dbus-broker networkmanager ufw flatpak libvirt zram-generator
opendoas wget curl git nano rsync docker
linux-zen-headers base-devel go
)
pacstrap /mnt ${packages[@]}
}
function iso_fstab() {
genfstab -U /mnt >> /mnt/etc/fstab
}
function iso_usr_rach() {
cp -r $rach /mnt/usr/share/rach
}
# $:1 - execv command to run
function iso_chroot() {
arch-chroot /mnt ${@:1}
}
function iso_reboot() {
reboot
}
### chroot
function chroot_systemd_boot() {
bootctl install
cp $rach/systemd-boot/loader.conf /boot/loader
cp $rach/systemd-boot/arch.conf /boot/loader/entries
}
function chroot_services() {
services=(
systemd-resolved systemd-homed NetworkManager avahi-daemon libvirtd ufw
docker
)
systemctl disable dbus
systemctl enable dbus-broker ${services[@]}
}
function chroot_doas() {
ln -sf /usr/bin/doas /usr/bin/sudo
cp $rach/doas.conf /etc/doas.conf
chmod 0400 /etc/doas.conf
}
function chroot_zram() {
# zram-generator enables itself
cp $rach/zram-generator.conf /etc/systemd/zram-generator.conf
}
function chroot_pacman() {
cat $rach/pacman.conf.append >> /etc/pacman.conf
pacman -Sy
}
function chroot_root_pass() {
passwd -d root
}
### root
function root_root_pass() {
passwd -l root
}
# $1 - dir name
function root_home_save() {
mv /home/$1 /home/$1.old || :
}
# $1 - username
function root_user() {
groupadd libvirt || :
groupadd docker || :
groupadd wheel || :
homectl create \
--storage=directory \
--member-of=libvirt \
--member-of=docker \
--member-of=wheel \
$1
}
function root_ufw() {
ufw enable
}
function root_ntp() {
timedatectl set-ntp true
}
function root_flatpak() {
flatpak remote-delete flathub || :
}
# $1 - username
# $:2 - execv command to run
function root_login() {
homectl activate $1
# sudo deactivates the homedir without this
# and all session services mess up too
machinectl shell $1@.host ${@:2}
}
### user
# $1 - script name
function user_load_custom() {
cd $rach/custom
if [ -z $1 ]; then
source noop.sh
else
source $1.sh
fi
}
# $1 - packages
function user_yay() {
cd /tmp
git clone https://aur.archlinux.org/yay.git || :
cd yay
makepkg -si --noconfirm
yay --noconfirm --sudo doas -S archlinux-keyring
yay --noconfirm --sudo doas -R sudo || sudo rm /usr/bin/sudo
yay --noconfirm --sudo doas -S aur/yay aur/opendoas-sudo $1
}
# $1 - flatpak refs
function user_flatpak() {
repos=(
"flathub https://flathub.org/repo/flathub.flatpakrepo"
"flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo"
"gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo"
"webkit https://software.igalia.com/flatpak-refs/webkit-sdk.flatpakrepo"
)
for ((i = 0; i < ${#repos[@]}; i++)); do
flatpak remote-add --user --if-not-exists ${repos[$i]}
done
sudo flatpak remote-delete flathub || :
for app in $1; do
flatpak install --noninteractive --user $app
done
}
# $1 - service names
function user_enable() {
[ -z "$1" ] sudo systemctl enable $1
}
# $1 - shell program
function user_shell() {
[ -z "$1" ] homectl update $(whoami) --shell=$custom_shell
}
Loading…
Cancel
Save