-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
65 lines (55 loc) · 1.72 KB
/
start.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
set -e
# Only create a config file if HP_SHARED_KEY is set.
if [ -n "$HP_SHARED_KEY" ]; then
echo "HP_SHARED_KEY is set, creating /frpc.toml configuration file..."
if [ -d "/certs/frp" ]; then
echo "Found /certs/frp directory. Creating configuration with TLS certificates."
cat <<EOF > /frpc.toml
serverAddr = "$HP_FRP_ADDRESS"
serverPort = $HP_FRP_PORT
loginFailExit = false
transport.tls.enable = true
transport.tls.certFile = "/certs/frp/client.crt"
transport.tls.keyFile = "/certs/frp/client.key"
transport.tls.trustedCaFile = "/certs/frp/ca.crt"
transport.tls.serverName = "harp.nc"
metadatas.token = "$HP_SHARED_KEY"
[[proxies]]
remotePort = $APP_PORT
type = "tcp"
name = "$APP_ID"
[proxies.plugin]
type = "unix_domain_socket"
unixPath = "/tmp/exapp.sock"
EOF
else
echo "Directory /certs/frp not found. Creating configuration without TLS certificates."
cat <<EOF > /frpc.toml
serverAddr = "$HP_FRP_ADDRESS"
serverPort = $HP_FRP_PORT
loginFailExit = false
transport.tls.enable = false
metadatas.token = "$HP_SHARED_KEY"
[[proxies]]
remotePort = $APP_PORT
type = "tcp"
name = "$APP_ID"
[proxies.plugin]
type = "unix_domain_socket"
unixPath = "/tmp/exapp.sock"
EOF
fi
else
echo "HP_SHARED_KEY is not set. Skipping FRP configuration."
fi
# If we have a configuration file and the shared key is present, start the FRP client
if [ -f /frpc.toml ] && [ -n "$HP_SHARED_KEY" ]; then
echo "Starting frpc in the background..."
frpc -c /frpc.toml &
fi
# Start the main application (adjust it for your ExApp)
echo "Starting main application..."
exec python3 main.py