diff --git a/Makefile b/Makefile index 1a12481..f118069 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,8 @@ install_basic: systemd scripts bin cp systemd/vpnclient-wg-basic.service /etc/systemd/system/vpnclient-wg-basic.service cp scripts/connect_basic.py /snacks/wireguard/scripts/connect_basic.py cp scripts/inner_basic.sh /snacks/wireguard/scripts/inner_basic.sh + cp scripts/is_root_namespace.py /snacks/wireguard/scripts/is_root_namespace.py + cp scripts/vpn_prompt.sh /etc/profile.d/vpn_prompt.sh cp bin/vpn /usr/local/bin/vpn setcap cap_sys_admin,cap_sys_ptrace=ep /usr/local/bin/vpn chmod -R 755 /snacks/wireguard diff --git a/scripts/is_root_namespace.py b/scripts/is_root_namespace.py new file mode 100644 index 0000000..b65c593 --- /dev/null +++ b/scripts/is_root_namespace.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +import sys +import re + +with open("/proc/self/net/dev", "r") as f: + data = f.read() + match = re.search("^enp[0-9a-z]+:", data, re.MULTILINE) + if match is None: + sys.exit(1) + else: + sys.exit(0) diff --git a/scripts/vpn_prompt.sh b/scripts/vpn_prompt.sh new file mode 100644 index 0000000..7b8df75 --- /dev/null +++ b/scripts/vpn_prompt.sh @@ -0,0 +1,4 @@ +if ! /snacks/wireguard_scripts/is_root_namespace.py +then + export PS1='%F{red}%f %n@%m % %c %#' +fi