Browse Source

Install/update WiFi host scripts during dw update and dw checkout

- dw update: if autohotspot not installed, run full setup-wifi.sh;
  if already installed, update script and service files to latest
- dw checkout: install WiFi scripts if branch has them but host doesn't
- setup-pi.sh already handles fresh installs via setup_autohotspot()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tuanchris 4 tháng trước cách đây
mục cha
commit
16bff68f84
1 tập tin đã thay đổi với 28 bổ sung0 xóa
  1. 28 0
      dw

+ 28 - 0
dw

@@ -182,6 +182,27 @@ cmd_update() {
         sudo systemctl restart dune-weaver
     fi
 
+    # Install/update WiFi host scripts if not present
+    if [[ -f "$INSTALL_DIR/wifi/setup-wifi.sh" ]]; then
+        if [[ ! -f /usr/local/bin/autohotspot ]]; then
+            echo ""
+            echo -e "${BLUE}Installing autohotspot WiFi scripts...${NC}"
+            sudo bash "$INSTALL_DIR/wifi/setup-wifi.sh"
+        else
+            # Always update the script and service files to latest
+            echo "Updating WiFi host scripts..."
+            sudo cp "$INSTALL_DIR/wifi/autohotspot" /usr/local/bin/autohotspot
+            sudo chmod +x /usr/local/bin/autohotspot
+
+            # Update service/timer files
+            sudo cp "$INSTALL_DIR/wifi/autohotspot.service" /etc/systemd/system/autohotspot.service
+            sudo cp "$INSTALL_DIR/wifi/autohotspot-check.service" /etc/systemd/system/autohotspot-check.service 2>/dev/null || true
+            sudo cp "$INSTALL_DIR/wifi/autohotspot-check.timer" /etc/systemd/system/autohotspot-check.timer 2>/dev/null || true
+            sudo systemctl daemon-reload
+            sudo systemctl enable autohotspot-check.timer 2>/dev/null || true
+        fi
+    fi
+
     # Update touch app if installed (check both directory and service exist)
     local touch_dir="$INSTALL_DIR/dune-weaver-touch"
     if [[ -d "$touch_dir" ]] && systemctl list-unit-files dune-weaver-touch.service 2>/dev/null | grep -q dune-weaver-touch; then
@@ -367,6 +388,13 @@ cmd_checkout() {
     sudo cp "$INSTALL_DIR/dw" /usr/local/bin/dw
     sudo chmod +x /usr/local/bin/dw
 
+    # Install WiFi scripts if available on this branch but not yet installed
+    if [[ -f "$INSTALL_DIR/wifi/setup-wifi.sh" ]] && [[ ! -f /usr/local/bin/autohotspot ]]; then
+        echo ""
+        echo -e "${BLUE}Installing autohotspot WiFi scripts...${NC}"
+        sudo bash "$INSTALL_DIR/wifi/setup-wifi.sh"
+    fi
+
     echo -e "${GREEN}Checkout complete!${NC}"
 }