-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchromeos_bashrc
48 lines (40 loc) · 1.18 KB
/
chromeos_bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# Put your fun stuff here.
# VPN functions
function workdns(){
normdns
cp -v ~/vpn_resolv.conf_bak ~/vpn_resolv.conf &&
if sudo mount -v --bind ~/vpn_resolv.conf /var/run/shill/resolv.conf; then
echo "DNS settings succesfully changed"
fi
}
function startvpn(){
echo "startvpn function"
sudo openvpn --mktun --dev tun0 &&
sleep 3 &&
workdns &&
sudo openvpn --config ~/client.ovpn --dev tun0 &&
normdns
}
function normdns(){
# Unmount all mounts
while true
do
if ! sudo umount -v /var/run/shill/resolv.conf; then
echo "Restored DNS settings"
break
fi
done
}