Advertisement
GodoPPL

SwitchyOmega addProxy.sh

Mar 29th, 2020
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.01 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Add proxies to SwitchyOmega export file
  4. # Remember to set the parametres before using
  5. #
  6. # Example Usage: ./addProxy.sh ovpn/de*
  7.  
  8.  
  9. OPTIONSFILE=OmegaOptions.bak
  10. PORT=80
  11. USERNAME='user@gmail.com'
  12. PASSWORD='password123'
  13.  
  14. if [ $# -eq 0 ]; then
  15.   echo "Please provide one or more ovpn files"
  16.   exit 1
  17. fi
  18.  
  19. for PATHNAME in $@; do
  20.   FILENAME="${PATHNAME##*/}"  # Remove any path info, and return only filename
  21.   HOSTNAME="${FILENAME%%\.tcp\.ovpn}"  # Remove the .tcp.ovpn file extensions
  22.   TEMPLATE='"+'$HOSTNAME'":{"auth":{"fallbackProxy":{"password":"'$PASSWORD'","username":"'$USERNAME'"}},"bypassList":[{"conditionType":"BypassCondition","pattern":"127.0.0.1"},{"conditionType":"BypassCondition","pattern":"::1"},{"conditionType":"BypassCondition","pattern":"localhost"}],"color":"#99ccee","fallbackProxy":{"host":"'$HOSTNAME'","port":'$PORT',"scheme":"http"},"name":"'$HOSTNAME'","profileType":"FixedProfile"},'
  23.   sed -i "s/^{/{$TEMPLATE/" $OPTIONSFILE  # Append the hosts to the Options file
  24. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement