-
Notifications
You must be signed in to change notification settings - Fork 4
/
entrypoint.sh
27 lines (26 loc) · 1 KB
/
entrypoint.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
#!/bin/bash
set -e
ifaddress=$(ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:")
ifgateway=$(ip route | grep 'default' | awk '{print $3}')
if [ ! -d "/var/etc" ]; then
mkdir /var/etc
fi
if [ ! -d "/var/etc/wireguard" ]; then
mkdir /var/etc/wireguard
fi
if [ `grep -c "162.159.192.1 engage.cloudflareclient.com" /etc/hosts` == '0' ]; then
echo "162.159.192.1 engage.cloudflareclient.com" >> /etc/hosts
fi
ip route add 162.159.192.1 via $ifgateway dev eth0
cp /etc/wireguard/wgcf.conf /var/etc/wireguard/wgcf.conf
sed -i '/MTU = 1280/a\Table = off' /var/etc/wireguard/wgcf.conf
wg-quick up /var/etc/wireguard/wgcf.conf
if [ `grep -c "252 eth0" /etc/iproute2/rt_tables` == '0' ]; then
echo "252 eth0" >> /etc/iproute2/rt_tables
fi
ip rule add from $ifaddress lookup eth0
ip route del default
ip route add default dev wgcf
ip route add table eth0 default via $ifgateway dev eth0
ip -6 route add default dev wgcf
ss-server -s $ifaddress -p 8388 -k $key -m $method -u -d $dns