New sequence for installing openvpn with setup of custom scripts

This commit is contained in:
2021-03-27 05:35:11 +00:00
parent 260daa009c
commit 741d0c74c9
7 changed files with 168 additions and 0 deletions

38
seqs/openvpn/up.sh Executable file
View File

@@ -0,0 +1,38 @@
#! /bin/bash
DEV=$1
if [ ! -d /tmp/openvpn ]; then
mkdir /tmp/openvpn
fi
CACHE_NAMESERVER="/tmp/$DEV.nameserver"
echo -n "" > $CACHE_NAMESERVER
TEMP_LOG="/tmp/openvpn_dns.log"
echo "DNS openvpn" > "$TEMP_LOG"
echo -e "${foreign_option_1}\n${foreign_option_2}\n$foreign_option_3" >> "$TEMP_LOG"
rm -rf /tmp/resolv.conf
touch /tmp/resolv.conf
dns=dns
for opt in ${!foreign_option_*}
do
eval "echo \$$opt" >> "$TEMP_LOG"
eval "dns=\${$opt#dhcp-option DNS }"
if [[ $dns =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]; then
if [ ! -f /etc/resolv.conf.default ]; then
cp /etc/resolv.conf /etc/resolv.conf.default
fi
# don't add "local" dns server
#cat /etc/resolv.conf | grep -v ^# | grep -v ^nameserver > /tmp/resolv.conf
echo "nameserver $dns" >> /tmp/resolv.conf
echo $dns >> $CACHE_NAMESERVER
#cat /etc/resolv.conf | grep -v ^# | grep -v "nameserver $dns" | grep nameserver >> /tmp/resolv.conf
fi
done
if [ -e "/tmp/resolv.conf" ]; then
mv /tmp/resolv.conf /etc/resolv.conf
fi