From 49d23f11f49daccf49e9c6cc9e7eabd6f4b4bfe4 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Sun, 3 May 2020 23:54:41 +0300 Subject: goodbye openvpn, hello wireguard --- dotfiles/.config/waybar/config | 2 -- dotfiles/.local/bin/addwgprofile | 3 +++ dotfiles/.local/bin/barvpnstatus | 16 +++++++++++----- dotfiles/.local/bin/togglevpn | 24 ++++++------------------ install.sh | 7 ++++--- system/NetworkManager/NetworkManager.conf | 2 +- system/resolv.conf | 2 -- system/resolvconf.conf | 7 +++++++ 8 files changed, 32 insertions(+), 31 deletions(-) create mode 100755 dotfiles/.local/bin/addwgprofile delete mode 100644 system/resolv.conf create mode 100644 system/resolvconf.conf diff --git a/dotfiles/.config/waybar/config b/dotfiles/.config/waybar/config index bf558dd..95d1f84 100644 --- a/dotfiles/.config/waybar/config +++ b/dotfiles/.config/waybar/config @@ -174,8 +174,6 @@ }, "custom/vpn-status": { "format": "{}", - "signal": 6, - "interval": "once", "exec": "barvpnstatus" }, "custom/mail-status": { diff --git a/dotfiles/.local/bin/addwgprofile b/dotfiles/.local/bin/addwgprofile new file mode 100755 index 0000000..7d0874c --- /dev/null +++ b/dotfiles/.local/bin/addwgprofile @@ -0,0 +1,3 @@ +#!/bin/sh + +nmcli connection import type wireguard file ~/.config/wg0.conf diff --git a/dotfiles/.local/bin/barvpnstatus b/dotfiles/.local/bin/barvpnstatus index 7850d94..cca0201 100755 --- a/dotfiles/.local/bin/barvpnstatus +++ b/dotfiles/.local/bin/barvpnstatus @@ -1,9 +1,15 @@ #!/bin/sh -if [ -f "$HOME/.cache/openvpnpid" ]; then - printf " vpn" - exit -fi +isup=$(ip a | grep wg0:) -printf "" +if [ -n "$isup" ]; then + printf " vpn\n" +else + printf "" +fi +# For some goddamned weird reason sed crashes with a +# "couldn't flush stdout: broken pipe" error when running from waybar itself +# if I don't call sed from its hard location, so I had to call it using +# /usr/bin/sed +nmcli monitor | grep -E --line-buffered 'wg0: connected|wg0: disconnected' | /usr/bin/sed --unbuffered 's/wg0: connected/ vpn/g;s/wg0: disconnected//g' diff --git a/dotfiles/.local/bin/togglevpn b/dotfiles/.local/bin/togglevpn index f4dc1f1..0bdeacb 100755 --- a/dotfiles/.local/bin/togglevpn +++ b/dotfiles/.local/bin/togglevpn @@ -1,22 +1,10 @@ #!/bin/sh -if [ -f "$HOME/.cache/openvpnpid" ]; then - rm ~/.cache/openvpnpid - sudo killall -SIGINT openvpn - exit -fi +isup=$(ip a | grep wg0:) -if [ ! -f "$HOME/.config/ovpn/conf.ovpn" ]; then - notify-send " OpenVPN" "Can't start VPN. Configuration file is missing" - exit +if [ -z "$isup" ]; then + nmcli connection up wg0 && notify-send " VPN" "Wireguard VPN tunnel established" && exit + notify-send " VPN" "Error while trying to start Wireguard tunnel" fi - -sudo openvpn "$HOME/.config/ovpn/conf.ovpn" & -PID=$! -notify-send " OpenVPN" "VPN is being initialized" -echo $PID > ~/.cache/openvpnpid -killall -40 waybar -wait $PID -notify-send " OpenVPN" "VPN service has stopped with exit code $?" -rm -f ~/.cache/openvpnpid -killall -40 waybar +nmcli connection down wg0 && notify-send " VPN" "Wireguard VPN tunnel brought down" && exit +notify-send " VPN" "Error while trying to close Wireguard tunnel" diff --git a/install.sh b/install.sh index 357e172..3f86907 100755 --- a/install.sh +++ b/install.sh @@ -5,16 +5,17 @@ if [ -z "$1" ]; then echo "Specify username for new user" + exit 1; fi CLONEDIR=$PWD # Install some basic programs -pacman -Sy --noconfirm base-devel zsh man networkmanager openvpn neovim sway swaylock swayidle waybar egl-wayland imv swaybg xorg-server-xwayland termite kitty qt5-wayland wl-clipboard dbus tmux htop bemenu mupdf mpd ncmpcpp mpc mpv mplayer libnotify mako cronie rsync grim slop ffmpeg w3m youtube-dl youtube-viewer newsboat wget curl krita inkscape darktable gcc make fontconfig pkg-config fakeroot papirus-icon-theme alsa-utils pulseaudio pulseaudio-bluetooth imagemagick ntfs-3g unzip unrar gnome-themes-standard gtk-engine-murrine telegram-desktop qt5ct r udisks2 perl-term-readline-gnu transmission-cli transmission-remote-gtk python-pynvim python-pip calcurse acpi acpid gnupg noto-fonts-cjk noto-fonts-emoji ttf-joypixels powerline-fonts python-pygit2 polkit polkit-gnome zathura zathura-pdf-mupdf zathura-djvu gst-libav vifm blueman bluez acpilight powertop accountsservice lightdm xdg-user-dirs abook ranger terminus-font qutebrowser jq stow wdiff texlive-most pandoc units +pacman -Sy --noconfirm base-devel zsh man networkmanager openresolv wireguard-tools neovim sway swaylock swayidle waybar egl-wayland imv swaybg xorg-server-xwayland termite kitty qt5-wayland wl-clipboard dbus tmux htop bemenu mupdf mpd ncmpcpp mpc mpv mplayer libnotify mako cronie rsync grim slop ffmpeg w3m youtube-dl youtube-viewer newsboat wget curl krita inkscape darktable gcc make fontconfig pkg-config fakeroot papirus-icon-theme alsa-utils pulseaudio pulseaudio-bluetooth imagemagick ntfs-3g unzip unrar gnome-themes-standard gtk-engine-murrine telegram-desktop qt5ct r bc udisks2 perl-term-readline-gnu transmission-cli transmission-remote-gtk python-pynvim python-pip python-pillow calcurse acpi acpid gnupg noto-fonts-cjk noto-fonts-emoji ttf-joypixels powerline-fonts python-pygit2 polkit polkit-gnome zathura zathura-pdf-mupdf zathura-djvu gst-libav vifm blueman bluez acpilight powertop accountsservice lightdm xdg-user-dirs abook ranger terminus-font qutebrowser jq stow wdiff texlive-most pandoc units isync notmuch # Copy system config files cp system/sudoers /etc/ -cp system/resolv.conf /etc/ +cp system/resolvconf.conf /etc/ cp system/NetworkManager/NetworkManager.conf /etc/NetworkManager/NetworkManager.conf cp system/mkinitcpio.conf /etc/ cp systemd/hotspot.service /etc/systemd/system/ @@ -37,7 +38,7 @@ chown -R "$1:$1" build cd build sudo -u "$1" "git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si" -yay -S --noconfirm aerc ttf-symbola stig pam-gnupg ncpamixer lightdm-mini-greeter plymouth-git mimeo xdg-utils-mimeo cli-visualizer +yay -S --noconfirm aerc-git ttf-symbola stig pam-gnupg ncpamixer lightdm-mini-greeter plymouth-git mimeo xdg-utils-mimeo cli-visualizer cd "$CLONEDIR" diff --git a/system/NetworkManager/NetworkManager.conf b/system/NetworkManager/NetworkManager.conf index c48e647..aea80d3 100644 --- a/system/NetworkManager/NetworkManager.conf +++ b/system/NetworkManager/NetworkManager.conf @@ -1,4 +1,4 @@ # Configuration file for NetworkManager. # See "man 5 NetworkManager.conf" for details. [main] -dns=none +rc-manager=resolvconf diff --git a/system/resolv.conf b/system/resolv.conf deleted file mode 100644 index af9304d..0000000 --- a/system/resolv.conf +++ /dev/null @@ -1,2 +0,0 @@ -nameserver 208.67.222.222 -nameserver 208.67.220.220 diff --git a/system/resolvconf.conf b/system/resolvconf.conf new file mode 100644 index 0000000..881849f --- /dev/null +++ b/system/resolvconf.conf @@ -0,0 +1,7 @@ +# Configuration for resolvconf(8) +# See resolvconf.conf(5) for details + +resolv_conf=/etc/resolv.conf +# If you run a local name server, you should uncomment the below line and +# configure your subscribers configuration files below. +name_servers="1.1.1.1" -- cgit v1.2.3