1
1
#! /bin/bash
2
2
set -e
3
3
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
14
10
serverAddr = "$HP_FRP_ADDRESS "
15
11
serverPort = $HP_FRP_PORT
16
- metadatas.token = "$HP_SHARED_KEY "
12
+
13
+ transport.tls.enable = true
17
14
transport.tls.certFile = "/certs/frp/client.crt"
18
15
transport.tls.keyFile = "/certs/frp/client.key"
19
16
transport.tls.trustedCaFile = "/certs/frp/ca.crt"
17
+ transport.tls.serverName = "harp.nc"
18
+
19
+ metadatas.token = "$HP_SHARED_KEY "
20
20
21
21
[[proxies]]
22
22
name = "$APP_ID "
@@ -25,11 +25,14 @@ localIP = "127.0.0.1"
25
25
localPort = $APP_PORT
26
26
remotePort = $APP_PORT
27
27
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
31
31
serverAddr = "$HP_FRP_ADDRESS "
32
32
serverPort = $HP_FRP_PORT
33
+
34
+ transport.tls.enable = false
35
+
33
36
metadatas.token = "$HP_SHARED_KEY "
34
37
35
38
[[proxies]]
@@ -39,10 +42,9 @@ localIP = "127.0.0.1"
39
42
localPort = $APP_PORT
40
43
remotePort = $APP_PORT
41
44
EOF
42
- fi
43
- else
44
- echo " HP_SHARED_KEY is not set. Skipping FRP configuration."
45
45
fi
46
+ else
47
+ echo " HP_SHARED_KEY is not set. Skipping FRP configuration."
46
48
fi
47
49
48
50
# If we have a configuration file and the shared key is present, start the FRP client
0 commit comments