File size: 1,479 Bytes
9b205e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

set -e

# Function for logging
log() {
    echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}

# Function for cleanup
cleanup() {
    log "Performing frpc installation cleanup..."
    rm -rf /tmp/frp*
}

# Trap to ensure cleanup on exit
trap cleanup EXIT

log "Starting frpc installation..."

log "Getting latest frpc version..."
FRPC_VERSION=$(curl -s https://api.github.com/repos/fatedier/frp/releases/latest | \
    grep -Po '"tag_name": "\K.*?(?=")')

if [ -z "${FRPC_VERSION}" ]; then
    log "ERROR: Failed to get frpc version"
    exit 1
fi

log "Latest frpc version: ${FRPC_VERSION}"

log "Downloading frpc ${FRPC_VERSION}..."
DOWNLOAD_URL="https://github.com/fatedier/frp/releases/download/${FRPC_VERSION}/frp_${FRPC_VERSION#v}_linux_amd64.tar.gz"
curl -fsSL "${DOWNLOAD_URL}" -o /tmp/frp.tar.gz

log "Extracting frpc..."
tar -xzf /tmp/frp.tar.gz -C /tmp

log "Installing frpc binary..."
EXTRACT_DIR="/tmp/frp_${FRPC_VERSION#v}_linux_amd64"
if [ ! -f "${EXTRACT_DIR}/frpc" ]; then
    log "ERROR: frpc binary not found in extracted archive"
    exit 1
fi

mv "${EXTRACT_DIR}/frpc" /usr/local/bin/frpc
chmod +x /usr/local/bin/frpc

log "Verifying frpc installation..."
if command -v frpc >/dev/null 2>&1; then
    INSTALLED_VERSION=$(frpc --version 2>&1 | head -n1 || echo "Version check failed")
    log "frpc installed successfully: ${INSTALLED_VERSION}"
else
    log "ERROR: frpc installation failed"
    exit 1
fi

log "frpc installation completed successfully"