Last active
April 14, 2020 06:52
-
-
Save jmcker/df3bd99d4dbed30951aa943c3d808df9 to your computer and use it in GitHub Desktop.
Touch ups for my massive collection of OpenVPN profiles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
backup_dir="backup-$(date +%Y-%m-%d_%H:%M:%S)" | |
mkdir -p "${backup_dir}" | |
cp *.ovpn "${backup_dir}" | |
for file in $(ls *.ovpn) | |
do | |
if ! cat "${file}" | grep "block-outside-dns" > /dev/null; then | |
echo "Adding 'block-outside-dns' to ${file}..." | |
sed -i 's/<ca>/block-outside-dns\n\n<ca>/g' "${file}" | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
backup_dir="backup-$(date +%Y-%m-%d_%H:%M:%S)" | |
mkdir -p "${backup_dir}" | |
cp *.ovpn "${backup_dir}" | |
# auth.conf should contain username and password on separate lines | |
[ ! -f auth.conf ] && touch auth.conf | |
chmod 600 auth.conf | |
for file in *.ovpn; do | |
sed -ri 's/auth-user-pass( auth.conf)*/auth-user-pass auth.conf/g' "${file}" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
backup_dir="backup-$(date +%Y-%m-%d_%H:%M:%S)" | |
mkdir -p "${backup_dir}" | |
cp *.ovpn "${backup_dir}" | |
for file in $(ls *.ovpn) | |
do | |
# Strip the port number | |
if echo "${file}" | grep -E ".*(udp|tcp)[0-9]+.*" > /dev/null; then | |
fixed_name=$(echo "${file}" | sed -r 's/(udp|tcp)[0-9]+/\1/g') | |
mv -v "${file}" "${fixed_name}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment