Browse Source

Initial commit

master
Dmitry Zakharchenko 6 months ago
commit
e3a07a0104
  1. 176
      larbs.sh
  2. 76
      progs.csv

176
larbs.sh

@ -0,0 +1,176 @@
#!/bin/sh
# Luke's Auto Rice Boostrapping Script (LARBS)
# by Adrian Claridge <am_claridge@icloud.com>
# License: GNU GPLv3
### OPTIONS AND VARIABLES ###
while getopts ":a:r:b:p:h" o; do case "${o}" in
h) printf "Optional arguments for custom use:\\n -r: Dotfiles repository (local file or url)\\n -p: Dependencies and programs csv (local file or url)\\n -h: Show this message\\n" && exit ;;
r) dotfilesrepo=${OPTARG} && git ls-remote "$dotfilesrepo" || exit ;;
b) repobranch=${OPTARG} ;;
p) progsfile=${OPTARG} ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && exit ;;
esac done
[ -z "$dotfilesrepo" ] && dotfilesrepo="https://github.com/dm1tz/dots.git"
[ -z "$progsfile" ] && progsfile="https://raw.githubusercontent.com/dm1tz/dots/master/.local/share/larbs/progs.csv"
[ -z "$repobranch" ] && repobranch="master"
### FUNCTIONS ###
installpkg(){ xbps-install -y "$1" >/dev/null 2>&1 ;}
grepseq="\"^[PGV]*,\""
error() { clear; printf "ERROR:\\n%s\\n" "$1"; exit;}
welcomemsg() { \
dialog --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-Adrian" 10 60
}
getuser() { \
# Prompts user for their username.
name=$(dialog --inputbox "First, please enter the username you created during the Void Linux install process." 10 60 3>&1 1>&2 2>&3 3>&1) || exit
repodir="/home/$name/.local/src"; sudo -u $name mkdir -p "$repodir"
while ! echo "$name" | grep "^[a-z_][a-z0-9_-]*$" >/dev/null 2>&1; do
name=$(dialog --no-cancel --inputbox "Username not valid. Be sure your username contains valid characters: lowercase letters, - or _." 10 60 3>&1 1>&2 2>&3 3>&1)
done ;}
preinstallmsg() { \
dialog --title "Enter The Void..." --yes-label "Let's go!" --no-label "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; }
}
maininstall() { # Installs all needed programs from main repo.
dialog --title "LARBS Installation" --infobox "Installing \`$1\` ($n of $total). $1 $2" 5 70
installpkg "$1"
}
gitmakeinstall() {
progname="$(basename "$1")"
dir="$repodir/$progname"
dialog --title "LARBS Installation" --infobox "Installing \`$progname\` ($n of $total) via \`git\` and \`make\`. $(basename "$1") $2" 5 70
sudo -u "$name" git clone --depth 1 "$1" "$dir" >/dev/null 2>&1 || { cd "$dir" || return ; sudo -u "$name" git pull --force origin master;}
cd "$dir" || exit
make >/dev/null 2>&1
make install >/dev/null 2>&1
cd /tmp || return ;}
pipinstall() { \
dialog --title "LARBS Installation" --infobox "Installing the Python package \`$1\` ($n of $total). $1 $2" 5 70
command -v pip || installpkg python3-pip >/dev/null 2>&1
yes | pip install "$1"
}
installationloop() { \
([ -f "$progsfile" ] && cp "$progsfile" /tmp/progs.csv) || curl -Ls "$progsfile" | sed '/^#/d' | eval grep "$grepseq" > /tmp/progs.csv
total=$(wc -l < /tmp/progs.csv)
while IFS=, read -r tag program comment; do
n=$((n+1))
echo "$comment" | grep "^\".*\"$" >/dev/null 2>&1 && comment="$(echo "$comment" | sed "s/\(^\"\|\"$\)//g")"
case "$tag" in
"G") gitmakeinstall "$program" "$comment" ;;
"P") pipinstall "$program" "$comment" ;;
*) maininstall "$program" "$comment" ;;
esac
done < /tmp/progs.csv ;}
# Downloads a gitrepo $1 and places the files in $2 only overwriting conflicts
putgitrepo() {
dialog --infobox "Downloading and installing config files..." 4 60
[ -z "$3" ] && branch="master" || branch="$repobranch"
dir=$(mktemp -d)
[ ! -d "$2" ] && mkdir -p "$2"
chown -R "$name:wheel" "$dir" "$2"
sudo -u "$name" git clone -b "$branch" --depth 1 "$1" "$dir" >/dev/null 2>&1
sudo -u "$name" cp -rfT "$dir" "$2"
}
systembeepoff() { dialog --infobox "Disabling beep sound and bluetooth..." 10 50
mkdir -p /etc/modprobe.d/
rmmod pcspkr
echo "blacklist pcspkr\nblacklist btusb" > /etc/modprobe.d/blacklist.conf ;}
putplug() { dialog --infobox "Downloading and installing vim-plug..." 4 60
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim >/dev/null 2>&1
sudo -u "$name" nvim +"PlugInstall --sync" +qa >/dev/null 2>&1 ;}
finalize(){ \
dialog --infobox "Preparing welcome message..." 4 50
dialog --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 Adrian" 12 80
}
### THE ACTUAL SCRIPT ###
### This is how everything happens in an intuitive format and order.
# Check if user is root on Arch distro. Install dialog.
installpkg dialog || error "Are you sure you're running this as the root user and have an internet connection?"
# Welcome user and pick dotfiles.
welcomemsg || error "User exited."
# Get and verify username and password.
getuser || error "User exited."
# Last chance for user to back out before install.
preinstallmsg || error "User exited."
dialog --title "LARBS Installation" --infobox "Installing \`Void nonfree repo\`, \`basedevel\` and \`git\`. These are required for the installation of other software." 5 70
installpkg void-repo-nonfree
xbps-install -Su >/dev/null
installpkg base-devel
installpkg git
installpkg curl
# The command that does all the installing. Reads the progs.csv file and
# installs each needed program using either xbps or git.
installationloop
# Install the dotfiles in the user's home directory
putgitrepo "$dotfilesrepo" "/home/$name" "$repobranch"
# Most important command! Get rid of the beep!
systembeepoff
# Install vim-plug
putplug
# Make zsh the default shell for the user
chsh -s /bin/zsh $name
# Enable services
ln -s /etc/sv/cronie /var/service/
ln -s /etc/sv/connmand /var/service/
ln -s /etc/sv/dbus /var/service/
# Change cursor to Adwaita
mkdir -p /usr/share/icons/default
printf '[Icon Theme]\nInherits=Adwaita' > /usr/share/icons/default/index.theme
# Tap to click
mkdir -p /etc/X11/xorg.conf.d/
printf 'Section "InputClass"
Identifier "libinput touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
# Enable left mouse button by tapping
Option "Tapping" "on"
EndSection' > /etc/X11/xorg.conf.d/40-libinput.conf
# Disable ttys 3-6
rm /var/service/agetty-tty6
touch /etc/sv/agetty-tty6/down
rm /var/service/agetty-tty5
touch /etc/sv/agetty-tty5/down
rm /var/service/agetty-tty4
touch /etc/sv/agetty-tty4/down
rm /var/service/agetty-tty3
touch /etc/sv/agetty-tty3/down
# Create basic home directories
sudo -u $name mkdir /home/$name/documents /home/$name/downloads /home/$name/music
# Last message! Install complete!
finalize
clear

