rvs-prxy server user login name & service container name

This commit is contained in:
chungyan5 2025-10-28 14:30:02 +00:00
parent 0660adfd04
commit 72c05996ca
4 changed files with 33 additions and 438 deletions

View File

@ -12,14 +12,18 @@ DOCKER_NETWORK=app-network # Docker network for connecting to i
# FRP Server Configuration # FRP Server Configuration
# Public IP address of the FRP server # Public IP address of the FRP server
FRP_SERVER_ADDR=192.168.1.100 FRP_SERVER_ADDR=192.168.1.100
FRP_SERVER_USER=myuser
FRP_SERVER_PORT=16999 # Port for FRP communication (default 16999) FRP_SERVER_PORT=16999 # Port for FRP communication (default 16999)
# Domain Configuration # Domain Configuration
# Public domain for Traefik routing # Public domain for Traefik routing
DOMAIN_NAME=myapp.example.com DOMAIN_NAME=myapp.example.com
# Common Proxy Configuration - Remote ports for external access # Service -- docker container name
PROXY_WEB_PORT=11077 # Remote port for web proxy - accessible via domain (default 13077) SERVICE_DOCKER_CONTAINER_NAME=your-app-docker-container
# Remote ports Configuration for 1) external access, or 2) traefik connecting (convert to publish at port 80/443 usually)
PROXY_WEB_PORT=11077 # Remote port for web proxy
# Dynamic Proxy Configuration - Use PROXY_*_PORT format for additional proxies # Dynamic Proxy Configuration - Use PROXY_*_PORT format for additional proxies
# Examples: # Examples:

View File

@ -87,7 +87,11 @@
- for localIP, it should not use IP, it should use docker container name, since we are use docker network. So the container should follow this rule as `${INSTANCE_NAME}-app` where `${INSTANCE_NAME}` from `.env*`. Modify the code to prepare a right `frpc.toml`. - for localIP, it should not use IP, it should use docker container name, since we are use docker network. So the container should follow this rule as `${INSTANCE_NAME}-app` where `${INSTANCE_NAME}` from `.env*`. Modify the code to prepare a right `frpc.toml`.
- From `.env*`, it has `${DOCKER_NETWORK}` variable, however, i do not fin it to apply into `docker run ...` cmd applying into the frpc container. Add it back. - From `.env*`, it has `${DOCKER_NETWORK}` variable, however, i do not fin it to apply into `docker run ...` cmd applying into the frpc container. Add it back.
- From `auto-sys-deploy.sh`, it has "Proceed with deployment? (OK/Cancel) [Cancel]: OK", disable the part of code, do not remove it, only disable it, do not need to ask any more for operation smoothly; - From `auto-sys-deploy.sh`, it has "Proceed with deployment? (OK/Cancel) [Cancel]: OK", disable the part of code, do not remove it, only disable it, do not need to ask any more for operation smoothly;
- i find the content of "$temp_script" is duplicated, 1st item as "746 to 1126" and 2nd item as "1127 to 1507". Verify these two items, then merge the content, finally remove the last one.
- i find seems duplicated function `restart_docker_compose()` exists twice, verify do we need to duplicate it?
- ~~`update_ports_config()` function seems exist twice times inside the "$temp_script", verify it which one should be right, then remove the duplicated one.~~
- From `.env*`, we have `FRP_SERVER_ADDR` variable, i aim to add a `FRP_SERVER_USER` to instead the currently hardcode of `teenfuture` user.
- For `generate_frpc_config()` -> handle `frpc.toml` content -> `config_content+="localIP = \"${THIS_INSTANCE}-app\"\n"`, i aim to change from `${THIS_INSTANCE}-app` to ${SERVICE_DOCKER_CONTAINER_NAME} from `.env*`. I have already updated the `.env.development` and `.env.example`. You update the `auto-sys-deploy.sh` code.
- From `.env*` -> `PROXY_*_PORT`, it creates this currently: - From `.env*` -> `PROXY_*_PORT`, it creates this currently:
``` ```
# XXXXX Self-hosting ports ==== # XXXXX Self-hosting ports ====
@ -96,6 +100,7 @@
``` ```
- if it is `PROXY_WEB_PORT`, it mentions as `WEB`, we do not care the port number even other than 80 and 443, we still skip the section "# XXXXX Self-hosting ports ====", that means no this section present at `apps/zzthis/docker-compose.app.yml`, otherwise other `PROXY_XXXX_PORT` which is `XXXX` is not `WEB`, then keep this section. - if it is `PROXY_WEB_PORT`, it mentions as `WEB`, we do not care the port number even other than 80 and 443, we still skip the section "# XXXXX Self-hosting ports ====", that means no this section present at `apps/zzthis/docker-compose.app.yml`, otherwise other `PROXY_XXXX_PORT` which is `XXXX` is not `WEB`, then keep this section.
- I am in the case of `PROXY_WEB_PORT=12077` from `.env.development` now, but this section "# XXXXX Self-hosting ports ====" is still exist. - I am in the case of `PROXY_WEB_PORT=12077` from `.env.development` now, but this section "# XXXXX Self-hosting ports ====" is still exist.
- i review the `auto-sys-deploy.sh` code -> `update_ports_config()` -> handle `local INSTANCE_MARKER ...`, it does not add any logic matching the above i just mentioned. Modify the code.
- ~~if it is `PROXY_WEB_PORT`, since it is web, so should be shared common pport 443 and 80, so, the above section "# XXXXX Self-hosting ports ====" can skip it. or other `PROXY_*_PORT` except `PROXY_WEB_PORT`, should still keep this section.~~ - ~~if it is `PROXY_WEB_PORT`, since it is web, so should be shared common pport 443 and 80, so, the above section "# XXXXX Self-hosting ports ====" can skip it. or other `PROXY_*_PORT` except `PROXY_WEB_PORT`, should still keep this section.~~
- ~~Currently it shows this command `cd /data/ssd/rvs-prxy/frps/ && ./stop.sh && ./start.sh` for manually to execute.~~ For manually testing as better, since this is production proxy, cannot always restart. - ~~Currently it shows this command `cd /data/ssd/rvs-prxy/frps/ && ./stop.sh && ./start.sh` for manually to execute.~~ For manually testing as better, since this is production proxy, cannot always restart.

