Newer
Older
skynet-server-cloud / infra / root / start_outbound.sh
@One One on 11 May 2022 891 bytes use wgcf as outbound
#!/usr/bin/env bash


echo_info() {
    GREEN='\033[0;32m'
    NC='\033[0m'
    printf "${GREEN}$1${NC}\n"
}


# generate profile
cd /data

if [ ! -e "wgcf-account.toml" ]; then
    echo_info "Registering wgcf..."

    wgcf register --accept-tos
fi
if [ ! -e "wgcf-profile.conf" ]; then
    echo_info "Generating config file..."

    wgcf generate
fi

cp wgcf-profile.conf /etc/wireguard/wgcf.conf

# table off
sed -i "/\[Interface\]/a Table = off" /etc/wireguard/wgcf.conf
# remove mtu
sed -i "/^MTU/c\\" /etc/wireguard/wgcf.conf
# remove dns
sed -i "/^DNS/c\\" /etc/wireguard/wgcf.conf

# up
echo_info "Setting up wgcf..."
wg-quick down wgcf
wg-quick up wgcf

# check status
echo_info "Checking wgcf network status..."
while ! curl --max-time 2 google.com; do
    wg-quick down wgcf
    echo_info "Sleep and retry again..."
    sleep 2
    wg-quick up wgcf
done
echo_info "OK, wgcf is up"