forked from 34306/vphone-aio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvphone-aio.sh
More file actions
executable file
·178 lines (149 loc) · 5.72 KB
/
vphone-aio.sh
File metadata and controls
executable file
·178 lines (149 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
#
# vphone-aio — All-in-one vPhone launcher
#
# Extracts vphone-cli.tar.zst (if needed), builds & boots the VM,
# starts iproxy tunnels for SSH and VNC, then waits.
# Press Ctrl+C to stop everything cleanly.
#
# Prerequisites:
# - macOS with Xcode (swift, codesign)
# - SIP/AMFI disabled (amfi_get_out_of_my_way=1)
# - libimobiledevice (iproxy) — brew install libimobiledevice
# - zstd — brew install zstd
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ARCHIVE="$SCRIPT_DIR/vphone-cli.tar.zst"
PROJECT="$SCRIPT_DIR/vphone-cli"
BOOT_PID=""
IPROXY_SSH_PID=""
IPROXY_VNC_PID=""
# ── Cleanup on exit ──────────────────────────────────────────────
cleanup() {
echo ""
echo "=========================================="
echo " Shutting down vPhone..."
echo "=========================================="
for pid_var in BOOT_PID IPROXY_SSH_PID IPROXY_VNC_PID; do
pid="${!pid_var}"
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
kill "$pid" 2>/dev/null
fi
done
sleep 2
for pid_var in BOOT_PID IPROXY_SSH_PID IPROXY_VNC_PID; do
pid="${!pid_var}"
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
kill -9 "$pid" 2>/dev/null
fi
done
echo ""
echo " All processes stopped. Goodbye!"
echo "=========================================="
exit 0
}
trap cleanup SIGINT SIGTERM EXIT
# ── Preflight checks ────────────────────────────────────────────
echo "=========================================="
echo " vPhone — All-in-one Launcher"
echo "=========================================="
echo ""
missing=()
command -v swift >/dev/null 2>&1 || missing+=("swift (Xcode)")
command -v iproxy >/dev/null 2>&1 || missing+=("iproxy (brew install libimobiledevice)")
if [ ${#missing[@]} -gt 0 ]; then
echo "ERROR: Missing required tools:"
for m in "${missing[@]}"; do
echo " - $m"
done
exit 1
fi
ALL_SUFFIXES=(aa ab ac ad ae af ag)
REPO_URL="https://github.com/34306/vphone-aio/raw/refs/heads/main"
# ── Download missing parts ───────────────────────────────────────
download_missing_parts() {
local need_download=false
for suffix in "${ALL_SUFFIXES[@]}"; do
local part_file="$SCRIPT_DIR/vphone-cli.tar.zst.part_${suffix}"
if [ ! -f "$part_file" ]; then
need_download=true
break
fi
done
if $need_download; then
command -v wget >/dev/null 2>&1 || {
echo "ERROR: wget not found. Install with: brew install wget"
exit 1
}
echo " Some split parts are missing. Downloading..."
echo ""
for suffix in "${ALL_SUFFIXES[@]}"; do
local part_file="$SCRIPT_DIR/vphone-cli.tar.zst.part_${suffix}"
if [ ! -f "$part_file" ]; then
echo " Downloading vphone-cli.tar.zst.part_${suffix} ..."
wget -q --show-progress -O "$part_file" \
"${REPO_URL}/vphone-cli.tar.zst.part_${suffix}?download=" || {
echo "ERROR: Failed to download part_${suffix}"
rm -f "$part_file"
exit 1
}
fi
done
echo ""
fi
}
# ── Merge split parts & extract if needed ────────────────────────
if [ ! -d "$PROJECT" ]; then
command -v zstd >/dev/null 2>&1 || {
echo "ERROR: zstd not found. Install with: brew install zstd"
exit 1
}
# Merge split parts if the full archive doesn't exist yet
if [ ! -f "$ARCHIVE" ]; then
echo "[1/4] Checking split parts..."
download_missing_parts
PARTS=("$SCRIPT_DIR"/vphone-cli.tar.zst.part_*)
echo "[2/4] Merging ${#PARTS[@]} split parts into vphone-cli.tar.zst ..."
cat "$SCRIPT_DIR"/vphone-cli.tar.zst.part_* > "$ARCHIVE"
echo " Done. ($(du -h "$ARCHIVE" | cut -f1))"
echo ""
echo "[3/4] Extracting vphone-cli.tar.zst ..."
else
echo "[1/4] vphone-cli.tar.zst already exists, skipping download & merge."
echo ""
echo "[3/4] Extracting vphone-cli.tar.zst ..."
fi
zstd -dc "$ARCHIVE" | tar xf - -C "$SCRIPT_DIR"
echo " Done."
# Clean up the merged archive and split parts to save disk space
rm -f "$ARCHIVE"
rm -f "$SCRIPT_DIR"/vphone-cli.tar.zst.part_*
echo " Cleaned up archive and split parts to save space."
else
echo "[1/4] vphone-cli/ already exists, skipping merge & extraction."
fi
echo ""
# ── Start iproxy tunnels ─────────────────────────────────────────
echo "[3/4] Starting iproxy tunnels ..."
iproxy 22222 22222 >/dev/null 2>&1 &
IPROXY_SSH_PID=$!
echo " SSH : localhost:22222 -> device:22222"
iproxy 5901 5901 >/dev/null 2>&1 &
IPROXY_VNC_PID=$!
echo " VNC : localhost:5901 -> device:5901"
# ── Build & Boot VM ──────────────────────────────────────────────
echo ""
echo "[4/4] Building and booting the VM ..."
echo ""
echo "=========================================="
echo ""
echo " Connect via VNC : vnc://127.0.0.1:5901"
echo " Connect via SSH : ssh -p 22222 [email protected]"
echo ""
echo " Press Ctrl+C to stop everything."
echo ""
echo "=========================================="
echo ""
cd "$PROJECT"
./boot.sh