forked from 1xtAsh/MyScripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wireguard.sh
47 lines (40 loc) · 1.14 KB
/
wireguard.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
#!/usr/bin/env bash
#
# Kanged by ImSpiDy
# Import or update wireguard
#
kt_dir="$(pwd)"
wg_dir_1="${kt_dir}/net/wireguard"
wg_dir_2="${kt_dir}/drivers/net/wireguard"
user_agent="WireGuard-AndroidROMBuild/0.3 ($(uname -a))"
wireguard_url="https://git.zx2c4.com/wireguard-linux-compat/snapshot/wireguard-linux-compat"
if [ -d "${wg_dir_1}" ]; then
wg_dir="${wg_dir_1}"
fi
if [ -d "${wg_dir_2}" ]; then
wg_dir="${wg_dir_2}"
else
wg_dir="${wg_dir_1}"
fi
if [ -d "${wg_dir}" ]; then
rm -rf "${wg_dir}"
wg_type="Merge"
else
wg_type="Add"
fi
while read -r distro package version _; do
if [[ $distro == upstream && $package == linuxcompat ]]; then
ver="$version"
break
fi
done < <(curl -A "${user_agent}" -LSs --connect-timeout 30 https://build.wireguard.com/distros.txt)
if [ ! -f "wireguard-linux-compat-${ver}.zip" ]; then
wget "${wireguard_url}"-"${ver}".zip
unzip wireguard-linux-compat-"${ver}".zip -d "${kt_dir}"/wireguard
fi
mkdir -p "${wg_dir}"
cp -r "${kt_dir}"/wireguard/*/src/* "${wg_dir}"
rm -rf "${kt_dir}"/wireguard*
git add "${wg_dir}"
git commit -sm "${wg_type} 'net/wireguard/' from wireguard-linux-compat ${ver}"
echo "done"