wangzhibo
2025-08-04 f5106b912f1261fe633aa6bcdf10a4b7e74345aa
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
#!/data/data/com.termux/files/usr/bin/env bash
 
pkg install tmux
 
# 1. get phone number
phone="$1"
 
if [[ ! "$phone" =~ ^[0-9]{11}$ ]]; then
    echo "please input 11 digital phone number"
    exit 1
fi
 
# 2. process toml config file
name="$phone"
remotePort="${phone: -4}"
TOML_FILE="./sening_vdp2.toml"
 
if [ ! -f "$TOML_FILE" ]; then
    echo "file sening_vdp2.toml does not exist!"
    exit 1
fi
 
# modify sening_vdp2.toml 's name and remotePort
sed -i "s/^name *= *.*/name = \"$name\"/" "$TOML_FILE"
sed -i "s/^remotePort *= *.*/remotePort = $remotePort/" "$TOML_FILE"
 
echo "✅ sening_vdp2.toml config already updated."
 
# 3. create .termux/boot dir
mkdir -p ~/.termux/boot
 
# 4. chmod
chmod +x sening_vdp1 sening_vdp2 start_service.sh
 
# 5. move start.sh to .termux/boot
cp start_service.sh ~/.termux/boot/
chmod +x ~/.termux/boot/start_service.sh
 
# 6 追加启动命令到 .bashrc (避免重复添加)
grep -qxF "bash $HOME/start_service.sh" ~/.bashrc || echo "bash $HOME/start_service.sh" >> ~/.bashrc
 
echo "✅ setup.sh finished"