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
·141 lines (117 loc) · 4.45 KB
/
Copy pathvphone-aio.sh
File metadata and controls
executable file
·141 lines (117 loc) · 4.45 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
#!/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
# ── 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
PARTS=("$SCRIPT_DIR"/vphone-cli.tar.zst.part_*)
if [ ${#PARTS[@]} -eq 0 ] || [ ! -f "${PARTS[0]}" ]; then
echo "ERROR: No vphone-cli.tar.zst or split parts found."
echo "Make sure vphone-cli.tar.zst.part_* files are next to this script."
exit 1
fi
echo "[1/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 "[2/4] Extracting vphone-cli.tar.zst ..."
else
echo "[1/4] vphone-cli.tar.zst already exists, skipping merge."
echo ""
echo "[2/4] Extracting vphone-cli.tar.zst ..."
fi
zstd -dc "$ARCHIVE" | tar xf - -C "$SCRIPT_DIR"
echo " Done."
# Clean up the merged archive to save disk space
rm -f "$ARCHIVE"
echo " Cleaned up archive 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 root@127.0.0.1"
echo ""
echo " Press Ctrl+C to stop everything."
echo ""
echo "=========================================="
echo ""
cd "$PROJECT"
./boot.sh