| | |
| | | #!/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" |