Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poprawki chce_wireguard.sh #203

Merged
merged 3 commits into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading