@mcesystems/usbmuxd-instance-manager 1.0.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -0
- package/dist/cli.js +750 -0
- package/dist/cli.js.map +7 -0
- package/dist/cli.mjs +727 -0
- package/dist/cli.mjs.map +7 -0
- package/dist/index.js +680 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +642 -0
- package/dist/index.mjs.map +7 -0
- package/dist/types/InstanceManager.d.ts +114 -0
- package/dist/types/InstanceManager.d.ts.map +1 -0
- package/dist/types/UsbmuxdService.d.ts +59 -0
- package/dist/types/UsbmuxdService.d.ts.map +1 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +125 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +61 -0
- package/prebuilt/alpine-usbmuxd.tar.gz +0 -0
- package/scripts/README.md +191 -0
- package/scripts/attach-device.ps1 +192 -0
- package/scripts/install-windows.ps1 +254 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# usbmuxd Instance Manager Scripts
|
|
2
|
+
|
|
3
|
+
Collection of PowerShell scripts for setting up and managing the usbmuxd instance manager on Windows.
|
|
4
|
+
|
|
5
|
+
## Scripts
|
|
6
|
+
|
|
7
|
+
### install-windows.ps1
|
|
8
|
+
|
|
9
|
+
**Purpose**: Complete installation of all prerequisites for the usbmuxd instance manager.
|
|
10
|
+
|
|
11
|
+
**Features**:
|
|
12
|
+
- Auto-elevates to Administrator if needed
|
|
13
|
+
- Installs/updates WSL2
|
|
14
|
+
- Installs usbipd-win
|
|
15
|
+
- Imports Alpine Linux distribution with usbmuxd
|
|
16
|
+
- Verifies installation
|
|
17
|
+
|
|
18
|
+
**Usage**:
|
|
19
|
+
```powershell
|
|
20
|
+
.\install-windows.ps1
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Options**:
|
|
24
|
+
- `-AlpineImagePath <path>`: Custom path to Alpine image (default: `../prebuilt/alpine-usbmuxd.tar.gz`)
|
|
25
|
+
- `-WslDistroName <name>`: Custom WSL distribution name (default: `alpine-usbmuxd-build`)
|
|
26
|
+
- `-SkipUsbipd`: Skip usbipd-win installation
|
|
27
|
+
- `-SkipWSLUpdate`: Skip WSL2 update
|
|
28
|
+
- `-Force`: Reinstall even if already installed
|
|
29
|
+
|
|
30
|
+
**Examples**:
|
|
31
|
+
```powershell
|
|
32
|
+
# Standard installation
|
|
33
|
+
.\install-windows.ps1
|
|
34
|
+
|
|
35
|
+
# Reinstall everything
|
|
36
|
+
.\install-windows.ps1 -Force
|
|
37
|
+
|
|
38
|
+
# Skip WSL update (if already up to date)
|
|
39
|
+
.\install-windows.ps1 -SkipWSLUpdate
|
|
40
|
+
|
|
41
|
+
# Install with custom distribution name
|
|
42
|
+
.\install-windows.ps1 -WslDistroName "my-usbmuxd-instance"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### attach-device.ps1
|
|
48
|
+
|
|
49
|
+
**Purpose**: Attach Apple devices to the Alpine WSL2 distribution for use with usbmuxd.
|
|
50
|
+
|
|
51
|
+
**Features**:
|
|
52
|
+
- Auto-elevates to Administrator if needed
|
|
53
|
+
- Auto-detects Apple devices
|
|
54
|
+
- Binds devices for sharing
|
|
55
|
+
- Starts WSL distribution
|
|
56
|
+
- Attaches devices to WSL2
|
|
57
|
+
- Verifies device accessibility
|
|
58
|
+
|
|
59
|
+
**Usage**:
|
|
60
|
+
```powershell
|
|
61
|
+
.\attach-device.ps1
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Options**:
|
|
65
|
+
- `-BusId <id>`: Specific USB BusId to attach (auto-detected if not specified)
|
|
66
|
+
- `-WslDistroName <name>`: WSL distribution name (default: `alpine-usbmuxd-build`)
|
|
67
|
+
- `-List`: List all USB devices and exit
|
|
68
|
+
- `-DetachAll`: Detach all devices from WSL
|
|
69
|
+
|
|
70
|
+
**Examples**:
|
|
71
|
+
```powershell
|
|
72
|
+
# Auto-attach first Apple device
|
|
73
|
+
.\attach-device.ps1
|
|
74
|
+
|
|
75
|
+
# List all USB devices
|
|
76
|
+
.\attach-device.ps1 -List
|
|
77
|
+
|
|
78
|
+
# Attach specific device
|
|
79
|
+
.\attach-device.ps1 -BusId 4-5
|
|
80
|
+
|
|
81
|
+
# Detach all devices
|
|
82
|
+
.\attach-device.ps1 -DetachAll
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Workflow
|
|
88
|
+
|
|
89
|
+
### First-Time Setup
|
|
90
|
+
|
|
91
|
+
1. **Install prerequisites**:
|
|
92
|
+
```powershell
|
|
93
|
+
.\install-windows.ps1
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
2. **Connect iOS device** via USB
|
|
97
|
+
|
|
98
|
+
3. **Attach device to WSL**:
|
|
99
|
+
```powershell
|
|
100
|
+
.\attach-device.ps1
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
4. **Test the setup**:
|
|
104
|
+
```powershell
|
|
105
|
+
cd ..
|
|
106
|
+
pnpm run example
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Daily Usage
|
|
110
|
+
|
|
111
|
+
If you've already installed, you only need to attach devices:
|
|
112
|
+
|
|
113
|
+
```powershell
|
|
114
|
+
# Connect device via USB
|
|
115
|
+
.\attach-device.ps1
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Troubleshooting
|
|
119
|
+
|
|
120
|
+
```powershell
|
|
121
|
+
# Check if devices are attached
|
|
122
|
+
.\attach-device.ps1 -List
|
|
123
|
+
|
|
124
|
+
# Detach all devices and start fresh
|
|
125
|
+
.\attach-device.ps1 -DetachAll
|
|
126
|
+
.\attach-device.ps1
|
|
127
|
+
|
|
128
|
+
# Reinstall everything
|
|
129
|
+
.\install-windows.ps1 -Force
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Common Issues
|
|
133
|
+
|
|
134
|
+
### "Access Denied" or "Admin Required"
|
|
135
|
+
|
|
136
|
+
**Solution**: Scripts automatically request Administrator privileges. Make sure to accept the UAC prompt.
|
|
137
|
+
|
|
138
|
+
### "Distribution not found"
|
|
139
|
+
|
|
140
|
+
**Solution**: Run the installer:
|
|
141
|
+
```powershell
|
|
142
|
+
.\install-windows.ps1
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### "Device not detected in WSL"
|
|
146
|
+
|
|
147
|
+
**Solution**:
|
|
148
|
+
1. Make sure device is attached:
|
|
149
|
+
```powershell
|
|
150
|
+
.\attach-device.ps1 -List
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
2. Re-attach if needed:
|
|
154
|
+
```powershell
|
|
155
|
+
.\attach-device.ps1 -DetachAll
|
|
156
|
+
.\attach-device.ps1
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### "WSL keeps shutting down"
|
|
160
|
+
|
|
161
|
+
**Solution**: The attach script starts a 10-minute keep-alive job. For longer sessions:
|
|
162
|
+
```powershell
|
|
163
|
+
# Start a 24-hour keep-alive
|
|
164
|
+
Start-Job { wsl -d alpine-usbmuxd-build sleep 86400 }
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Technical Details
|
|
168
|
+
|
|
169
|
+
### Alpine Image
|
|
170
|
+
|
|
171
|
+
- **Location**: `../prebuilt/alpine-usbmuxd.tar.gz`
|
|
172
|
+
- **Size**: ~26 MB
|
|
173
|
+
- **Contents**: Alpine Linux 3.19 with usbmuxd v1.1.1
|
|
174
|
+
|
|
175
|
+
### WSL Distribution
|
|
176
|
+
|
|
177
|
+
- **Default Name**: `alpine-usbmuxd-build`
|
|
178
|
+
- **Install Location**: `%LOCALAPPDATA%\usbmuxd-alpine`
|
|
179
|
+
- **Storage**: Dynamic (starts small, grows as needed)
|
|
180
|
+
|
|
181
|
+
### Ports
|
|
182
|
+
|
|
183
|
+
- **Instance 1**: 27015
|
|
184
|
+
- **Instance 2**: 27016
|
|
185
|
+
- **Instance N**: 27015 + N - 1
|
|
186
|
+
|
|
187
|
+
## See Also
|
|
188
|
+
|
|
189
|
+
- [SETUP.md](../SETUP.md) - Complete setup guide
|
|
190
|
+
- [README.md](../README.md) - Package documentation
|
|
191
|
+
- [Examples](../src/examples/) - Usage examples
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Device Attachment Script for usbmuxd Instance Manager
|
|
2
|
+
# This script attaches Apple devices to the Alpine WSL2 distribution
|
|
3
|
+
# Requires Administrator privileges (will auto-elevate)
|
|
4
|
+
|
|
5
|
+
param(
|
|
6
|
+
[string]$WslDistroName = "alpine-usbmuxd-build",
|
|
7
|
+
[string]$BusId = "",
|
|
8
|
+
[switch]$List = $false,
|
|
9
|
+
[switch]$DetachAll = $false
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
$ErrorActionPreference = "Stop"
|
|
13
|
+
|
|
14
|
+
# Check if running as Administrator
|
|
15
|
+
function Test-Administrator {
|
|
16
|
+
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
17
|
+
$principal = New-Object Security.Principal.WindowsPrincipal($user)
|
|
18
|
+
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Auto-elevate to Administrator if not already running as admin
|
|
22
|
+
if (-not (Test-Administrator)) {
|
|
23
|
+
Write-Host "Requesting Administrator privileges..." -ForegroundColor Yellow
|
|
24
|
+
|
|
25
|
+
$argList = @(
|
|
26
|
+
"-NoProfile"
|
|
27
|
+
"-ExecutionPolicy Bypass"
|
|
28
|
+
"-File `"$PSCommandPath`""
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
if ($WslDistroName -ne "alpine-usbmuxd-build") {
|
|
32
|
+
$argList += "-WslDistroName `"$WslDistroName`""
|
|
33
|
+
}
|
|
34
|
+
if ($BusId) { $argList += "-BusId `"$BusId`"" }
|
|
35
|
+
if ($List) { $argList += "-List" }
|
|
36
|
+
if ($DetachAll) { $argList += "-DetachAll" }
|
|
37
|
+
|
|
38
|
+
$process = Start-Process powershell.exe -Verb RunAs -ArgumentList ($argList -join " ") -Wait -PassThru
|
|
39
|
+
exit $process.ExitCode
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
$programFiles = $env:ProgramFiles
|
|
43
|
+
$usbipdPath = Join-Path $programFiles "usbipd-win\usbipd.exe"
|
|
44
|
+
|
|
45
|
+
# Check if usbipd is installed
|
|
46
|
+
if (-not (Test-Path $usbipdPath)) {
|
|
47
|
+
Write-Host "✗ usbipd-win is not installed" -ForegroundColor Red
|
|
48
|
+
Write-Host " Please run the installation script first: .\scripts\install-windows.ps1" -ForegroundColor Yellow
|
|
49
|
+
Read-Host "Press Enter to exit"
|
|
50
|
+
exit 1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Write-Host "`n=== Apple Device Attachment ===" -ForegroundColor Cyan
|
|
54
|
+
Write-Host ""
|
|
55
|
+
|
|
56
|
+
# List devices
|
|
57
|
+
if ($List) {
|
|
58
|
+
Write-Host "Connected USB devices:" -ForegroundColor Cyan
|
|
59
|
+
& $usbipdPath list
|
|
60
|
+
Read-Host "`nPress Enter to exit"
|
|
61
|
+
exit 0
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Detach all devices
|
|
65
|
+
if ($DetachAll) {
|
|
66
|
+
Write-Host "Detaching all devices from WSL..." -ForegroundColor Yellow
|
|
67
|
+
$devices = & $usbipdPath list 2>&1 | Select-String "Attached"
|
|
68
|
+
|
|
69
|
+
if ($devices) {
|
|
70
|
+
foreach ($device in $devices) {
|
|
71
|
+
$busId = ($device -split "\s+")[0]
|
|
72
|
+
Write-Host " Detaching $busId..."
|
|
73
|
+
& $usbipdPath detach --busid $busId 2>&1 | Out-Null
|
|
74
|
+
}
|
|
75
|
+
Write-Host "✓ All devices detached" -ForegroundColor Green
|
|
76
|
+
} else {
|
|
77
|
+
Write-Host " No attached devices found" -ForegroundColor Yellow
|
|
78
|
+
}
|
|
79
|
+
Read-Host "`nPress Enter to exit"
|
|
80
|
+
exit 0
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# List all devices
|
|
84
|
+
Write-Host "Step 1: Listing USB devices..." -ForegroundColor Cyan
|
|
85
|
+
$deviceList = & $usbipdPath list 2>&1
|
|
86
|
+
|
|
87
|
+
# Find Apple devices
|
|
88
|
+
$appleDevices = $deviceList | Select-String "05ac:" | Where-Object { $_ -match "Apple" }
|
|
89
|
+
|
|
90
|
+
if (-not $appleDevices) {
|
|
91
|
+
Write-Host "✗ No Apple devices found" -ForegroundColor Red
|
|
92
|
+
Write-Host " Please connect an iOS device via USB" -ForegroundColor Yellow
|
|
93
|
+
Write-Host ""
|
|
94
|
+
Write-Host "All connected devices:" -ForegroundColor Cyan
|
|
95
|
+
Write-Host $deviceList
|
|
96
|
+
Read-Host "`nPress Enter to exit"
|
|
97
|
+
exit 1
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Write-Host "✓ Found Apple device(s):" -ForegroundColor Green
|
|
101
|
+
$appleDevices | ForEach-Object { Write-Host " $_" }
|
|
102
|
+
Write-Host ""
|
|
103
|
+
|
|
104
|
+
# If BusId not specified, auto-detect
|
|
105
|
+
if (-not $BusId) {
|
|
106
|
+
# Parse first Apple device BusId
|
|
107
|
+
$firstDevice = $appleDevices | Select-Object -First 1
|
|
108
|
+
$BusId = ($firstDevice -split "\s+")[0]
|
|
109
|
+
Write-Host "Auto-detected BusId: $BusId" -ForegroundColor Cyan
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Step 2: Bind (share) the device
|
|
113
|
+
Write-Host "`nStep 2: Binding device $BusId..." -ForegroundColor Cyan
|
|
114
|
+
|
|
115
|
+
$bindResult = & $usbipdPath bind --busid $BusId --force 2>&1
|
|
116
|
+
if ($LASTEXITCODE -ne 0) {
|
|
117
|
+
# Check if already bound
|
|
118
|
+
if ($bindResult -match "already") {
|
|
119
|
+
Write-Host "✓ Device already bound" -ForegroundColor Green
|
|
120
|
+
} else {
|
|
121
|
+
Write-Host "✗ Failed to bind device" -ForegroundColor Red
|
|
122
|
+
Write-Host " $bindResult" -ForegroundColor Yellow
|
|
123
|
+
Read-Host "`nPress Enter to exit"
|
|
124
|
+
exit 1
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
Write-Host "✓ Device bound successfully" -ForegroundColor Green
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# Step 3: Start WSL distribution (keep-alive)
|
|
131
|
+
Write-Host "`nStep 3: Starting WSL distribution..." -ForegroundColor Cyan
|
|
132
|
+
|
|
133
|
+
$wslProcess = Start-Job -ScriptBlock {
|
|
134
|
+
param($distro)
|
|
135
|
+
wsl -d $distro sleep 600
|
|
136
|
+
} -ArgumentList $WslDistroName
|
|
137
|
+
|
|
138
|
+
Start-Sleep -Seconds 2
|
|
139
|
+
|
|
140
|
+
if ($wslProcess.State -eq "Running") {
|
|
141
|
+
Write-Host "✓ WSL distribution is running" -ForegroundColor Green
|
|
142
|
+
} else {
|
|
143
|
+
Write-Host "✗ Failed to start WSL distribution" -ForegroundColor Red
|
|
144
|
+
Read-Host "`nPress Enter to exit"
|
|
145
|
+
exit 1
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Step 4: Attach device to WSL
|
|
149
|
+
Write-Host "`nStep 4: Attaching device to WSL..." -ForegroundColor Cyan
|
|
150
|
+
|
|
151
|
+
& $usbipdPath attach --wsl $WslDistroName --busid $BusId 2>&1
|
|
152
|
+
if ($LASTEXITCODE -ne 0) {
|
|
153
|
+
Write-Host "✗ Failed to attach device to WSL" -ForegroundColor Red
|
|
154
|
+
Stop-Job $wslProcess
|
|
155
|
+
Remove-Job $wslProcess
|
|
156
|
+
Read-Host "`nPress Enter to exit"
|
|
157
|
+
exit 1
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Write-Host "✓ Device attached to WSL" -ForegroundColor Green
|
|
161
|
+
|
|
162
|
+
# Step 5: Verify attachment
|
|
163
|
+
Write-Host "`nStep 5: Verifying device in WSL..." -ForegroundColor Cyan
|
|
164
|
+
|
|
165
|
+
$lsusbOutput = wsl -d $WslDistroName lsusb 2>&1
|
|
166
|
+
if ($LASTEXITCODE -eq 0 -and $lsusbOutput -match "Apple") {
|
|
167
|
+
Write-Host "✓ Device is visible in WSL" -ForegroundColor Green
|
|
168
|
+
$appleDeviceInWsl = $lsusbOutput | Select-String "Apple"
|
|
169
|
+
Write-Host " $appleDeviceInWsl" -ForegroundColor White
|
|
170
|
+
} else {
|
|
171
|
+
Write-Host "⚠ Could not verify device in WSL" -ForegroundColor Yellow
|
|
172
|
+
Write-Host " $lsusbOutput" -ForegroundColor Yellow
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# Success summary
|
|
176
|
+
Write-Host "`n=== Attachment Complete ===" -ForegroundColor Cyan
|
|
177
|
+
Write-Host ""
|
|
178
|
+
Write-Host "✓ Apple device attached successfully!" -ForegroundColor Green
|
|
179
|
+
Write-Host " BusId: $BusId" -ForegroundColor White
|
|
180
|
+
Write-Host " WSL Distribution: $WslDistroName" -ForegroundColor White
|
|
181
|
+
Write-Host ""
|
|
182
|
+
Write-Host "The WSL distribution will remain running in the background." -ForegroundColor Yellow
|
|
183
|
+
Write-Host "To stop it, run: wsl --shutdown" -ForegroundColor Yellow
|
|
184
|
+
Write-Host ""
|
|
185
|
+
Write-Host "Next steps:" -ForegroundColor Cyan
|
|
186
|
+
Write-Host "1. Start the usbmuxd instance manager"
|
|
187
|
+
Write-Host "2. The device will be automatically detected and assigned to a port"
|
|
188
|
+
Write-Host ""
|
|
189
|
+
Write-Host "To detach devices, run:" -ForegroundColor Cyan
|
|
190
|
+
Write-Host " .\scripts\attach-device.ps1 -DetachAll" -ForegroundColor White
|
|
191
|
+
Write-Host ""
|
|
192
|
+
Read-Host "Press Enter to exit"
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# usbmuxd Instance Manager - Windows Setup Script
|
|
2
|
+
# This script installs all prerequisites needed for the usbmuxd instance manager on Windows
|
|
3
|
+
#
|
|
4
|
+
# Prerequisites:
|
|
5
|
+
# - Windows 10/11 with WSL2 support
|
|
6
|
+
# - Administrator privileges (will auto-elevate)
|
|
7
|
+
# - Internet connection for downloads
|
|
8
|
+
|
|
9
|
+
param(
|
|
10
|
+
[string]$AlpineImagePath = "$PSScriptRoot\..\prebuilt\alpine-usbmuxd.tar.gz",
|
|
11
|
+
[string]$WslDistroName = "alpine-usbmuxd-build",
|
|
12
|
+
[switch]$SkipUsbipd = $false,
|
|
13
|
+
[switch]$SkipWSLUpdate = $false,
|
|
14
|
+
[switch]$Force = $false
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
$ErrorActionPreference = "Stop"
|
|
18
|
+
|
|
19
|
+
# Check if running as Administrator
|
|
20
|
+
function Test-Administrator {
|
|
21
|
+
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
22
|
+
$principal = New-Object Security.Principal.WindowsPrincipal($user)
|
|
23
|
+
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# Auto-elevate to Administrator if not already running as admin
|
|
27
|
+
if (-not (Test-Administrator)) {
|
|
28
|
+
Write-Host "Requesting Administrator privileges..." -ForegroundColor Yellow
|
|
29
|
+
|
|
30
|
+
# Build argument string
|
|
31
|
+
$argList = @(
|
|
32
|
+
"-NoProfile"
|
|
33
|
+
"-ExecutionPolicy Bypass"
|
|
34
|
+
"-File `"$PSCommandPath`""
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Add original parameters
|
|
38
|
+
if ($AlpineImagePath -ne "$PSScriptRoot\..\prebuilt\alpine-usbmuxd.tar.gz") {
|
|
39
|
+
$argList += "-AlpineImagePath `"$AlpineImagePath`""
|
|
40
|
+
}
|
|
41
|
+
if ($WslDistroName -ne "alpine-usbmuxd-build") {
|
|
42
|
+
$argList += "-WslDistroName `"$WslDistroName`""
|
|
43
|
+
}
|
|
44
|
+
if ($SkipUsbipd) { $argList += "-SkipUsbipd" }
|
|
45
|
+
if ($SkipWSLUpdate) { $argList += "-SkipWSLUpdate" }
|
|
46
|
+
if ($Force) { $argList += "-Force" }
|
|
47
|
+
|
|
48
|
+
# Start elevated process
|
|
49
|
+
$process = Start-Process powershell.exe -Verb RunAs -ArgumentList ($argList -join " ") -Wait -PassThru
|
|
50
|
+
exit $process.ExitCode
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Colors for output
|
|
54
|
+
function Write-Step {
|
|
55
|
+
param([string]$Message)
|
|
56
|
+
Write-Host "`n=== $Message ===" -ForegroundColor Cyan
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function Write-Success {
|
|
60
|
+
param([string]$Message)
|
|
61
|
+
Write-Host "✓ $Message" -ForegroundColor Green
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function Write-Info {
|
|
65
|
+
param([string]$Message)
|
|
66
|
+
Write-Host " $Message" -ForegroundColor White
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function Write-Warn {
|
|
70
|
+
param([string]$Message)
|
|
71
|
+
Write-Host "⚠ $Message" -ForegroundColor Yellow
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function Write-Fail {
|
|
75
|
+
param([string]$Message)
|
|
76
|
+
Write-Host "✗ $Message" -ForegroundColor Red
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Write-Host @"
|
|
80
|
+
|
|
81
|
+
╔════════════════════════════════════════════════════════════════╗
|
|
82
|
+
║ ║
|
|
83
|
+
║ usbmuxd Instance Manager - Windows Setup ║
|
|
84
|
+
║ ║
|
|
85
|
+
╚════════════════════════════════════════════════════════════════╝
|
|
86
|
+
|
|
87
|
+
"@ -ForegroundColor Cyan
|
|
88
|
+
|
|
89
|
+
Write-Success "Running with Administrator privileges"
|
|
90
|
+
|
|
91
|
+
# Step 1: Check WSL2
|
|
92
|
+
Write-Step "Step 1: Checking WSL2"
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
$wslVersion = wsl --version 2>&1
|
|
96
|
+
if ($LASTEXITCODE -ne 0) {
|
|
97
|
+
Write-Fail "WSL2 is not installed"
|
|
98
|
+
Write-Info "Installing WSL2..."
|
|
99
|
+
wsl --install --no-distribution
|
|
100
|
+
Write-Warn "WSL2 installed. Please reboot your computer and run this script again."
|
|
101
|
+
Read-Host "Press Enter to exit"
|
|
102
|
+
exit 0
|
|
103
|
+
}
|
|
104
|
+
Write-Success "WSL2 is installed"
|
|
105
|
+
} catch {
|
|
106
|
+
Write-Fail "Failed to check WSL2: $_"
|
|
107
|
+
Read-Host "Press Enter to exit"
|
|
108
|
+
exit 1
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
# Step 2: Update WSL2
|
|
112
|
+
if (-not $SkipWSLUpdate) {
|
|
113
|
+
Write-Step "Step 2: Updating WSL2"
|
|
114
|
+
try {
|
|
115
|
+
wsl --update
|
|
116
|
+
Write-Success "WSL2 updated"
|
|
117
|
+
} catch {
|
|
118
|
+
Write-Warn "Failed to update WSL2: $_"
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
Write-Info "Skipping WSL2 update (--SkipWSLUpdate specified)"
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
# Step 3: Install usbipd-win
|
|
125
|
+
if (-not $SkipUsbipd) {
|
|
126
|
+
Write-Step "Step 3: Installing usbipd-win"
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
$programFiles = $env:ProgramFiles
|
|
130
|
+
$usbipdPath = Join-Path $programFiles "usbipd-win\usbipd.exe"
|
|
131
|
+
if ((Test-Path $usbipdPath) -and -not $Force) {
|
|
132
|
+
Write-Success "usbipd-win is already installed"
|
|
133
|
+
$version = & $usbipdPath --version 2>&1
|
|
134
|
+
Write-Info "Version: $version"
|
|
135
|
+
} else {
|
|
136
|
+
Write-Info "Installing usbipd-win via winget..."
|
|
137
|
+
winget install --id dorssel.usbipd-win --accept-package-agreements --accept-source-agreements
|
|
138
|
+
if ($LASTEXITCODE -ne 0) {
|
|
139
|
+
Write-Fail "Failed to install usbipd-win"
|
|
140
|
+
Read-Host "Press Enter to exit"
|
|
141
|
+
exit 1
|
|
142
|
+
}
|
|
143
|
+
Write-Success "usbipd-win installed"
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
Write-Fail "Failed to install usbipd-win: $_"
|
|
147
|
+
Read-Host "Press Enter to exit"
|
|
148
|
+
exit 1
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
Write-Info "Skipping usbipd-win installation (--SkipUsbipd specified)"
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
# Step 4: Check Alpine image
|
|
155
|
+
Write-Step "Step 4: Checking Alpine Linux image"
|
|
156
|
+
|
|
157
|
+
if (-not (Test-Path $AlpineImagePath)) {
|
|
158
|
+
Write-Fail "Alpine image not found at: $AlpineImagePath"
|
|
159
|
+
Write-Info "Please ensure the prebuilt Alpine image is available"
|
|
160
|
+
Read-Host "Press Enter to exit"
|
|
161
|
+
exit 1
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
$imageSize = (Get-Item $AlpineImagePath).Length / 1MB
|
|
165
|
+
Write-Success "Alpine image found ($([math]::Round($imageSize, 2)) MB)"
|
|
166
|
+
|
|
167
|
+
# Step 5: Import Alpine WSL2 distribution
|
|
168
|
+
Write-Step "Step 5: Importing Alpine WSL2 distribution"
|
|
169
|
+
|
|
170
|
+
# Check if distribution already exists
|
|
171
|
+
$existingDistros = wsl --list --quiet 2>&1 | ForEach-Object { $_.Trim() }
|
|
172
|
+
$distroExists = $existingDistros -contains $WslDistroName
|
|
173
|
+
|
|
174
|
+
if ($distroExists) {
|
|
175
|
+
if ($Force) {
|
|
176
|
+
Write-Warn "Distribution '$WslDistroName' already exists. Removing..."
|
|
177
|
+
wsl --unregister $WslDistroName
|
|
178
|
+
Write-Success "Existing distribution removed"
|
|
179
|
+
$distroExists = $false
|
|
180
|
+
} else {
|
|
181
|
+
Write-Success "Distribution '$WslDistroName' already exists"
|
|
182
|
+
Write-Info "Use -Force to reinstall"
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (-not $distroExists) {
|
|
187
|
+
Write-Info "Importing Alpine distribution..."
|
|
188
|
+
$installPath = "$env:LOCALAPPDATA\usbmuxd-alpine"
|
|
189
|
+
|
|
190
|
+
# Create install directory
|
|
191
|
+
if (-not (Test-Path $installPath)) {
|
|
192
|
+
New-Item -ItemType Directory -Path $installPath -Force | Out-Null
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
# Import the distribution
|
|
196
|
+
wsl --import $WslDistroName $installPath $AlpineImagePath
|
|
197
|
+
|
|
198
|
+
if ($LASTEXITCODE -ne 0) {
|
|
199
|
+
Write-Fail "Failed to import Alpine distribution"
|
|
200
|
+
Read-Host "Press Enter to exit"
|
|
201
|
+
exit 1
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
Write-Success "Alpine distribution imported"
|
|
205
|
+
Write-Info "Install location: $installPath"
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# Step 6: Verify Alpine distribution
|
|
209
|
+
Write-Step "Step 6: Verifying Alpine distribution"
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
$testOutput = wsl -d $WslDistroName uname -r 2>&1
|
|
213
|
+
if ($LASTEXITCODE -eq 0) {
|
|
214
|
+
Write-Success "Alpine distribution is working"
|
|
215
|
+
Write-Info "Kernel: $testOutput"
|
|
216
|
+
} else {
|
|
217
|
+
Write-Fail "Failed to verify Alpine distribution"
|
|
218
|
+
Read-Host "Press Enter to exit"
|
|
219
|
+
exit 1
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
# Check usbmuxd installation
|
|
223
|
+
$usbmuxdCheck = wsl -d $WslDistroName which usbmuxd 2>&1
|
|
224
|
+
if ($LASTEXITCODE -eq 0) {
|
|
225
|
+
Write-Success "usbmuxd is installed in Alpine"
|
|
226
|
+
Write-Info "Path: $usbmuxdCheck"
|
|
227
|
+
} else {
|
|
228
|
+
Write-Fail "usbmuxd not found in Alpine distribution"
|
|
229
|
+
Read-Host "Press Enter to exit"
|
|
230
|
+
exit 1
|
|
231
|
+
}
|
|
232
|
+
} catch {
|
|
233
|
+
Write-Fail "Failed to verify Alpine distribution: $_"
|
|
234
|
+
Read-Host "Press Enter to exit"
|
|
235
|
+
exit 1
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
# Step 7: Setup complete
|
|
239
|
+
Write-Step "Setup Complete"
|
|
240
|
+
|
|
241
|
+
Write-Success "All prerequisites installed successfully!"
|
|
242
|
+
Write-Host ""
|
|
243
|
+
Write-Info "Next steps:"
|
|
244
|
+
Write-Info "1. Connect an iOS device via USB"
|
|
245
|
+
Write-Info "2. Run the device attachment script:"
|
|
246
|
+
Write-Info " .\scripts\attach-device.ps1"
|
|
247
|
+
Write-Info "3. Start using the usbmuxd instance manager"
|
|
248
|
+
Write-Host ""
|
|
249
|
+
Write-Info "Quick test:"
|
|
250
|
+
Write-Info " cd packages\usbmuxd-instance-manager"
|
|
251
|
+
Write-Info " pnpm run example"
|
|
252
|
+
Write-Host ""
|
|
253
|
+
Write-Info "Press Enter to exit..."
|
|
254
|
+
Read-Host
|