Skip to content

Instantly share code, notes, and snippets.

@fionn
Last active November 4, 2017 07:23
Show Gist options
  • Save fionn/f908c315298960589c6cb07b7c06383f to your computer and use it in GitHub Desktop.
Save fionn/f908c315298960589c6cb07b7c06383f to your computer and use it in GitHub Desktop.
Add a credential file to OpenVPN configurations
#/bin/bash
if [ $(id -u) != 0 ]; then
echo "You must be root"
sudo "$0" "$@"
exit $?
fi
for file in $@; do
sed -i "s|^auth-user-pass$|& /etc/openvpn/client/provider/secret.password|" $file
if [[ $? -ne 0 ]]; then
exit $?
fi
done
exit $?
#!/bin/bash
if [ $(id -u) != 0 ]; then
echo "You must be root"
sudo "$0" "$@"
exit $?
fi
resolv_path=/etc/openvpn/client/update-resolv-conf.sh
for file in $@; do
echo "script-security 2" >> $file
echo "up $resolv_path" >> $file
echo "down $resolv_path" >> $file
if [[ $? -ne 0 ]]; then
exit $?
fi
done
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment