diff --git a/setup_homelogic.sh b/setup_homelogic.sh index 3a0e5df..5d0c280 100755 --- a/setup_homelogic.sh +++ b/setup_homelogic.sh @@ -14,6 +14,22 @@ print_info() { printf "${CYAN}➜ %s${NC}\n" "$1" } +ask_optional_step() { + local step_name="$1" + local callback="$2" + + 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." + ;; + * ) + $callback + ;; + esac +} + setup_server() { print_step "Setting up Server" print_info "Updating packages and configuring firewall..." @@ -71,29 +87,33 @@ setup_zsh() { setup_tailscale() { print_step "Setting up Tailscale" - printf "\n${YELLOW}❓ Do you want to install and setup Tailscale? [Y/n] ${NC}" - read choice - case "$choice" in - n|N|no|No|NO ) - print_info "Skipping Tailscale setup." - ;; - * ) - if ! command -v tailscale > /dev/null 2>&1; then - print_info "Installing Tailscale..." - curl -fsSL https://tailscale.com/install.sh | sh - sudo tailscale up - else - print_info "Tailscale is already installed." - fi - ;; - esac + if ! command -v tailscale > /dev/null 2>&1; then + print_info "Installing Tailscale..." + curl -fsSL https://tailscale.com/install.sh | sh + sudo tailscale up + else + print_info "Tailscale is already installed." + fi +} + +setup_wifitui() { + print_step "Setting up Wifitui" + 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 + rm -f /tmp/wifitui.deb } main() { setup_server setup_docker setup_zsh - setup_tailscale + + ask_optional_step "Tailscale" setup_tailscale + ask_optional_step "Wifitui" setup_wifitui printf "\n${GREEN}✔ Setup complete! Please log out and log back in for all changes to take effect.${NC}\n" }