Skip to content

Commit c1c2ad5

Browse files
committed
each start recreate FRP config if needed
Signed-off-by: Oleksander Piskun <[email protected]>
1 parent d541a39 commit c1c2ad5

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

start.sh

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/bin/bash
22
set -e
33

4-
# Check if the configuration file already exists
5-
if [ -f /frpc.toml ]; then
6-
echo "/frpc.toml already exists, skipping creation."
7-
else
8-
# Only create a config file if HP_SHARED_KEY is set.
9-
if [ -n "$HP_SHARED_KEY" ]; then
10-
echo "HP_SHARED_KEY is set, creating /frpc.toml configuration file..."
11-
if [ -d "/certs/frp" ]; then
12-
echo "Found /certs/frp directory. Creating configuration with TLS certificates."
13-
cat <<EOF > /frpc.toml
4+
# Only create a config file if HP_SHARED_KEY is set.
5+
if [ -n "$HP_SHARED_KEY" ]; then
6+
echo "HP_SHARED_KEY is set, creating /frpc.toml configuration file..."
7+
if [ -d "/certs/frp" ]; then
8+
echo "Found /certs/frp directory. Creating configuration with TLS certificates."
9+
cat <<EOF > /frpc.toml
1410
serverAddr = "$HP_FRP_ADDRESS"
1511
serverPort = $HP_FRP_PORT
16-
metadatas.token = "$HP_SHARED_KEY"
12+
13+
transport.tls.enable = true
1714
transport.tls.certFile = "/certs/frp/client.crt"
1815
transport.tls.keyFile = "/certs/frp/client.key"
1916
transport.tls.trustedCaFile = "/certs/frp/ca.crt"
17+
transport.tls.serverName = "harp.nc"
18+
19+
metadatas.token = "$HP_SHARED_KEY"
2020
2121
[[proxies]]
2222
name = "$APP_ID"
@@ -25,11 +25,14 @@ localIP = "127.0.0.1"
2525
localPort = $APP_PORT
2626
remotePort = $APP_PORT
2727
EOF
28-
else
29-
echo "Directory /certs/frp not found. Creating configuration without TLS certificates."
30-
cat <<EOF > /frpc.toml
28+
else
29+
echo "Directory /certs/frp not found. Creating configuration without TLS certificates."
30+
cat <<EOF > /frpc.toml
3131
serverAddr = "$HP_FRP_ADDRESS"
3232
serverPort = $HP_FRP_PORT
33+
34+
transport.tls.enable = false
35+
3336
metadatas.token = "$HP_SHARED_KEY"
3437
3538
[[proxies]]
@@ -39,10 +42,9 @@ localIP = "127.0.0.1"
3942
localPort = $APP_PORT
4043
remotePort = $APP_PORT
4144
EOF
42-
fi
43-
else
44-
echo "HP_SHARED_KEY is not set. Skipping FRP configuration."
4545
fi
46+
else
47+
echo "HP_SHARED_KEY is not set. Skipping FRP configuration."
4648
fi
4749

4850
# If we have a configuration file and the shared key is present, start the FRP client

0 commit comments

Comments
 (0)