76
progs.csv

@ -0,0 +1,76 @@
#TAG,NAME IN REPO (or git url),PURPOSE (should be a verb phrase to sound right while installing),
,anki,"is a flashcard program that utilizes spaced repetition."
,atool,"manages and gives information about archives."
,bsdtar,"is a BSD utilities using libarchive."
,calcurse,"is a lightweight terminal-based calendar."
,connman,"is an open source connection manager."
,cronie,"contains the standard UNIX daemon crond specified programs at scheduled times."
,dbus,"facilitates inter-process communication."
,dosfstools,"allows your computer to access dos-like filesystems."
,dunst,"is a lightweight notification system."
,elinks,"is full-featured text browser."
,exfat-utils,"allows management of FAT drives."
,ffmpeg,"can record and splice video and audio on the command line."
,font-fira-ttf,"is a Mozilla's new typeface OTF."
,fontconfig-devel,"is required for the compilation of some programs."
,fzf,"is a fuzzy finder tool."
,gcr-devel,"is required for the compilation of some programs."
,gotop,"is a terminal based graphical activity monitor inspired by gtop and vtop."
,highlight,"can highlight code output."
,libX11-devel,"is required for the compilation of some programs."
,libXft-devel,"is required for the compilation of some programs."
,libnotify,"allows desktop notifications."
,maim,"can take quick screenshots at your request."
,man-db,"lets you read man pages of programs."
,mpc,"is a terminal interface for mpd."
,mpd,"is a lightweight music daemon."
,mpv,"is the patrician's choice video player."
,ncmpcpp,"is a ncurses interface for music with multiple formats and a powerful tag editor."
,neovim,"is a tidier vim with some useful features."
,newsboat,"is a terminal RSS client."
,noto-fonts-emoji,"is a emoji font set."
,ntfs-3g,"allows accessing NTFS partitions."
,ntp,"is a time synchronization daemon."
,pamixer,"is a command-line audio interface."
,pass,"safely encrypts passwords."
,pipe-viewer,"is a youtube cli interface."
,pulseaudio,"is the audio system."
,pulsemixer,"is an audio controller."
,qutebrowser,"is a keyboard-focused browser with minimal GUI."
,setxkbmap,"sets keyboard map."
,simple-mtpfs,"enables the mounting of cell phones."
,sxiv,"is a minimalist image viewer."
,translate-shell,"is a command-line interface for Google Translate."
,transmission,"is a free BitTorrent client."
,tremc,"is a curses interface for transmission."
,ts,"queues commands or files for download."
,unclutter-xfixes,"hides an inactive mouse."
,unrar,"extracts rar's."
,unzip,"unzips zips."
,urlscan,"is a terminal url selector."
,vifm,"is a curses based vi[m] like file manager."
,xbacklight,"enables changing screen brightness levels."
,xcape,"gives the special escape/super mappings of LARBS."
,xclip,"allows for copying and pasting from the command line."
,xdg-utils,"assists with various desktop integration tasks."
,xdotool,"provides window action utilities on the command line."
,xdpyinfo,"aids with resolution determination and screen recording."
,xinit,"starts the graphical server."
,xkb-switch,"allows to query and change the XKB layout state."
,xmodmap,"modifies keymaps and pointer button mappings."
,xorg-minimal,"is the graphical server."
,xprop,"is a tool for detecting window properties."
,xsel,"retrieves and sets the X selection."
,xset,"is a X11 user preferences utility."
,xtools,"are opinionated helpers for working with XBPS."
,xwallpaper,"sets the wallpaper."
,xwininfo,"allows querying information about windows."
,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."
,zsh-syntax-highlighting,"provides syntax highlighting in the shell."
G,https://github.com/dm1tz/dmenu.git,"runs commands and provides a UI for selection."
G,https://github.com/dm1tz/dwm.git,"is a window manager."
G,https://github.com/dm1tz/dwmblocks.git,"serves as the modular status bar."
G,https://github.com/dm1tz/slock.git,"is a simple X display locker."
G,https://github.com/dm1tz/st.git,"is a suckless terminal."
Loading…
Cancel
Save