WIP
This commit is contained in:
parent
94969fff0e
commit
2fa4f62579
57
bootstrap.sh
57
bootstrap.sh
|
@ -40,6 +40,55 @@ warn() {
|
||||||
printf "%b\n" "${YELLOW}${BOLD}${1}${RESET}"
|
printf "%b\n" "${YELLOW}${BOLD}${1}${RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_buffer() {
|
||||||
|
buffer_size=$1
|
||||||
|
for i in $(seq 1 "$((buffer_size))"); do
|
||||||
|
if [ "$trim" = "y" ]; then
|
||||||
|
eval "printf '%-${line_length}s\n' \"\$buffer${i}\""
|
||||||
|
else
|
||||||
|
eval "printf '%-${line_length}.${line_length}s\n' \"\$buffer${i}\""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
push_buffer() {
|
||||||
|
line=$1
|
||||||
|
buffer_size=$2
|
||||||
|
for i in $(seq 1 $((buffer_size))); do
|
||||||
|
eval "buffer$i=\$buffer$((i + 1))"
|
||||||
|
done
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
eval "buffer${buffer_size}='$line'"
|
||||||
|
# buffer1="$line"
|
||||||
|
}
|
||||||
|
|
||||||
|
scroll() {
|
||||||
|
buffer_size=$1 # int
|
||||||
|
trim=${2:-y} # 'y' | 'n'
|
||||||
|
|
||||||
|
line_length=$(tput cols)
|
||||||
|
trap 'line_length=$(tput cols)' WINCH
|
||||||
|
|
||||||
|
tput civis
|
||||||
|
while read -r line; do
|
||||||
|
push_buffer "$line" "$buffer_size"
|
||||||
|
|
||||||
|
tput sc
|
||||||
|
print_buffer "$buffer_size"
|
||||||
|
tput rc
|
||||||
|
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
tput cnorm
|
||||||
|
|
||||||
|
for i in $(seq 1 $((buffer_size))); do
|
||||||
|
eval "buffer$i=''"
|
||||||
|
done
|
||||||
|
print_buffer "$buffer_size"
|
||||||
|
trap - WINCH
|
||||||
|
}
|
||||||
|
|
||||||
_loop_wrapper() {
|
_loop_wrapper() {
|
||||||
unset n
|
unset n
|
||||||
unset total
|
unset total
|
||||||
|
@ -55,7 +104,7 @@ _loop_wrapper() {
|
||||||
n=$((n + 1))
|
n=$((n + 1))
|
||||||
eval "info \"(${n}/${total}) $message\""
|
eval "info \"(${n}/${total}) $message\""
|
||||||
eval "$command"
|
eval "$command"
|
||||||
done <"$file"
|
done <"$file" | scroll 7
|
||||||
}
|
}
|
||||||
|
|
||||||
check_root() {
|
check_root() {
|
||||||
|
@ -81,9 +130,9 @@ setup() {
|
||||||
install_packages() {
|
install_packages() {
|
||||||
#shellcheck disable=SC2016,SC2046
|
#shellcheck disable=SC2016,SC2046
|
||||||
{ sed '/^[[:space:]]*#/d;/^$/d' "${SCRIPT_DIR}/packages.txt" | xargs -r xbps-install -y || error "Invalid package in packages.txt"; } | grep -v 'already installed'
|
{ sed '/^[[:space:]]*#/d;/^$/d' "${SCRIPT_DIR}/packages.txt" | xargs -r xbps-install -y || error "Invalid package in packages.txt"; } | grep -v 'already installed'
|
||||||
info "Done!"
|
|
||||||
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!"
|
||||||
|
info "Done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_files() {
|
install_files() {
|
||||||
|
@ -104,7 +153,7 @@ create_symlinks() {
|
||||||
[ -L $target ] && rm $target
|
[ -L $target ] && rm $target
|
||||||
ln -s $source $target
|
ln -s $source $target
|
||||||
'
|
'
|
||||||
|
info "Done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_user() {
|
create_user() {
|
||||||
|
@ -202,6 +251,8 @@ finalize() {
|
||||||
|
|
||||||
### CONTROL FLOW BEGINS HERE ###
|
### CONTROL FLOW BEGINS HERE ###
|
||||||
|
|
||||||
|
trap 'tput cnorm; tput sgr0; exit' INT TERM EXIT
|
||||||
|
|
||||||
check_root
|
check_root
|
||||||
|
|
||||||
emphasize "-- Copying Files --"
|
emphasize "-- Copying Files --"
|
||||||
|
|
Loading…
Reference in New Issue