Update setup

This commit is contained in:
2026-03-27 16:53:36 -03:00
parent 5a63fe796a
commit cd4e80d3d6

View File

@@ -20,45 +20,83 @@ setup_ui() {
clear
local ROWS
ROWS=$(tput lines 2>/dev/null || echo 24)
if [ "$ROWS" -lt 10 ]; then ROWS=10; fi
local LOG_START=8
LOG_END=$ROWS
LOG_START=$(( LOG_END - 15 + 1 ))
if [ "$LOG_START" -le 11 ]; then
LOG_START=12
fi
SEP_LINE=$(( LOG_START - 1 ))
INFO_LINE=$(( SEP_LINE - 1 ))
printf "\033[1;1H${BLUE}=========================================${NC}\n"
printf "\033[2;1H${CYAN} HOMELOGIC SETUP SCRIPT ${NC}\n"
printf "\033[3;1H${BLUE}=========================================${NC}\n"
printf "\033[7;1H${YELLOW}--- Verbose Logs ------------------------${NC}\n"
printf "\033[${LOG_START};${ROWS}r"
printf "\033[${ROWS};1H"
printf "\033[4;1H [ ] Server\n"
printf "\033[5;1H [ ] Docker\n"
printf "\033[6;1H [ ] ZSH\n"
printf "\033[7;1H [ ] Tailscale\n"
printf "\033[8;1H [ ] Wifitui\n"
printf "\033[${SEP_LINE};1H${YELLOW}--- Verbose Logs ------------------------${NC}\n"
update_status 4 "Pending"
update_status 5 "Pending"
update_status 6 "Pending"
update_status 7 "Pending"
update_status 8 "Pending"
printf "\033[${LOG_START};${LOG_END}r"
printf "\033[${LOG_END};1H"
}
update_status() {
local line="$1"
local status="$2"
local color="${NC}"
case "$status" in
Pending) color="${NC}" ;;
Running) color="${BLUE}" ;;
Installed) color="${GREEN}" ;;
Skipped) color="${YELLOW}" ;;
esac
printf "\0337\033[%d;4H${color}%-10s${NC}\0338" "$line" "$status"
}
print_step() {
printf "\0337\033[5;1H\033[K${BLUE}▶ %s${NC}\0338" "$1"
printf "\n${BLUE}========== %s ==========${NC}\n" "$1"
}
print_info() {
printf "\0337\033[6;1H\033[K${CYAN} ➜ %s${NC}\0338" "$1"
local IL=${INFO_LINE:-10}
printf "\0337\033[${IL};1H\033[K${CYAN} ➜ %s${NC}\0338" "$1"
printf "${CYAN}➜ %s${NC}\n" "$1"
}
ask_optional_step() {
local step_name="$1"
local callback="$2"
local line="$1"
local step_name="$2"
local callback="$3"
printf "\n${YELLOW}❓ Do you want to install and setup %s? [Y/n] ${NC}" "$step_name"
read choice
case "$choice" in
n|N|no|No|NO )
print_info "Skipping $step_name setup."
update_status "$line" "Skipped"
;;
* )
$callback
update_status "$line" "Running"
$callback "$line"
;;
esac
}
setup_server() {
update_status 4 "Running"
print_step "Setting up Server"
print_info "Updating packages and configuring firewall..."
sudo apt-get update
@@ -68,9 +106,11 @@ setup_server() {
sudo ufw allow 8123/udp
sudo ufw allow 3000/tcp
sudo ufw allow 3001/tcp
update_status 4 "Installed"
}
setup_docker() {
update_status 5 "Running"
print_step "Setting up Docker"
print_info "Installing prerequisites..."
sudo apt -y install lsb-release gnupg apt-transport-https ca-certificates curl software-properties-common
@@ -93,9 +133,11 @@ setup_docker() {
sudo usermod -aG docker "$USER"
fi
sudo docker network create homelogic 2>/dev/null || true
update_status 5 "Installed"
}
setup_zsh() {
update_status 6 "Running"
print_step "Setting up ZSH"
print_info "Configuring .zshrc and hushlogin..."
touch ../.hushlogin
@@ -111,9 +153,11 @@ setup_zsh() {
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
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
update_status 6 "Installed"
}
setup_tailscale() {
local line="$1"
print_step "Setting up Tailscale"
if ! command -v tailscale > /dev/null 2>&1; then
print_info "Installing Tailscale..."
@@ -122,19 +166,22 @@ setup_tailscale() {
else
print_info "Tailscale is already installed."
fi
update_status "$line" "Installed"
}
setup_wifitui() {
local line="$1"
print_step "Setting up Wifitui"
print_info "Installing Network Manager..."
sudo apt-get install network-manager
sudo apt-get install network-manager -y
print_info "Downloading Wifitui..."
TAG=$(curl -s https://api.github.com/repos/shazow/wifitui/releases/latest | grep "tag_name" | cut -d '"' -f4)
OS="linux-$(uname -m)" # x86_64 or arm64
LATEST_RELEASE="https://github.com/shazow/wifitui/releases/download/${TAG}/wifitui-${TAG:1}-${OS}"
curl -Lfs "${LATEST_RELEASE}.deb" -o /tmp/wifitui.deb
sudo apt install /tmp/wifitui.deb
sudo apt install -y /tmp/wifitui.deb
rm -f /tmp/wifitui.deb
update_status "$line" "Installed"
}
main() {
@@ -171,17 +218,22 @@ main() {
setup_server
setup_docker
setup_zsh
ask_optional_step "Tailscale" setup_tailscale
ask_optional_step "Wifitui" setup_wifitui
ask_optional_step 7 "Tailscale" setup_tailscale
ask_optional_step 8 "Wifitui" setup_wifitui
;;
2)
update_status 7 "Skipped"
update_status 8 "Skipped"
setup_server
setup_docker
setup_zsh
;;
3)
ask_optional_step "Tailscale" setup_tailscale
ask_optional_step "Wifitui" setup_wifitui
update_status 4 "Skipped"
update_status 5 "Skipped"
update_status 6 "Skipped"
ask_optional_step 7 "Tailscale" setup_tailscale
ask_optional_step 8 "Wifitui" setup_wifitui
;;
esac