remove tput fuckery
This commit is contained in:
parent
1807d8f3fe
commit
6c78d63c28
29
bootstrap.sh
29
bootstrap.sh
|
@ -50,14 +50,11 @@ _loop_wrapper() {
|
||||||
skip_regex="^(#.*)?$"
|
skip_regex="^(#.*)?$"
|
||||||
total=$(grep -cvP "$skip_regex" "$file")
|
total=$(grep -cvP "$skip_regex" "$file")
|
||||||
|
|
||||||
tput sc
|
|
||||||
while read -r x; do
|
while read -r x; do
|
||||||
echo "$x" | grep -qvP "$skip_regex" || continue
|
echo "$x" | grep -qvP "$skip_regex" || continue
|
||||||
n=$((n + 1))
|
n=$((n + 1))
|
||||||
eval "info \"(${n}/${total}) $message\""
|
eval "info \"(${n}/${total}) $message\""
|
||||||
eval "$command"
|
eval "$command"
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
done <"$file"
|
done <"$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,22 +64,15 @@ check_root() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
tput sc
|
|
||||||
info "Synchronizing XBPS index..."
|
info "Synchronizing XBPS index..."
|
||||||
xbps-install -S >/dev/null 2>&1 || error "Failed to synchronize XBPS index! (Try manually running xbps-install -S)"
|
xbps-install -S >/dev/null 2>&1 || error "Failed to synchronize XBPS index! (Try manually running xbps-install -S)"
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
|
|
||||||
if ! xbps-query ntp >/dev/null 2>&1; then
|
if ! xbps-query ntp >/dev/null 2>&1; then
|
||||||
info "Installing ntp..."
|
info "Installing ntp..."
|
||||||
xbps-install -y ntp >/dev/null 2>&1
|
xbps-install -y ntp >/dev/null 2>&1
|
||||||
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 el
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Done!"
|
info "Done!"
|
||||||
|
@ -105,15 +95,11 @@ install_files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
create_user() {
|
create_user() {
|
||||||
tput sc
|
|
||||||
|
|
||||||
failed=false
|
failed=false
|
||||||
while ! echo "$username" | grep "^[a-z_][a-z0-9_-]*$" | grep -qv "root"; 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: ")
|
username=$(prompt "Input Username: ")
|
||||||
failed=true
|
failed=true
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if id -u "$username" >/dev/null 2>&1; then
|
if id -u "$username" >/dev/null 2>&1; then
|
||||||
|
@ -125,14 +111,8 @@ create_user() {
|
||||||
failed=false
|
failed=false
|
||||||
while [ -z "$pass1" ] || [ "$pass1" != "$pass2" ]; do
|
while [ -z "$pass1" ] || [ "$pass1" != "$pass2" ]; do
|
||||||
$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 el
|
|
||||||
pass1=$(prompt "Input Password: ")
|
pass1=$(prompt "Input Password: ")
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
pass2=$(prompt "Repeat Password: ")
|
pass2=$(prompt "Repeat Password: ")
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
failed=true
|
failed=true
|
||||||
done
|
done
|
||||||
echo "$username:$pass1" | chpasswd
|
echo "$username:$pass1" | chpasswd
|
||||||
|
@ -162,28 +142,19 @@ create_directories() {
|
||||||
}
|
}
|
||||||
|
|
||||||
install_dotfiles() {
|
install_dotfiles() {
|
||||||
tput sc
|
|
||||||
info "Cloning dotfiles..."
|
info "Cloning dotfiles..."
|
||||||
mkdir -p "${user_home}/${STOW_DIR}"
|
mkdir -p "${user_home}/${STOW_DIR}"
|
||||||
if [ ! -d "${user_home}/${STOW_DIR}/${DOTS_PACKAGE}/.git" ]; then
|
if [ ! -d "${user_home}/${STOW_DIR}/${DOTS_PACKAGE}/.git" ]; then
|
||||||
if ! git -C "${user_home}/${STOW_DIR}" clone -q --recurse-submodules -b "$DOTS_BRANCH" "$DOTS_REPO" "$DOTS_PACKAGE"; then
|
if ! git -C "${user_home}/${STOW_DIR}" clone -q --recurse-submodules -b "$DOTS_BRANCH" "$DOTS_REPO" "$DOTS_PACKAGE"; then
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
warn "Failed to clone dotfiles"
|
warn "Failed to clone dotfiles"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
info "Symlinking dotfiles..."
|
info "Symlinking dotfiles..."
|
||||||
if ! stow -d "$user_home/$STOW_DIR" -t "$user_home" "$DOTS_PACKAGE" 1>/dev/null 2>&1; then
|
if ! stow -d "$user_home/$STOW_DIR" -t "$user_home" "$DOTS_PACKAGE" 1>/dev/null 2>&1; then
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
warn "Failed to symlink dotfiles"
|
warn "Failed to symlink dotfiles"
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
tput rc
|
|
||||||
tput el
|
|
||||||
info "Done!"
|
info "Done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue