Initial commit

This commit is contained in:
Petar Kapriš 2025-04-16 21:35:52 +02:00
commit 48c4579e99
2 changed files with 416 additions and 0 deletions

338
larbs.sh Normal file
View file

@ -0,0 +1,338 @@
#!/bin/sh
### Brief install instructions for convenience ###
# Partition disk:
# cfdisk /dev/nvme0n1
#
# Format paritions:
# example:
# mkfs.ext4 -L ROOT /dev/sda2
# mkfs.ext4 -L HOME /dev/sda3
# mkfs.ext4 -L BOOT /dev/sda1
# mkswap -L SWAP /dev/sda4
#
# mkfs.fat -F 32 /dev/sda1
# fatlabel /dev/sda1 ESP
# swapon /dev/disk/by-label/SWAP
# mount /dev/disk/by-label/ROOT /mnt
# mkdir /mnt/boot
# mkdir /mnt/home
# mount /dev/disk/by-label/HOME /mnt/home
# mount /dev/disk/by-label/BOOT /mnt/boot
# mkdir /mnt/boot/efi
# mount /dev/disk/by-label/ESP /mnt/boot/efi
#
# Connect through wifi:
# iwctl
# ping artixlinux.org
#
# Update system clock:
# rc-service ntpd start
#
# Install the base system and kernel:
# basestrap /mnt base base-devel openrc elogind-openrc
# basestrap /mnt linux linux-firmware
#
# Generate file system table:
# fstabgen -U /mnt >> /mnt/etc/fstab
# # (verify the fstab file)
#
# Enter new system:
# artix-chroot /mnt
#
# Configure system clock:
# ln -sf /usr/share/zoneinfo/Europe/Belgrade /etc/localtime
# hwclock --systohc
#
# Enable locales:
# pacman -S vim
# vim /etc/locale.gen
# locale-gen
#
# Install boot loader:
# pacman -S grub os-prober efibootmgr
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
# grub-mkconfig -o /boot/grub/grub.cfg
#
# Add users:
# (set root passwd)
# passwd
#
# useradd -m kappa
# passwd kappa
#
# Network config: (maybe this should be changed for network manager)
# vim /etc/hostname # add a hostname
# vim /etc/hosts
# # 127.0.0.1 localhost
# # ::1 localhost
# # 127.0.1.1 myhostname.localdomain myhostname
# vim /etc/conf.d/hostname
# hostname="myhostname"
#
# pacman -S dhcpcd iwd dhcpcd-openrc iwd-openrc
# rc-update add dhcpcd
# rc-update add iwd
#
# Reboot system:
# exit
# umount -R /mnt
# reboot
# Luke's Auto Rice Bootstrapping Script (LARBS)
# by Luke Smith <luke@lukesmith.xyz>
# License: GNU GPLv3
### OPTIONS AND VARIABLES ###
progsfile="https://raw.githubusercontent.com/LukeSmithxyz/LARBS/master/static/progs.csv"
aurhelper="yay"
export TERM=ansi
### FUNCTIONS ###
installpkg() {
pacman --noconfirm --needed -S "$1" >/dev/null 2>&1
}
error() {
# Log to stderr and exit with failure.
printf "%s\n" "$1" >&2
exit 1
}
welcomemsg() {
whiptail --title "Welcome!" \
--msgbox "Welcome to Luke's Auto-Rice Bootstrapping Script!\\n\\nThis script will automatically install a fully-featured Linux desktop, which I use as my main machine.\\n\\n-Luke" 10 60
whiptail --title "Important Note!" --yes-button "All ready!" \
--no-button "Return..." \
--yesno "Be sure the computer you are using has current pacman updates and refreshed Arch keyrings.\\n\\nIf it does not, the installation of some programs might fail." 8 70
}
getuserandpass() {
# Prompts user for new username and password.
name=$(whiptail --inputbox "First, please enter a name for the user account." 10 60 3>&1 1>&2 2>&3 3>&1) || exit 1
while ! echo "$name" | grep -q "^[a-z_][a-z0-9_-]*$"; do
name=$(whiptail --nocancel --inputbox "Username not valid. Give a username beginning with a letter, with only lowercase letters, - or _." 10 60 3>&1 1>&2 2>&3 3>&1)
done
pass1=$(whiptail --nocancel --passwordbox "Enter a password for that user." 10 60 3>&1 1>&2 2>&3 3>&1)
pass2=$(whiptail --nocancel --passwordbox "Retype password." 10 60 3>&1 1>&2 2>&3 3>&1)
while ! [ "$pass1" = "$pass2" ]; do
unset pass2
pass1=$(whiptail --nocancel --passwordbox "Passwords do not match.\\n\\nEnter password again." 10 60 3>&1 1>&2 2>&3 3>&1)
pass2=$(whiptail --nocancel --passwordbox "Retype password." 10 60 3>&1 1>&2 2>&3 3>&1)
done
}
usercheck() {
! { id -u "$name" >/dev/null 2>&1; } ||
whiptail --title "WARNING" --yes-button "CONTINUE" \
--no-button "No wait..." \
--yesno "The user \`$name\` already exists on this system. LARBS can install for a user already existing.\\n\\nLARBS will change $name's password to the one you just gave." 14 70
}
preinstallmsg() {
whiptail --title "Let's get this party started!" --yes-button "Let's go!" \
--no-button "No, nevermind!" \
--yesno "The rest of the installation will now be totally automated, so you can sit back and relax.\\n\\nIt will take some time, but when done, you can relax even more with your complete system.\\n\\nNow just press <Let's go!> and the system will begin installation!" 13 60 || {
clear
exit 1
}
}
adduserandpass() {
# Adds user `$name` with password $pass1.
whiptail --infobox "Adding user \"$name\"..." 7 50
useradd -m -g wheel -s /bin/zsh "$name" >/dev/null 2>&1 ||
usermod -a -G wheel "$name" && mkdir -p /home/"$name" && chown "$name":wheel /home/"$name"
export repodir="/home/$name/.local/src"
mkdir -p "$repodir"
chown -R "$name":wheel "$(dirname "$repodir")"
echo "$name:$pass1" | chpasswd
unset pass1 pass2
}
refreshkeys() {
case "$(readlink -f /sbin/init)" in
*systemd*) # May end up removing the Arch option
whiptail --infobox "Refreshing Arch Keyring..." 7 40
pacman --noconfirm -S archlinux-keyring >/dev/null 2>&1
;;
*)
whiptail --infobox "Enabling Arch Repositories for more a more extensive software collection..." 7 40
pacman --noconfirm --needed -S \
artix-keyring artix-archlinux-support >/dev/null 2>&1
grep -q "^\[extra\]" /etc/pacman.conf ||
echo "[extra]
Include = /etc/pacman.d/mirrorlist-arch" >>/etc/pacman.conf
pacman -Sy --noconfirm >/dev/null 2>&1
pacman-key --populate archlinux >/dev/null 2>&1
;;
esac
}
manualinstall() {
# Installs $1 manually. Used only for AUR helper here.
# Should be run after repodir is created and var is set.
pacman -Qq "$1" && return 0
whiptail --infobox "Installing \"$1\" manually." 7 50
sudo -u "$name" mkdir -p "$repodir/$1"
sudo -u "$name" git -C "$repodir" clone --depth 1 --single-branch \
--no-tags -q "https://aur.archlinux.org/$1.git" "$repodir/$1" ||
{
cd "$repodir/$1" || return 1
sudo -u "$name" git pull --force origin master
}
cd "$repodir/$1" || exit 1
sudo -u "$name" \
makepkg --noconfirm -si >/dev/null 2>&1 || return 1
}
maininstall() {
# Installs all needed programs from main repo.
whiptail --title "LARBS Installation" --infobox "Installing \`$1\` ($n of $total). $1 $2" 9 70
installpkg "$1"
}
gitmakeinstall() {
progname="${1##*/}"
progname="${progname%.git}"
dir="$repodir/$progname"
whiptail --title "LARBS Installation" \
--infobox "Installing \`$progname\` ($n of $total) via \`git\` and \`make\`. $(basename "$1") $2" 8 70
sudo -u "$name" git -C "$repodir" clone --depth 1 --single-branch \
--no-tags -q "$1" "$dir" ||
{
cd "$dir" || return 1
sudo -u "$name" git pull --force origin master
}
cd "$dir" || exit 1
make >/dev/null 2>&1
make install >/dev/null 2>&1
cd /tmp || return 1
}
aurinstall() {
whiptail --title "LARBS Installation" \
--infobox "Installing \`$1\` ($n of $total) from the AUR. $1 $2" 9 70
echo "$aurinstalled" | grep -q "^$1$" && return 1
sudo -u "$name" $aurhelper -S --noconfirm "$1" >/dev/null 2>&1
}
pipinstall() {
whiptail --title "LARBS Installation" \
--infobox "Installing the Python package \`$1\` ($n of $total). $1 $2" 9 70
[ -x "$(command -v "pip")" ] || installpkg python-pip >/dev/null 2>&1
yes | pip install "$1"
}
installationloop() {
([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) ||
curl -Ls "$progsfile" | sed '/^#/d' >/tmp/progs.csv
total=$(wc -l </tmp/progs.csv)
aurinstalled=$(pacman -Qqm)
while IFS=, read -r tag program comment; do
n=$((n + 1))
echo "$comment" | grep -q "^\".*\"$" &&
comment="$(echo "$comment" | sed -E "s/(^\"|\"$)//g")"
case "$tag" in
"A") aurinstall "$program" "$comment" ;;
"G") gitmakeinstall "$program" "$comment" ;;
"P") pipinstall "$program" "$comment" ;; # Will likely remain unused
*) maininstall "$program" "$comment" ;;
esac
done </tmp/progs.csv
}
finalize() {
whiptail --title "All done!" \
--msgbox "Congrats! Provided there were no hidden errors, the script completed successfully and all the programs and configuration files should be in place.\\n\\nTo run the new graphical environment, log out and log back in as your new user, then run the command \"startx\" to start the graphical environment (it will start automatically in tty1).\\n\\n.t Luke" 13 80
}
### THE ACTUAL SCRIPT ###
### This is how everything happens in an intuitive format and order.
# Check if user is root on Arch distro. Install whiptail.
pacman --noconfirm --needed -Sy libnewt ||
error "Are you sure you're running this as the root user, are on an Arch-based distribution and have an internet connection?"
# Welcome user and pick dotfiles.
welcomemsg || error "User exited."
# Get and verify username and password.
getuserandpass || error "User exited."
# Give warning if user already exists.
usercheck || error "User exited."
# Last chance for user to back out before install.
preinstallmsg || error "User exited."
### The rest of the script requires no user input.
# Refresh Arch keyrings.
refreshkeys ||
error "Error automatically refreshing Arch keyring. Consider doing so manually."
for x in curl ca-certificates base-devel git ntp zsh dash; do
whiptail --title "LARBS Installation" \
--infobox "Installing \`$x\` which is required to install and configure other programs." 8 70
installpkg "$x"
done
whiptail --title "LARBS Installation" \
--infobox "Synchronizing system time to ensure successful and secure installation of software..." 8 70
ntpd -q -g >/dev/null 2>&1
adduserandpass || error "Error adding username and/or password."
[ -f /etc/sudoers.pacnew ] && cp /etc/sudoers.pacnew /etc/sudoers # Just in case
# Allow user to run sudo without password. Since AUR programs must be installed
# in a fakeroot environment, this is required for all builds with AUR.
trap 'rm -f /etc/sudoers.d/larbs-temp' HUP INT QUIT TERM PWR EXIT
echo "%wheel ALL=(ALL) NOPASSWD: ALL
Defaults:%wheel,root runcwd=*" >/etc/sudoers.d/larbs-temp
# Make pacman colorful, concurrent downloads and Pacman eye-candy.
grep -q "ILoveCandy" /etc/pacman.conf || sed -i "/#VerbosePkgLists/a ILoveCandy" /etc/pacman.conf
sed -Ei "s/^#(ParallelDownloads).*/\1 = 5/;/^#Color$/s/#//" /etc/pacman.conf
# Use all cores for compilation.
sed -i "s/-j2/-j$(nproc)/;/^#MAKEFLAGS/s/^#//" /etc/makepkg.conf
manualinstall $aurhelper || error "Failed to install AUR helper."
# Make sure .*-git AUR packages get updated automatically.
$aurhelper -Y --save --devel
# The command that does all the installing. Reads the progs.csv file and
# installs each needed program the way required. Be sure to run this only after
# the user has been created and has priviledges to run sudo without a password
# and all build dependencies are installed.
installationloop
# Most important command! Get rid of the beep!
rmmod pcspkr
echo "blacklist pcspkr" >/etc/modprobe.d/nobeep.conf
# dbus UUID must be generated for Artix runit.
dbus-uuidgen >/var/lib/dbus/machine-id
# Allow wheel users to sudo with password and allow several system commands
# (like `shutdown` to run without password).
echo "%wheel ALL=(ALL:ALL) ALL" >/etc/sudoers.d/00-larbs-wheel-can-sudo
echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/reboot,/usr/bin/systemctl suspend,/usr/bin/wifi-menu,/usr/bin/mount,/usr/bin/umount,/usr/bin/pacman -Syu,/usr/bin/pacman -Syyu,/usr/bin/pacman -Syyu --noconfirm,/usr/bin/loadkeys,/usr/bin/pacman -Syyuw --noconfirm,/usr/bin/pacman -S -y --config /etc/pacman.conf --,/usr/bin/pacman -S -y -u --config /etc/pacman.conf --" >/etc/sudoers.d/01-larbs-cmds-without-password
echo "Defaults editor=/usr/bin/nvim" >/etc/sudoers.d/02-larbs-visudo-editor
mkdir -p /etc/sysctl.d
echo "kernel.dmesg_restrict = 0" > /etc/sysctl.d/dmesg.conf
# Cleanup
rm -f /etc/sudoers.d/larbs-temp
# Last message! Install complete!
finalize

