您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

adjustConfigs.sh 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. bold=$(tput bold)
  3. normal=$(tput sgr0)
  4. #
  5. # This is a script to ease the process of updating and adding .ovpn files to the project.
  6. # As some customizations have to be done with the .ovpn files from the providers
  7. # this script was created to make it easy and also to highlight which changes we actually do and why.
  8. #
  9. # Intended usage is to download .zip (or other) package with .ovpn files from your provider.
  10. # Then delete the content in the provider-folder, replace with the new ones, run the script and it should be quite good.
  11. # Just need to double check that the default.ovpn is still there and that the diff to origin looks reasonable.
  12. #
  13. display_usage() {
  14. echo "${bold}Hint: read the script before using it${normal}"
  15. echo "If you just forgot: ./adjustConfigs.sh <provider-folder>"
  16. }
  17. # if no arguments supplied, display usage
  18. if [ $# -lt 1 ]
  19. then
  20. display_usage
  21. exit 1
  22. fi
  23. provider=$1
  24. for configFile in $provider/*.ovpn;
  25. do
  26. if [[ -L ${configFile} ]]; then
  27. continue # Don't edit symbolic links (default.ovpn)
  28. fi
  29. # Absolute reference to ca cert
  30. sed -i "s/ca .*\.crt/ca \/etc\/openvpn\/$provider\/ca.crt/g" "$configFile"
  31. # Absolute reference to Wdc key file
  32. sed -i "s/tls-auth Wdc.key 1/tls-auth \/etc\/openvpn\/$provider\/Wdc.key 1/g" "$configFile"
  33. # Absolute reference to crl
  34. sed -i "s/crl-verify.*\.pem/crl-verify \/etc\/openvpn\/$provider\/crl.pem/g" "$configFile"
  35. # Set user-pass file location
  36. sed -i "s/auth-user-pass.*/auth-user-pass \/config\/openvpn-credentials.txt/g" "$configFile"
  37. done
  38. echo "Updated all .ovpn files in folder $provider"