-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from wumekk/patch-1
Poprawki chce_wireguard.sh
- Loading branch information
Showing
1 changed file
with
16 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,15 @@ | |
# Autor skryptu: Andrzej Szczepaniak | ||
# Współautor: Jakub 'unknow' Mrugalski | ||
# Aktualizacja: Dawid Kasza | ||
# Aktualizacja2: Michał Skórcz | ||
set -e | ||
|
||
# Sprawdz uprawnienia przed wykonaniem skryptu instalacyjnego | ||
if [[ $EUID -ne 0 ]]; then | ||
echo -e "W celu instalacji tego pakietu potrzebujesz wyzszych uprawnien! Uzyj polecenia \033[1;31msudo ./chce_wireguard.sh\033[0m lub zaloguj sie na konto roota i wywolaj skrypt ponownie." | ||
exit 1 | ||
fi | ||
|
||
# Backup the current resolv.conf file | ||
cp /etc/resolv.conf /etc/resolv.back | ||
|
||
|
@@ -30,6 +37,9 @@ wget https://github.com/WireGuard/wireguard-go/archive/refs/heads/master.zip | |
unzip -qq master.zip -d wireguard-go | ||
rm master.zip | ||
|
||
# Ensure directory does not exists | ||
rm -rf "/tmp/wireguard-tools" | ||
|
||
# Clone the Wireguard tools repository | ||
git -c http.sslVerify=false clone https://git.zx2c4.com/wireguard-tools /tmp/wireguard-tools | ||
|
||
|
@@ -58,8 +68,10 @@ tar -xf $GO_ARCHIVE_OUTPUT -C $GO_INSTALL_PATH | |
# Add PATH env | ||
if [ $SUDO_USER ] && [ $SUDO_USER != "root" ] ; then | ||
export PROFILE_PATH="/home/$SUDO_USER/.profile" | ||
export HOME_PATH="/home/$SUDO_USER" | ||
else | ||
export PROFILE_PATH="$HOME/.profile" | ||
export HOME_PATH="$HOME" | ||
fi | ||
|
||
# If Go PATH export doesn't exist, add it | ||
|
@@ -68,7 +80,7 @@ if ! grep 'export PATH=$PATH:/usr/local/go/bin' $PROFILE_PATH > /dev/null ; then | |
echo 'export PATH=$PATH:/usr/local/go/bin' >> $(ls $PROFILE_PATH) | ||
fi | ||
|
||
source ~/.profile | ||
source $PROFILE_PATH | ||
|
||
# Build and install Wireguard tools | ||
cd /tmp/wireguard-go/wireguard-go-master | ||
|
@@ -103,13 +115,13 @@ curl -s -d "mode=wireguard-client&srv=$srv&privkey=$cliprivkey&pubkey=$pubkey" h | |
systemctl stop "wg-quick@wg0" | ||
sed -i '/RETRIES=infinity/{n;s/.*/Environment=WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1/}' /lib/systemd/system/[email protected] | ||
systemctl daemon-reload | ||
echo "export WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1" >> ~/.profile | ||
echo "export WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1" >> ~/.bashrc | ||
echo "export WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1" >> $PROFILE_PATH | ||
echo "export WG_I_PREFER_BUGGY_USERSPACE_TO_POLISHED_KMOD=1" >> $HOME_PATH/.bashrc | ||
systemctl start "wg-quick@wg0" | ||
|
||
# Generate a QR code for the client configuration | ||
qrencode -t ansiutf8 </etc/wireguard/wg-client1.conf | ||
|
||
# Clean up temporary files | ||
rm -rf /tmp/wireguard-tools | ||
rm -rf /tmp/wireguard-go | ||
rm -rf /tmp/wireguard-go |