Skip to content

Commit

Permalink
Merge pull request #203 from wumekk/patch-1
Browse files Browse the repository at this point in the history
Poprawki chce_wireguard.sh
  • Loading branch information
loper authored Jun 23, 2024
2 parents 237b39d + 2f828a7 commit cca915d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions scripts/chce_wireguard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit cca915d

Please sign in to comment.