add prompt
This commit is contained in:
parent
e15d424a38
commit
579487db91
2
Makefile
2
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
|
||||
|
11
scripts/is_root_namespace.py
Normal file
11
scripts/is_root_namespace.py
Normal file
@ -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)
|
4
scripts/vpn_prompt.sh
Normal file
4
scripts/vpn_prompt.sh
Normal file
@ -0,0 +1,4 @@
|
||||
if ! /snacks/wireguard_scripts/is_root_namespace.py
|
||||
then
|
||||
export PS1='%F{red}<vpn>%f %n@%m % %c %#'
|
||||
fi
|
Loading…
Reference in New Issue
Block a user