78
progs.csv Normal file
View file

@ -0,0 +1,78 @@
#TAG,NAME IN REPO (or git url),PURPOSE (should be a verb phrase to sound right while installing)
,xorg-server,"is the graphical server. This first one may take a while as it pulls many other dependencies first on clean installs."
,xorg-xwininfo,"allows querying information about windows."
,xorg-xinit,"starts the graphical server."
,xorg-xset,"utility for configuring and ajusting X server"
,polkit,"manages user policies."
,otf-libertinus,"provides the sans and serif fonts for LARBS."
,ttf-font-awesome,"provides extended glyph support."
,ttf-dejavu,"properly displays emojis."
A,lf-git,"is an extensive terminal file manager that everyone likes."
,ueberzugpp,"enables previews in the lf file manager."
,bc,"is a mathematics language used for the dropdown calculator."
,xcompmgr,"is for transparency and removing screen-tearing."
,xorg-xprop,"is a tool for detecting window properties."
,arandr,"allows the user to customize monitor arrangements."
,dosfstools,"allows your computer to access dos-like filesystems."
,libnotify,"allows desktop notifications."
,dunst,"is a suckless notification system."
,calcurse,"terminal-based organizer for interactive and command line use"
,exfat-utils,"allows management of FAT drives."
,nsxiv,"is a minimalist image viewer."
,xwallpaper,"sets the wallpaper."
,ffmpeg,"can record and splice video and audio on the command line."
,ffmpegthumbnailer,"creates thumbnail previews of video files."
,gnome-keyring,"serves as the system keyring."
A,gtk-theme-arc-gruvbox-git,"gives the dark GTK theme used in LARBS."
,python-qdarkstyle,"provides a dark Qt theme."
,neovim,"a tidier vim with some useful features"
,mpd,"is a lightweight music daemon."
,mpc,"is a terminal interface for mpd."
,mpv,"is the patrician's choice video player."
,man-db,"lets you read man pages of programs."
,ncmpcpp,"a ncurses interface for music with multiple formats and a powerful tag editor."
,newsboat,"is a terminal RSS client."
A,librewolf-bin,"is the default browser of LARBS which also comes with ad-blocking and other sensible and necessary features by default."
A,librewolf-extension-localcdn-bin,"local emulation of Content Delivery Networks."
A,librewolf-extension-istilldontcareaboutcookies-bin,"removes annoying cookie banners"
A,librewolf-extension-tridactyl-bin,"vim bindings in your browser."
A,librewolf-extension-ublock-origin-bin,"the best ad blocker in town."
A,arkenfox-user.js,"provides hardened security settings for Firefox and Librewolf to avoid Mozilla spyware and general web fingerprinting."
,noto-fonts,"is an expansive font package."
,noto-fonts-emoji,"is an emoji font."
,ntfs-3g,"allows accessing NTFS partitions."
,wireplumber,"is the audio system."
,pipewire-pulse,"gives pipewire compatibility with PulseAudio programs."
,pulsemixer,"is an audio controller."
A,sc-im,"is an Excel-like terminal spreadsheet manager."
,maim,"can take quick screenshots at your request."
A,abook,"is an offline addressbook usable by neomutt."
,unclutter,"hides an inactive mouse."
,unzip,"unzips zips."
,lynx,"is a terminal browser also used in LARBS for generating in-terminal previews of websites, emails and HTML files."
,xcape,"gives the special escape/super mappings of LARBS."
,xclip,"allows for copying and pasting from the command line."
,xdotool,"provides window action utilities on the command line."
,yt-dlp,"can download any YouTube video (or playlist or channel) when given the link."
,zathura,"is a pdf viewer with vim-like bindings."
,zathura-pdf-mupdf,"allows mupdf pdf compatibility in zathura."
,poppler,"manipulates .pdfs and gives .pdf previews and other .pdf functions."
,mediainfo,"shows audio and video information and is used in the file browser."
,atool,"manages and gives information about archives."
,fzf,"is a fuzzy finder tool used for easy selection and location of files."
,bat,"can highlight code output and display files and is used to generate previews in the file browser."
,xorg-xbacklight,"enables changing screen brightness levels."
A,zsh-fast-syntax-highlighting-git,"provides syntax highlighting in the shell."
A,task-spooler,"queues commands or files for download."
A,simple-mtpfs,"enables the mounting of cell phones."
A,htop-vim,"is a graphical and colorful system monitor."
G,https://github.com/LukeSmithxyz/dwmblocks.git,"serves as the modular status bar."
G,https://github.com/lukesmithxyz/dmenu.git,"runs commands and provides a UI for selection."
G,https://github.com/lukesmithxyz/st.git,"is my custom build of suckless's terminal emulator."
G,https://github.com/lukesmithxyz/dwm.git,"is the window manager."
A,mutt-wizard-git,"is a light-weight terminal-based email system."
,slock,"allows you to lock your computer, and quickly unlock with your password."
,socat,"is a utility which establishes two byte streams and transfers data between them."
,moreutils,"is a collection of useful unix tools."
,tesseract,"command-line OCR engine for advance maimpick"
,tesseract-data-eng,"english language pack for OCR"
1 #TAG NAME IN REPO (or git url) PURPOSE (should be a verb phrase to sound right while installing)
2 xorg-server is the graphical server. This first one may take a while as it pulls many other dependencies first on clean installs.
3 xorg-xwininfo allows querying information about windows.
4 xorg-xinit starts the graphical server.
5 xorg-xset utility for configuring and ajusting X server
6 polkit manages user policies.
7 otf-libertinus provides the sans and serif fonts for LARBS.
8 ttf-font-awesome provides extended glyph support.
9 ttf-dejavu properly displays emojis.
10 A lf-git is an extensive terminal file manager that everyone likes.
11 ueberzugpp enables previews in the lf file manager.
12 bc is a mathematics language used for the dropdown calculator.
13 xcompmgr is for transparency and removing screen-tearing.
14 xorg-xprop is a tool for detecting window properties.
15 arandr allows the user to customize monitor arrangements.
16 dosfstools allows your computer to access dos-like filesystems.
17 libnotify allows desktop notifications.
18 dunst is a suckless notification system.
19 calcurse terminal-based organizer for interactive and command line use
20 exfat-utils allows management of FAT drives.
21 nsxiv is a minimalist image viewer.
22 xwallpaper sets the wallpaper.
23 ffmpeg can record and splice video and audio on the command line.
24 ffmpegthumbnailer creates thumbnail previews of video files.
25 gnome-keyring serves as the system keyring.
26 A gtk-theme-arc-gruvbox-git gives the dark GTK theme used in LARBS.
27 python-qdarkstyle provides a dark Qt theme.
28 neovim a tidier vim with some useful features
29 mpd is a lightweight music daemon.
30 mpc is a terminal interface for mpd.
31 mpv is the patrician's choice video player.
32 man-db lets you read man pages of programs.
33 ncmpcpp a ncurses interface for music with multiple formats and a powerful tag editor.
34 newsboat is a terminal RSS client.
35 A librewolf-bin is the default browser of LARBS which also comes with ad-blocking and other sensible and necessary features by default.
36 A librewolf-extension-localcdn-bin local emulation of Content Delivery Networks.
37 A librewolf-extension-istilldontcareaboutcookies-bin removes annoying cookie banners
38 A librewolf-extension-tridactyl-bin vim bindings in your browser.
39 A librewolf-extension-ublock-origin-bin the best ad blocker in town.
40 A arkenfox-user.js provides hardened security settings for Firefox and Librewolf to avoid Mozilla spyware and general web fingerprinting.
41 noto-fonts is an expansive font package.
42 noto-fonts-emoji is an emoji font.
43 ntfs-3g allows accessing NTFS partitions.
44 wireplumber is the audio system.
45 pipewire-pulse gives pipewire compatibility with PulseAudio programs.
46 pulsemixer is an audio controller.
47 A sc-im is an Excel-like terminal spreadsheet manager.
48 maim can take quick screenshots at your request.
49 A abook is an offline addressbook usable by neomutt.
50 unclutter hides an inactive mouse.
51 unzip unzips zips.
52 lynx is a terminal browser also used in LARBS for generating in-terminal previews of websites, emails and HTML files.
53 xcape gives the special escape/super mappings of LARBS.
54 xclip allows for copying and pasting from the command line.
55 xdotool provides window action utilities on the command line.
56 yt-dlp can download any YouTube video (or playlist or channel) when given the link.
57 zathura is a pdf viewer with vim-like bindings.
58 zathura-pdf-mupdf allows mupdf pdf compatibility in zathura.
59 poppler manipulates .pdfs and gives .pdf previews and other .pdf functions.
60 mediainfo shows audio and video information and is used in the file browser.
61 atool manages and gives information about archives.
62 fzf is a fuzzy finder tool used for easy selection and location of files.
63 bat can highlight code output and display files and is used to generate previews in the file browser.
64 xorg-xbacklight enables changing screen brightness levels.
65 A zsh-fast-syntax-highlighting-git provides syntax highlighting in the shell.
66 A task-spooler queues commands or files for download.
67 A simple-mtpfs enables the mounting of cell phones.
68 A htop-vim is a graphical and colorful system monitor.
69 G https://github.com/LukeSmithxyz/dwmblocks.git serves as the modular status bar.
70 G https://github.com/lukesmithxyz/dmenu.git runs commands and provides a UI for selection.
71 G https://github.com/lukesmithxyz/st.git is my custom build of suckless's terminal emulator.
72 G https://github.com/lukesmithxyz/dwm.git is the window manager.
73 A mutt-wizard-git is a light-weight terminal-based email system.
74 slock allows you to lock your computer, and quickly unlock with your password.
75 socat is a utility which establishes two byte streams and transfers data between them.
76 moreutils is a collection of useful unix tools.
77 tesseract command-line OCR engine for advance maimpick
78 tesseract-data-eng english language pack for OCR