Update setup

This commit is contained in:
2026-03-27 16:56:28 -03:00
parent cd4e80d3d6
commit 29ff3fe3c3

View File

@@ -7,6 +7,14 @@ YELLOW='\033[1;33m'
CYAN='\033[1;36m' CYAN='\033[1;36m'
NC='\033[0m' NC='\033[0m'
# Configuration for UI
MAX_LOG_LINES=8
LINE_SERVER=4
LINE_DOCKER=5
LINE_ZSH=6
LINE_TAILSCALE=7
LINE_WIFITUI=8
teardown_ui() { teardown_ui() {
local ROWS local ROWS
ROWS=$(tput lines 2>/dev/null || echo 24) ROWS=$(tput lines 2>/dev/null || echo 24)
@@ -22,10 +30,11 @@ setup_ui() {
ROWS=$(tput lines 2>/dev/null || echo 24) ROWS=$(tput lines 2>/dev/null || echo 24)
LOG_END=$ROWS LOG_END=$ROWS
LOG_START=$(( LOG_END - 15 + 1 )) LOG_START=$(( LOG_END - MAX_LOG_LINES + 1 ))
if [ "$LOG_START" -le 11 ]; then local MIN_LOG_START=$(( LINE_WIFITUI + 4 ))
LOG_START=12 if [ "$LOG_START" -le "$(( MIN_LOG_START - 1 ))" ]; then
LOG_START=$MIN_LOG_START
fi fi
SEP_LINE=$(( LOG_START - 1 )) SEP_LINE=$(( LOG_START - 1 ))
@@ -35,19 +44,19 @@ setup_ui() {
printf "\033[2;1H${CYAN} HOMELOGIC SETUP SCRIPT ${NC}\n" printf "\033[2;1H${CYAN} HOMELOGIC SETUP SCRIPT ${NC}\n"
printf "\033[3;1H${BLUE}=========================================${NC}\n" printf "\033[3;1H${BLUE}=========================================${NC}\n"
printf "\033[4;1H [ ] Server\n" printf "\033[${LINE_SERVER};1H [ ] Server\n"
printf "\033[5;1H [ ] Docker\n" printf "\033[${LINE_DOCKER};1H [ ] Docker\n"
printf "\033[6;1H [ ] ZSH\n" printf "\033[${LINE_ZSH};1H [ ] ZSH\n"
printf "\033[7;1H [ ] Tailscale\n" printf "\033[${LINE_TAILSCALE};1H [ ] Tailscale\n"
printf "\033[8;1H [ ] Wifitui\n" printf "\033[${LINE_WIFITUI};1H [ ] Wifitui\n"
printf "\033[${SEP_LINE};1H${YELLOW}--- Verbose Logs ------------------------${NC}\n" printf "\033[${SEP_LINE};1H${YELLOW}--- Verbose Logs ------------------------${NC}\n"
update_status 4 "Pending" update_status "$LINE_SERVER" "Pending"
update_status 5 "Pending" update_status "$LINE_DOCKER" "Pending"
update_status 6 "Pending" update_status "$LINE_ZSH" "Pending"
update_status 7 "Pending" update_status "$LINE_TAILSCALE" "Pending"
update_status 8 "Pending" update_status "$LINE_WIFITUI" "Pending"
printf "\033[${LOG_START};${LOG_END}r" printf "\033[${LOG_START};${LOG_END}r"
printf "\033[${LOG_END};1H" printf "\033[${LOG_END};1H"
@@ -71,7 +80,7 @@ print_step() {
} }
print_info() { print_info() {
local IL=${INFO_LINE:-10} local IL=${INFO_LINE:-$(( LINE_WIFITUI + 2 ))}
printf "\0337\033[${IL};1H\033[K${CYAN} ➜ %s${NC}\0338" "$1" printf "\0337\033[${IL};1H\033[K${CYAN} ➜ %s${NC}\0338" "$1"
printf "${CYAN}➜ %s${NC}\n" "$1" printf "${CYAN}➜ %s${NC}\n" "$1"
} }
@@ -96,7 +105,7 @@ ask_optional_step() {
} }
setup_server() { setup_server() {
update_status 4 "Running" update_status "$LINE_SERVER" "Running"
print_step "Setting up Server" print_step "Setting up Server"
print_info "Updating packages and configuring firewall..." print_info "Updating packages and configuring firewall..."
sudo apt-get update sudo apt-get update
@@ -106,11 +115,11 @@ setup_server() {
sudo ufw allow 8123/udp sudo ufw allow 8123/udp
sudo ufw allow 3000/tcp sudo ufw allow 3000/tcp
sudo ufw allow 3001/tcp sudo ufw allow 3001/tcp
update_status 4 "Installed" update_status "$LINE_SERVER" "Installed"
} }
setup_docker() { setup_docker() {
update_status 5 "Running" update_status "$LINE_DOCKER" "Running"
print_step "Setting up Docker" print_step "Setting up Docker"
print_info "Installing prerequisites..." print_info "Installing prerequisites..."
sudo apt -y install lsb-release gnupg apt-transport-https ca-certificates curl software-properties-common sudo apt -y install lsb-release gnupg apt-transport-https ca-certificates curl software-properties-common
@@ -133,11 +142,11 @@ setup_docker() {
sudo usermod -aG docker "$USER" sudo usermod -aG docker "$USER"
fi fi
sudo docker network create homelogic 2>/dev/null || true sudo docker network create homelogic 2>/dev/null || true
update_status 5 "Installed" update_status "$LINE_DOCKER" "Installed"
} }
setup_zsh() { setup_zsh() {
update_status 6 "Running" update_status "$LINE_ZSH" "Running"
print_step "Setting up ZSH" print_step "Setting up ZSH"
print_info "Configuring .zshrc and hushlogin..." print_info "Configuring .zshrc and hushlogin..."
touch ../.hushlogin touch ../.hushlogin
@@ -153,7 +162,7 @@ setup_zsh() {
print_info "Installing Oh My Zsh and plugins..." print_info "Installing Oh My Zsh and plugins..."
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 2>/dev/null || true git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 2>/dev/null || true
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
update_status 6 "Installed" update_status "$LINE_ZSH" "Installed"
} }
setup_tailscale() { setup_tailscale() {
@@ -218,22 +227,22 @@ main() {
setup_server setup_server
setup_docker setup_docker
setup_zsh setup_zsh
ask_optional_step 7 "Tailscale" setup_tailscale ask_optional_step "$LINE_TAILSCALE" "Tailscale" setup_tailscale
ask_optional_step 8 "Wifitui" setup_wifitui ask_optional_step "$LINE_WIFITUI" "Wifitui" setup_wifitui
;; ;;
2) 2)
update_status 7 "Skipped" update_status "$LINE_TAILSCALE" "Skipped"
update_status 8 "Skipped" update_status "$LINE_WIFITUI" "Skipped"
setup_server setup_server
setup_docker setup_docker
setup_zsh setup_zsh
;; ;;
3) 3)
update_status 4 "Skipped" update_status "$LINE_SERVER" "Skipped"
update_status 5 "Skipped" update_status "$LINE_DOCKER" "Skipped"
update_status 6 "Skipped" update_status "$LINE_ZSH" "Skipped"
ask_optional_step 7 "Tailscale" setup_tailscale ask_optional_step "$LINE_TAILSCALE" "Tailscale" setup_tailscale
ask_optional_step 8 "Wifitui" setup_wifitui ask_optional_step "$LINE_WIFITUI" "Wifitui" setup_wifitui
;; ;;
esac esac