Merge branch 'main' of https://git.snaile.de/luca/bootstrapper
This commit is contained in:
commit
57a6e4f539
70
bootstrap.sh
70
bootstrap.sh
|
@ -4,7 +4,7 @@ DOTS_BRANCH="main"
|
||||||
STOW_DIR=".local/share/stow"
|
STOW_DIR=".local/share/stow"
|
||||||
DOTS_PACKAGE="dots"
|
DOTS_PACKAGE="dots"
|
||||||
|
|
||||||
USER_GROUPS="wheel,plugdev" # Comma separated list
|
USER_GROUPS="wheel,floppy,audio,video,cdrom,optical,kvm,xbuilder,plugdev" # Comma separated list
|
||||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||||
|
|
||||||
BOLD="$(tput bold)"
|
BOLD="$(tput bold)"
|
||||||
|
@ -21,8 +21,7 @@ error() {
|
||||||
|
|
||||||
prompt() {
|
prompt() {
|
||||||
message=$1
|
message=$1
|
||||||
tty=$2
|
printf "%b" "${BLUE}${message}${RESET}" >"$(tty)"
|
||||||
printf "%b" "${BLUE}${message}${RESET}" >"$tty"
|
|
||||||
# shellcheck disable=SC3037,SC2046
|
# shellcheck disable=SC3037,SC2046
|
||||||
read -r x
|
read -r x
|
||||||
echo "$x"
|
echo "$x"
|
||||||
|
@ -70,36 +69,29 @@ check_root() {
|
||||||
setup() {
|
setup() {
|
||||||
tput sc
|
tput sc
|
||||||
info "Synchronizing XBPS index..."
|
info "Synchronizing XBPS index..."
|
||||||
xbps-install -Sy >/dev/null 2>&1 || error "Failed to synchronize XBPS index!"
|
xbps-install -S >/dev/null 2>&1 || error "Failed to synchronize XBPS index! (Try manually running xbps-install -S)"
|
||||||
tput rc
|
tput rc
|
||||||
tput el
|
tput el
|
||||||
|
|
||||||
info "Installing ntp..."
|
if ! xbps-query ntp >/dev/null 2>&1; then
|
||||||
xbps-install -y ntp >/dev/null 2>&1
|
info "Installing ntp..."
|
||||||
tput rc
|
xbps-install -y ntp >/dev/null 2>&1
|
||||||
tput el
|
tput rc
|
||||||
|
tput el
|
||||||
|
|
||||||
info "Synchronizing time..."
|
info "Synchronizing time..."
|
||||||
ntpdate "pool.ntp.org" >/dev/null 2>&1 || warn "Failed to synchronize time!"
|
ntpdate "pool.ntp.org" >/dev/null 2>&1 || warn "Failed to synchronize time!"
|
||||||
tput rc
|
tput rc
|
||||||
tput el
|
tput el
|
||||||
|
fi
|
||||||
|
|
||||||
info "Done!"
|
info "Done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_packages() {
|
install_packages() {
|
||||||
failed_packages=""
|
#shellcheck disable=SC2016,SC2046
|
||||||
#shellcheck disable=SC2016
|
xbps-install -y $(xargs -a "$1") 2>&1 | grep -q "not found in repository pool." && error "Invalid package in packages.txt, run validate.sh"
|
||||||
_loop_wrapper "$1" \
|
info "Done!"
|
||||||
'Installing ${x}' \
|
|
||||||
'xbps-install -y "$x" >/dev/null 2>&1 || failed_packages="${failed_packages} ${x}"'
|
|
||||||
if [ -n "$failed_packages" ]; then
|
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
warn "Failed to install:${failed_packages}"
|
|
||||||
else
|
|
||||||
info "Done!"
|
|
||||||
fi
|
|
||||||
command -v git 1>/dev/null 2>&1 || error "git isn't installed even though it should be!"
|
command -v git 1>/dev/null 2>&1 || error "git isn't installed even though it should be!"
|
||||||
command -v stow 1>/dev/null 2>&1 || error "stow isn't installed even though it should be!"
|
command -v stow 1>/dev/null 2>&1 || error "stow isn't installed even though it should be!"
|
||||||
}
|
}
|
||||||
|
@ -116,16 +108,17 @@ create_user() {
|
||||||
tput sc
|
tput sc
|
||||||
|
|
||||||
failed=false
|
failed=false
|
||||||
while ! echo "$username" | grep -q "[a-z_][a-z0-9_-]*$"; do
|
while ! echo "$username" | grep "^[a-z_][a-z0-9_-]*$" | grep -qv "root"; do
|
||||||
$failed && warn "Invalid username, try again!"
|
$failed && warn "Invalid username, try again!"
|
||||||
username=$(prompt "Input Username: " "$(tty)")
|
username=$(prompt "Input Username: ")
|
||||||
failed=true
|
failed=true
|
||||||
tput rc
|
tput rc
|
||||||
tput el
|
tput el
|
||||||
done
|
done
|
||||||
|
|
||||||
if id -u "$username" >/dev/null 2>&1; then
|
if id -u "$username" >/dev/null 2>&1; then
|
||||||
warn "User \"$username\" already exists! Skipping user creation!"
|
warn "User \"$username\" already exists, Skipping user creation!"
|
||||||
|
usermod -aG "$USER_GROUPS" "$username"
|
||||||
else
|
else
|
||||||
info "Creating user \"$username\" with the following groups: \"$USER_GROUPS\"..."
|
info "Creating user \"$username\" with the following groups: \"$USER_GROUPS\"..."
|
||||||
useradd -m -G "$USER_GROUPS" "$username"
|
useradd -m -G "$USER_GROUPS" "$username"
|
||||||
|
@ -134,10 +127,10 @@ create_user() {
|
||||||
$failed && warn "Passwords do not match or are empty, try again!"
|
$failed && warn "Passwords do not match or are empty, try again!"
|
||||||
tput rc
|
tput rc
|
||||||
tput el
|
tput el
|
||||||
pass1=$(prompt "Input Password: " "$(tty)")
|
pass1=$(prompt "Input Password: ")
|
||||||
tput rc
|
tput rc
|
||||||
tput el
|
tput el
|
||||||
pass2=$(prompt "Repeat Password: " "$(tty)")
|
pass2=$(prompt "Repeat Password: ")
|
||||||
tput rc
|
tput rc
|
||||||
tput el
|
tput el
|
||||||
failed=true
|
failed=true
|
||||||
|
@ -190,8 +183,8 @@ install_dotfiles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
select_keymap() {
|
select_keymap() {
|
||||||
|
[ -L "${user_home}/.local/share/xkb/compiled/default" ] && return
|
||||||
map="$(find "${user_home}/.local/share/xkb/compiled" -type f -printf "%f\n" | fzf --header="Select a default keymap:")"
|
map="$(find "${user_home}/.local/share/xkb/compiled" -type f -printf "%f\n" | fzf --header="Select a default keymap:")"
|
||||||
rm "${user_home}/.local/share/xkb/compiled/default"
|
|
||||||
ln -s "$map" "${user_home}/.local/share/xkb/compiled/default"
|
ln -s "$map" "${user_home}/.local/share/xkb/compiled/default"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +192,7 @@ enable_services() {
|
||||||
tput sc
|
tput sc
|
||||||
info "Installing user service service..."
|
info "Installing user service service..."
|
||||||
target="/etc/sv/runsvdir-${username}"
|
target="/etc/sv/runsvdir-${username}"
|
||||||
mkdir -p "$(dirname "$target")"
|
mkdir -p "$target"
|
||||||
sed "s/<U>/$username/" "${SCRIPT_DIR}/runsvdir-user" >"$target/run"
|
sed "s/<U>/$username/" "${SCRIPT_DIR}/runsvdir-user" >"$target/run"
|
||||||
[ ! -L "/var/service/$(basename "$target")" ] &&
|
[ ! -L "/var/service/$(basename "$target")" ] &&
|
||||||
ln -s "$target" "/var/service/"
|
ln -s "$target" "/var/service/"
|
||||||
|
@ -224,17 +217,22 @@ finalize() {
|
||||||
|
|
||||||
check_root
|
check_root
|
||||||
|
|
||||||
|
emphasize "-- Copying Files --"
|
||||||
|
install_files
|
||||||
|
|
||||||
emphasize "-- Preparing Installation --"
|
emphasize "-- Preparing Installation --"
|
||||||
setup
|
setup
|
||||||
|
|
||||||
emphasize "-- Installing Packages --"
|
emphasize "-- Installing Packages --"
|
||||||
install_packages "${SCRIPT_DIR}/packages.txt"
|
install_packages "${SCRIPT_DIR}/packages.txt"
|
||||||
|
|
||||||
emphasize "-- Copying Files --"
|
username="$SUDO_USER"
|
||||||
install_files
|
if [ -z "$username" ]; then
|
||||||
|
emphasize "-- Creating User Account --"
|
||||||
emphasize "-- Creating User Account --"
|
create_user
|
||||||
create_user
|
else
|
||||||
|
user_home=$(getent passwd "$username" | cut -d ':' -f 6)
|
||||||
|
fi
|
||||||
|
|
||||||
emphasize "-- Creating Standard Home Directories --"
|
emphasize "-- Creating Standard Home Directories --"
|
||||||
create_directories "${SCRIPT_DIR}/directories.txt"
|
create_directories "${SCRIPT_DIR}/directories.txt"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
.config/zsh/configs
|
.config/zsh/configs
|
||||||
.config/X11/xsession.d
|
.config/X11/xsession.d
|
||||||
.local/state
|
.local/state
|
||||||
|
.local/log
|
||||||
.local/share/applications
|
.local/share/applications
|
||||||
.local/share/gnupg
|
.local/share/gnupg
|
||||||
.local/bin/cron
|
.local/bin/cron
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#%PAM-1.0
|
||||||
|
|
||||||
|
auth required pam_securetty.so
|
||||||
|
auth requisite pam_nologin.so
|
||||||
|
auth include system-local-login
|
||||||
|
auth optional pam_gnome_keyring.so
|
||||||
|
account include system-local-login
|
||||||
|
session include system-local-login
|
||||||
|
session optional pam_gnome_keyring.so auto_start
|
|
@ -0,0 +1,2 @@
|
||||||
|
password required pam_unix.so sha512 shadow nullok
|
||||||
|
password optional pam_gnome_keyring.so
|
|
@ -4,7 +4,7 @@ ACTION!="add|change", GOTO="yubico_end"
|
||||||
# device node, needed for challenge/response to work correctly.
|
# device node, needed for challenge/response to work correctly.
|
||||||
|
|
||||||
# Yubico Yubikey II
|
# Yubico Yubikey II
|
||||||
ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0010|0110|0111|0114|0116|0401|0403|0404|0405|0407|0410",
|
ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0010|0110|0111|0114|0116|0401|0403|0404|0405|0407|0410", \
|
||||||
ENV{ID_SECURITY_TOKEN}="1"
|
ENV{ID_SECURITY_TOKEN}="1"
|
||||||
|
|
||||||
LABEL="yubico_end"
|
LABEL="yubico_end"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Udev rules for letting the console user access the Yubikey USB
|
# Udev rules for letting the console user access the Yubikey USB
|
||||||
# device node, needed for challenge/response to work correctly.
|
# device node, needed for challenge/response to work correctly.
|
||||||
|
|
||||||
ACTION=="add|change", SUBSYSTEM=="usb",
|
ACTION=="add|change", SUBSYSTEM=="usb", \
|
||||||
ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0010|0110|0111|0114|0116|0401|0403|0404|0405|0407|0410", \
|
ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0010|0110|0111|0114|0116|0401|0403|0404|0405|0407|0410", \
|
||||||
TEST=="/var/run/ConsoleKit/database", \
|
TEST=="/var/run/ConsoleKit/database", \
|
||||||
RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"
|
RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>public-key</key>
|
||||||
|
<data>LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUF0QmkxSjJOTC83MXEzZ2ZCK3VKcAo3WUNnazRtcEJLMFVyM2VHNzd4Sjk0R3pseW0yZ1ZnZXN3bkRTWENIMm94a3FJM3A3a0E1UHpwZkV5K2RIRlgwCi9PTmdPRlBSaEtNemRBR3dVNy9sZk9VUUNad0pIc1d0c2p4VmZCY0E1d0FvWTk0Szh3RldDak5DOU1zSVc2TVMKbGNQNGdYTzdZczRSVUNuUXVyVFBXVkpJNEYxSWxheXg5KzVKTFJBdVlMeHFFOVBwTmVIUHVmRVZJb0YzV1BxdQpQYzFZTDdvbXpUOUpYWC82RTZVQ3A1bVo2em5jRDlEZ29TZFNUTVFCbjF3RWpFOVNKcktKdFBRczRKU1J2dDQyClNKL05ZTkFScmFIT01XMDZ3RzZuQkNYM212M0ZXdFp1ZWxBSTZQOGtnZmNKWTBjbWJFb3hzSEpJT2JGajRNMWMKYS9tTG1xcTBqc2UxYitxdzQ4WlJZZnh1bmt2YjQ4dCtoTE8veUNXRXAvN0hFaGxrcTdncUtNZ1E0WmF0L1JmNwplVUY0ZHc0cUl6MHZ1cTVpTTJQZTdEd2U4N09yUGRzcE8zZGhucWUvZGRYYTdxakdpaS9KTjN5OXE4dmFmbGw4CnB4aUFLakFRb3k2WStjU21HOUpTRyt3NHdLNFhXTWFmQWMxcVczRmFhbE5sUzdRRzFLS2cxeHhzU1lUVkJWT2EKZUQ1dnFiZ2RGeCtSLzhubEtnbXJROGJqMkFNWkFRT2VwRDNFRUNFM1FsanhVejVqc3ppZ0tsS3hNVlBwR2tmYQpNWjExbmlVR0ZwL2pmUS8rTlhhT21sSnJkVmpxZTlwSk1HdkdhZVBZc1huY3pTaU04YTU4RUU0RDIwY3ZmRmU4CmhpOVlKT3lGQ0NSYlFiSmdoUzZxRENrQ0F3RUFBUT09Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=</data>
|
||||||
|
<key>public-key-size</key>
|
||||||
|
<integer>4096</integer>
|
||||||
|
<key>signature-by</key>
|
||||||
|
<string>luca <luca@snaile.de></string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -10,7 +10,6 @@ nsxiv
|
||||||
xwallpaper
|
xwallpaper
|
||||||
ffmpeg
|
ffmpeg
|
||||||
man-db
|
man-db
|
||||||
tldr
|
|
||||||
pipewire
|
pipewire
|
||||||
wireplumber
|
wireplumber
|
||||||
pulsemixer
|
pulsemixer
|
||||||
|
@ -68,4 +67,10 @@ gnome-keyring
|
||||||
gnupg2-scdaemon
|
gnupg2-scdaemon
|
||||||
yubikey-manager
|
yubikey-manager
|
||||||
mediainfo
|
mediainfo
|
||||||
font-firacode-nf-ttf
|
ranger
|
||||||
|
brave-bin
|
||||||
|
ueberzug
|
||||||
|
seahorse
|
||||||
|
tokyonight-theme
|
||||||
|
tokyonight-icons
|
||||||
|
polkit
|
||||||
|
|
|
@ -5,3 +5,4 @@ elogind
|
||||||
crond
|
crond
|
||||||
bluetoothd
|
bluetoothd
|
||||||
pcscd
|
pcscd
|
||||||
|
polkitd
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
info() {
|
||||||
|
printf "%b\n" "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||||
|
skip_regex="^(#.*)?$"
|
||||||
|
|
||||||
|
total=$(grep -cvP "$skip_regex" "${SCRIPT_DIR}/packages.txt")
|
||||||
|
tput sc
|
||||||
|
while read -r package; do
|
||||||
|
echo "$package" | grep -qvP "$skip_regex" || continue
|
||||||
|
n=$((n + 1))
|
||||||
|
eval "info \"(${n}/${total}) Validating $package\""
|
||||||
|
xbps-query -R "$package" >/dev/null 2>&1 || failed_packages="${failed_packages} ${package}"
|
||||||
|
tput rc
|
||||||
|
tput el
|
||||||
|
done <"${SCRIPT_DIR}/packages.txt"
|
||||||
|
|
||||||
|
echo "Failed packages:${failed_packages}"
|
Reference in New Issue