View File

@ -1,8 +0,0 @@
- From `.env*` -> `PROXY_*_PORT`, it creates this currently:
```
# XXXXX Self-hosting ports ====
- "12077:12077/tcp"
# =========================
```
- if it is `PROXY_WEB_PORT`, it mentions as `WEB`, we do not care the port number even other than 80 and 443, we still skip the section "# XXXXX Self-hosting ports ====", that means no this section present at `apps/zzthis/docker-compose.app.yml`, otherwise other `PROXY_XXXX_PORT` which is `XXXX` is not `WEB`, then keep this section.
- I am in the case of `PROXY_WEB_PORT=12077` from `.env.development` now, but this section "# XXXXX Self-hosting ports ====" is still exist.

View File

@ -423,6 +423,16 @@ generate_frpc_config() {
save_to_env "FRP_SERVER_ADDR" "$SERVER_ADDR" save_to_env "FRP_SERVER_ADDR" "$SERVER_ADDR"
fi fi
# Use FRP server user from environment or default to 'teenfuture'
if [ -n "$FRP_SERVER_USER" ]; then
SERVER_USER="$FRP_SERVER_USER"
log_info "Using environment variable for FRP server user: $SERVER_USER"
else
# Use default 'teenfuture' user if not specified
SERVER_USER="teenfuture"
log_info "Using default FRP server user: $SERVER_USER"
fi
# Use default server port (16999) without prompting, but use existing if available # Use default server port (16999) without prompting, but use existing if available
if [ -n "$FRP_SERVER_PORT" ]; then if [ -n "$FRP_SERVER_PORT" ]; then
SERVER_PORT="$FRP_SERVER_PORT" SERVER_PORT="$FRP_SERVER_PORT"
@ -520,7 +530,12 @@ generate_frpc_config() {
config_content+="name = \"${proxy_name}-${THIS_INSTANCE}\"\n" config_content+="name = \"${proxy_name}-${THIS_INSTANCE}\"\n"
config_content+="type = \"tcp\"\n" config_content+="type = \"tcp\"\n"
config_content+="localPort = ${local_port}\n" config_content+="localPort = ${local_port}\n"
config_content+="localIP = \"${THIS_INSTANCE}-app\"\n" # Use SERVICE_DOCKER_CONTAINER_NAME from .env* files if available, otherwise fall back to ${THIS_INSTANCE}-app
if [ -n "$SERVICE_DOCKER_CONTAINER_NAME" ]; then
config_content+="localIP = \"${SERVICE_DOCKER_CONTAINER_NAME}\"\n"
else
config_content+="localIP = \"${THIS_INSTANCE}-app\"\n"
fi
config_content+="remotePort = ${remote_port}\n\n" config_content+="remotePort = ${remote_port}\n\n"
done done
@ -1071,386 +1086,6 @@ restart_docker_compose() {
echo "You can view the logs with: docker logs --tail 50 frps_frps_1" echo "You can view the logs with: docker logs --tail 50 frps_frps_1"
} }
# Function to update the docker-compose configuration
update_compose_config() {
local INSTANCE_NAME="$1"
local HAS_WEB_PROXY="$2"
shift 2 # Remove first two arguments, remaining are ports
local PORTS=("$@") # Get all port arguments
local LAST_ARG="${PORTS[-1]}" # Last argument should be domain name
unset 'PORTS[-1]' # Remove domain from ports array
local DOMAIN_NAME="$LAST_ARG"
local COMPOSE_FILE="/data/ssd/rvs-prxy/frps/apps/zzthis/docker-compose.app.yml"
# Use the first port as the web port for domain routing
local WEB_PORT="${PORTS[0]}"
# Create a backup of the original file with timestamp
if [ -f "${COMPOSE_FILE}" ]; then
local TIMESTAMP=$(date +%Y%m%d_%H%M%S)
local BACKUP_FILE="${COMPOSE_FILE}.backup_${TIMESTAMP}"
cp "${COMPOSE_FILE}" "${BACKUP_FILE}"
echo "Created backup of docker-compose.app.yml as ${BACKUP_FILE}"
else
echo "NOTE: docker-compose.app.yml does not exist yet, will create it"
fi
# Update ports section based on whether we have a web proxy
if [ "$HAS_WEB_PROXY" = "true" ]; then
echo "Skipping port mappings for configuration with web proxy (access via domain only)"
else
# Update ports section with all ports (don't pass domain name to ports config)
update_ports_config "$INSTANCE_NAME" "${PORTS[@]}"
fi
# Update labels section - only needs the web port for routing
update_labels_config "$INSTANCE_NAME" "$WEB_PORT" "$DOMAIN_NAME"
# Ask user if they want to restart the service
echo ""
read -p "Do you want to restart the Docker Compose service now? (y/N): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
restart_docker_compose
else
echo "You can restart the service later with:"
echo " cd /data/ssd/rvs-prxy/frps/ && ./stop.sh && ./start.sh"
echo "And view logs with:"
echo " docker logs --tail 50 frps_frps_1"
fi
}
# Execute the configuration update with passed parameters
# Pass all ports and domain name as arguments to update_compose_config
update_compose_config "$@"
#!/bin/bash
# Function to check if the instance configuration is complete and up-to-date in ports section
# This function is a simplified version - in a real implementation, this would check dynamically
check_ports_config_status() {
local INSTANCE_NAME="$1"
local PORTS_CONFIG=("${@:2}") # All remaining arguments are ports
local COMPOSE_FILE="/data/ssd/rvs-prxy/frps/apps/zzthis/docker-compose.app.yml"
# Set the instance marker for ports section
local INSTANCE_MARKER="# ${INSTANCE_NAME} Self-hosting ports ===="
# Check if the instance marker exists
if [ ! -f "${COMPOSE_FILE}" ] || ! grep -q "${INSTANCE_MARKER}" "${COMPOSE_FILE}"; then
echo "not_found"
return
fi
# Find the exact lines of the configuration block
local start_line=$(grep -n "${INSTANCE_MARKER}" "${COMPOSE_FILE}" | head -1 | cut -d: -f1)
local end_line=$(grep -n "# =========================" "${COMPOSE_FILE}" | awk -F: -v start="$start_line" '$1 > start {print $1; exit}')
# If we can't find the end marker, use a default range
if [ -z "$end_line" ]; then
end_line=$((start_line + ${#PORTS_CONFIG[@]} + 5))
fi
# Extract the configuration block
local config_block=$(sed -n "${start_line},${end_line}p" "${COMPOSE_FILE}")
# Count the port lines
local port_lines=$(echo "$config_block" | grep -c '^ - "[0-9]*:[0-9]*/tcp"')
# For simplicity in this implementation, we'll mark as 'outdated' to update
echo "outdated"
}
# Function to check if the instance configuration is complete and up-to-date in labels section
check_labels_config_status() {
local INSTANCE_NAME="$1"
local WEB_PORT="$2"
local DOMAIN_NAME="$3"
local COMPOSE_FILE="/data/ssd/rvs-prxy/frps/apps/zzthis/docker-compose.app.yml"
# Set the instance marker for labels section (different from ports)
local INSTANCE_MARKER="# ${INSTANCE_NAME} Self-hosting labels ===="
# Check if the instance marker exists in labels section
if [ ! -f "${COMPOSE_FILE}" ] || ! grep -q "${INSTANCE_MARKER}" "${COMPOSE_FILE}"; then
echo "not_found"
return
fi
# Find the exact lines of the configuration block
local start_line=$(grep -n "${INSTANCE_MARKER}" "${COMPOSE_FILE}" | head -1 | cut -d: -f1)
local end_line=$(grep -n "# =========================" "${COMPOSE_FILE}" | awk -F: -v start="$start_line" '$1 > start {print $1; exit}')
# If we can't find the end marker, use a default range
if [ -z "$end_line" ]; then
end_line=$((start_line + 15))
fi
# Extract the configuration block
local config_block=$(sed -n "${start_line},${end_line}p" "${COMPOSE_FILE}")
# Count the label lines (should be 11 lines plus markers)
local label_lines=$(echo "$config_block" | grep -c '^ - "traefik\.')
if [ "$label_lines" -ge 11 ]; then
# Check if the domain and port match our current configuration
local current_domain=$(echo "$config_block" | grep 'rule=Host(' | head -1 | sed 's/.*Host(`\([^)]*\)`).*/\1/')
local current_port=$(echo "$config_block" | grep 'loadbalancer.server.port' | sed 's/.*port=\([0-9]*\).*/\1/')
if [ -n "$current_domain" ] && [ -n "$current_port" ] && \
[ "$current_domain" = "$DOMAIN_NAME" ] && [ "$current_port" = "$WEB_PORT" ]; then
echo "up_to_date"
else
echo "outdated"
fi
else
echo "incomplete"
fi
}
# Function to find the correct insertion point in a specific section
find_section_insertion_point() {
local section_name="$1"
local COMPOSE_FILE="/data/ssd/rvs-prxy/frps/apps/zzthis/docker-compose.app.yml"
# Find the section start line
local section_start=$(grep -n "${section_name}:" "${COMPOSE_FILE}" | head -1 | cut -d: -f1)
if [ -z "$section_start" ]; then
echo "0"
return
fi
# Look for the next section after this one or end of section
local current_line=$((section_start + 1))
local total_lines=$(wc -l < "${COMPOSE_FILE}")
while [ "$current_line" -le "$total_lines" ]; do
local line_content=$(sed -n "${current_line}p" "${COMPOSE_FILE}")
# If we hit a line that starts a new section (not indented or comment)
if [[ "$line_content" =~ ^[[:space:]]*[a-zA-Z] ]] && [[ ! "$line_content" =~ ^[[:space:]]*# ]] && [[ ! "$line_content" =~ ^[[:space:]]*- ]]; then
echo "$current_line"
return
fi
current_line=$((current_line + 1))
done
# If we didn't find the end, insert at the end of the file
echo $((total_lines + 1))
}
# Function to update ports section with dynamic ports
update_ports_config() {
local INSTANCE_NAME="$1"
shift # Remove first argument, remaining are ports
local PORTS=("$@") # All remaining arguments are ports
local COMPOSE_FILE="/data/ssd/rvs-prxy/frps/apps/zzthis/docker-compose.app.yml"
local INSTANCE_MARKER="# ${INSTANCE_NAME} Self-hosting ports ===="
local INSTANCE_END_MARKER="# ========================="
local config_status=$(check_ports_config_status "$INSTANCE_NAME" "${PORTS[@]}")
echo "Ports configuration status: $config_status"
case "$config_status" in
"not_found")
echo "Adding new instance to ports section"
local insertion_line=$(find_section_insertion_point "ports")
# Build the port configuration dynamically, excluding standard web ports (80, 443)
local port_config=""
local non_standard_ports=()
for port in "${PORTS[@]}"; do
# Skip standard web ports since they may be managed by the system
if [ "$port" != "80" ] && [ "$port" != "443" ]; then
port_config+=" - \"${port}:${port}/tcp\"\\n"
non_standard_ports+=("$port")
fi
done
# Only add ports section if there are non-standard ports to map
if [ -n "$port_config" ]; then
# Insert the configuration at the correct location
sed -i "${insertion_line}i\\
\\
${INSTANCE_MARKER}\\
${port_config} ${INSTANCE_END_MARKER}\\
" "${COMPOSE_FILE}"
echo "Ports configuration added successfully for ${#non_standard_ports[@]} non-standard port(s): ${non_standard_ports[*]}"
else
echo "No non-standard ports to add to ports section (ports 80 and 443 are standard)"
fi
;;
"up_to_date")
echo "Ports configuration is already up to date"
;;
"outdated"|"incomplete")
echo "Updating existing ports configuration"
# Find the exact lines of the existing configuration
local start_line=$(grep -n "${INSTANCE_MARKER}" "${COMPOSE_FILE}" | head -1 | cut -d: -f1)
local end_line=$(grep -n "${INSTANCE_END_MARKER}" "${COMPOSE_FILE}" | awk -F: -v start="$start_line" '$1 > start {print $1; exit}')
# If we can't find the end marker, use a default range
if [ -n "$start_line" ] && [ -z "$end_line" ]; then
end_line=$((start_line + ${#PORTS[@]} + 5))
fi
# Remove only the specific configuration block (from start marker to end marker)
if [ -n "$start_line" ] && [ -n "$end_line" ] && [ "$start_line" -gt 0 ] && [ "$end_line" -gt "$start_line" ]; then
sed -i "${start_line},${end_line}d" "${COMPOSE_FILE}"
# Build the updated port configuration dynamically, excluding standard web ports (80, 443)
local port_config=""
local non_standard_ports=()
for port in "${PORTS[@]}"; do
# Skip standard web ports since they may be managed by the system
if [ "$port" != "80" ] && [ "$port" != "443" ]; then
port_config+=" - \"${port}:${port}/tcp\"\\n"
non_standard_ports+=("$port")
fi
done
# Only update ports section if there are non-standard ports to map
if [ -n "$port_config" ]; then
# Insert the updated configuration at the same location
sed -i "${start_line}i\\
${INSTANCE_MARKER}\\
${port_config} ${INSTANCE_END_MARKER}" "${COMPOSE_FILE}"
echo "Ports configuration updated successfully for ${#non_standard_ports[@]} non-standard port(s): ${non_standard_ports[*]}"
else
echo "No non-standard ports to update in ports section (ports 80 and 443 are standard)"
fi
else
echo "Warning: Could not determine valid line range for ports update"
fi
;;
esac
}
# Function to update labels section
update_labels_config() {
local INSTANCE_NAME="$1"
local WEB_PORT="$2"
local DOMAIN_NAME="$3"
local COMPOSE_FILE="/data/ssd/rvs-prxy/frps/apps/zzthis/docker-compose.app.yml"
local INSTANCE_MARKER="# ${INSTANCE_NAME} Self-hosting labels ===="
local INSTANCE_END_MARKER="# ========================="
local config_status=$(check_labels_config_status "$INSTANCE_NAME" "$WEB_PORT" "$DOMAIN_NAME")
echo "Labels configuration status: $config_status"
case "$config_status" in
"not_found")
echo "Adding new instance to labels section"
local insertion_line=$(find_section_insertion_point "labels")
# Insert the configuration at the correct location
sed -i "${insertion_line}i\\
\\
${INSTANCE_MARKER}\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.entrypoints=web\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.rule=Host(\`${DOMAIN_NAME}\`)\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.service=frps-${INSTANCE_NAME}\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.middlewares=http2https@file\"\\
\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.entrypoints=websecure\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.rule=Host(\`${DOMAIN_NAME}\`)\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.service=frps-${INSTANCE_NAME}\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.tls=true\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.tls.certresolver=letsencrypt\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.tls.domains[0].main=${DOMAIN_NAME}\"\\
\\
- \"traefik.http.services.frps-${INSTANCE_NAME}.loadbalancer.server.port=${WEB_PORT}\"\\
${INSTANCE_END_MARKER}\\
" "${COMPOSE_FILE}"
echo "Labels configuration added successfully"
;;
"up_to_date")
echo "Labels configuration is already up to date"
;;
"outdated"|"incomplete")
echo "Updating existing labels configuration"
# Find the exact lines of the existing configuration
local start_line=$(grep -n "${INSTANCE_MARKER}" "${COMPOSE_FILE}" | head -1 | cut -d: -f1)
local end_line=$(grep -n "${INSTANCE_END_MARKER}" "${COMPOSE_FILE}" | awk -F: -v start="$start_line" '$1 > start {print $1; exit}')
# If we can't find the end marker, use a default range
if [ -z "$end_line" ]; then
end_line=$((start_line + 15))
fi
# Remove only the specific configuration block (from start marker to end marker)
if [ -n "$start_line" ] && [ -n "$end_line" ] && [ "$start_line" -gt 0 ] && [ "$end_line" -gt "$start_line" ]; then
sed -i "${start_line},${end_line}d" "${COMPOSE_FILE}"
# Insert the updated configuration at the same location
sed -i "${start_line}i\\
${INSTANCE_MARKER}\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.entrypoints=web\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.rule=Host(\`${DOMAIN_NAME}\`)\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.service=frps-${INSTANCE_NAME}\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-http.middlewares=http2https@file\"\\
\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.entrypoints=websecure\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.rule=Host(\`${DOMAIN_NAME}\`)\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.service=frps-${INSTANCE_NAME}\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.tls=true\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.tls.certresolver=letsencrypt\"\\
- \"traefik.http.routers.frps-${INSTANCE_NAME}-https.tls.domains[0].main=${DOMAIN_NAME}\"\\
\\
- \"traefik.http.services.frps-${INSTANCE_NAME}.loadbalancer.server.port=${WEB_PORT}\"\\
${INSTANCE_END_MARKER}" "${COMPOSE_FILE}"
echo "Labels configuration updated successfully"
else
echo "Warning: Could not determine valid line range for labels update"
fi
;;
esac
}
# Function to restart Docker Compose service
restart_docker_compose() {
local COMPOSE_DIR="/data/ssd/rvs-prxy/frps/"
echo "Restarting Docker Compose service..."
# Change to the compose directory
cd "${COMPOSE_DIR}" || {
echo "Error: Could not change to directory ${COMPOSE_DIR}"
return 1
}
# Stop the service
echo "Stopping the service..."
if [ -f "./stop.sh" ]; then
./stop.sh
else
docker-compose -f docker-compose.app.yml down
fi
# Start the service
echo "Starting the service..."
if [ -f "./start.sh" ]; then
./start.sh
else
docker-compose -f docker-compose.app.yml up -d
fi
# Wait a moment for the service to start
sleep 3
# Show the logs
echo "Showing the last 50 lines of logs:"
docker logs --tail 50 frps_frps_1 2>/dev/null || docker logs --tail 50 "${COMPOSE_DIR##*/}_frps_1" 2>/dev/null || {
echo "Warning: Could not retrieve logs for frps_frps_1. Trying alternative container names..."
docker ps -a | grep frps
}
echo ""
echo "Docker Compose service has been restarted."
echo "You can view the logs with: docker logs --tail 50 frps_frps_1"
}
# Function to update the docker-compose configuration # Function to update the docker-compose configuration
update_compose_config() { update_compose_config() {
@ -1513,22 +1148,22 @@ EOF
# Copy script to proxy server and execute it with all ports and domain # Copy script to proxy server and execute it with all ports and domain
log_info "Connecting to proxy server at $proxy_server_addr" log_info "Connecting to proxy server at $proxy_server_addr"
if scp -i ~/.ssh/itl-devs1 "$temp_script" teenfuture@$proxy_server_addr:/tmp/; then if scp -i ~/.ssh/itl-devs1 "$temp_script" ${SERVER_USER}@$proxy_server_addr:/tmp/; then
# Construct command with instance name, web proxy flag, all ports and domain name # Construct command with instance name, web proxy flag, all ports and domain name
local cmd_args=("$THIS_INSTANCE" "$has_web_proxy") local cmd_args=("$THIS_INSTANCE" "$has_web")
for port in "${all_ports[@]}"; do for port in "${all_ports[@]}"; do
cmd_args+=("$port") cmd_args+=("$port")
done done
cmd_args+=("$DOMAIN_NAME") # Add domain name as last argument cmd_args+=("$DOMAIN_NAME") # Add domain name as last argument
if ssh -i ~/.ssh/itl-devs1 teenfuture@$proxy_server_addr "bash /tmp/$(basename $temp_script) ${cmd_args[*]}"; then if ssh -i ~/.ssh/itl-devs1 ${SERVER_USER}@$proxy_server_addr "bash /tmp/$(basename $temp_script) ${cmd_args[*]}"; then
log_info "Proxy server configuration updated successfully" log_info "Proxy server configuration updated successfully"
# Clean up remote script # Clean up remote script
ssh -i ~/.ssh/itl-devs1 teenfuture@$proxy_server_addr "rm /tmp/$(basename $temp_script)" >/dev/null 2>&1 || true ssh -i ~/.ssh/itl-devs1 ${SERVER_USER}@$proxy_server_addr "rm /tmp/$(basename $temp_script)" >/dev/null 2>&1 || true
else else
log_error "Failed to execute script on proxy server" log_error "Failed to execute script on proxy server"
# Clean up remote script # Clean up remote script
ssh -i ~/.ssh/itl-devs1 teenfuture@$proxy_server_addr "rm /tmp/$(basename $temp_script)" >/dev/null 2>&1 || true ssh -i ~/.ssh/itl-devs1 ${SERVER_USER}@$proxy_server_addr "rm /tmp/$(basename $temp_script)" >/dev/null 2>&1 || true
rm -f "$temp_script" rm -f "$temp_script"
return 1 return 1
fi fi
@ -1548,47 +1183,6 @@ EOF
# Function to restart Docker Compose service
restart_docker_compose() {
local COMPOSE_DIR="/data/ssd/rvs-prxy/frps/"
echo "Restarting Docker Compose service..."
# Change to the compose directory
cd "${COMPOSE_DIR}" || {
echo "Error: Could not change to directory ${COMPOSE_DIR}"
return 1
}
# Stop the service
echo "Stopping the service..."
if [ -f "./stop.sh" ]; then
./stop.sh
else
docker-compose -f docker-compose.app.yml down
fi
# Start the service
echo "Starting the service..."
if [ -f "./start.sh" ]; then
./start.sh
else
docker-compose -f docker-compose.app.yml up -d
fi
# Wait a moment for the service to start
sleep 3
# Show the logs
echo "Showing the last 50 lines of logs:"
docker logs --tail 50 frps_frps_1 2>/dev/null || docker logs --tail 50 "${COMPOSE_DIR##*/}_frps_1" 2>/dev/null || {
echo "Warning: Could not retrieve logs for frps_frps_1. Trying alternative container names..."
docker ps -a | grep frps
}
echo ""
echo "Docker Compose service has been restarted."
echo "You can view the logs with: docker logs --tail 50 frps_frps_1"
}