45 lines
1.1 KiB
Bash
Raw Normal View History

2023-05-28 12:31:46 +08:00
#!/bin/bash
# 解析命令行参数
2023-06-04 02:28:45 +08:00
while getopts ":p:s:t:r:k:" opt; do
2023-05-28 12:31:46 +08:00
case $opt in
2023-05-29 18:00:33 +08:00
p) frpc_server_port=$OPTARG;;
2023-05-28 12:31:46 +08:00
s) frpc_server_addr=$OPTARG;;
t) frpc_token=$OPTARG;;
r) frpc_remote_port=$OPTARG;;
2023-06-04 02:28:45 +08:00
k) ssh_passward=$OPTARG;;
2023-05-28 12:31:46 +08:00
\?) echo "Invalid option -$OPTARG" >&2;;
esac
done
2023-05-29 18:00:33 +08:00
DOCKER_NAME="pikadev"
if [ -n "$frpc_remote_port" ]; then
DOCKER_NAME+="_$frpc_remote_port"
fi
# 检查是否设置了frpc_server_port参数
if [ -n "$frpc_server_port" ]; then
2023-05-28 12:31:46 +08:00
# 启动frpc
echo "Starting frpc..."
2023-05-29 18:00:33 +08:00
docker rm $DOCKER_NAME -f
2023-05-31 01:24:20 +08:00
docker run -d --name $DOCKER_NAME \
2023-05-28 12:31:46 +08:00
--restart always \
-w /root/pikascript \
-e FRPC_REMOTE_PORT=$frpc_remote_port \
-e FRPC_SERVER_ADDR=$frpc_server_addr \
-e FRPC_SERVER_PORT=$frpc_server_port \
-e FRPC_TOKEN=$frpc_token \
2023-06-04 02:28:45 +08:00
-e SSH_PASSWARD=$ssh_passward\
2023-05-29 18:00:33 +08:00
pikadev \
bash /etc/frpc.sh
2023-05-28 12:31:46 +08:00
else
# 不启动frpc
2023-05-29 18:00:33 +08:00
echo "frpc_server_port is not set. Skipping frpc startup."
docker rm $DOCKER_NAME -f
2023-05-28 12:31:46 +08:00
docker run -it --name $DOCKER_NAME \
--restart always \
-w /root/pikascript \
2023-05-29 18:00:33 +08:00
pikadev \
2023-05-28 12:31:46 +08:00
bash
fi