Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-17 07:05:55

0001 #!/bin/bash
0002 set -o nounset
0003 set -o errexit
0004 
0005 PROXY_PROFILE=$USER
0006 PROXY_PORT=8020
0007 SSH_HOST="sodium"
0008 
0009 function print_the_help {
0010   echo "USAGE: ${0} [-p <PROXY_PORT>] [-n <PROFILE_NAME>] [-s SSH_HOST] "
0011   echo "  OPTIONS: "
0012   echo "       -s,--host      ssh host. Default: sodium"
0013   echo "       -p,--port      Proxy port number. Default: 8020"
0014   echo "       -n,--profile   Profile name to use. Sets profile directory to ~/.proxy-profiles/PROFILE_NAME"
0015   echo " " 
0016   echo "  EXAMPLE: " 
0017   echo "    ${0} -p 8920 -n sodium sodium  " 
0018   exit 
0019 }
0020 
0021 function yes_or_no {
0022   while true; do
0023     read -p "$* [y/n]: " yn
0024     case $yn in
0025       [Yy]*) return 0 ;;
0026       [Nn]*) echo "No entered" ; return 1 ;;
0027     esac
0028   done
0029 }
0030 if [[ $# -eq 0 ]] ; then
0031   print_the_help
0032   exit 
0033 fi
0034 
0035 POSITIONAL=()
0036 while [[ $# -gt 0 ]]
0037 do
0038   key="$1"
0039 
0040   case $key in
0041     -h|--help)
0042       shift # past argument
0043       print_the_help
0044       exit
0045       ;;
0046     -p|--port)
0047       PROXY_PORT="$2"
0048       shift # past argument
0049       shift # past value
0050       ;;
0051     -n|--profile)
0052       PROXY_PROFILE="$2"
0053       shift # past argument
0054       shift # past value
0055       ;;
0056     -s|--host)
0057       SSH_HOST="$2"
0058       shift # past argument
0059       shift # past value
0060       ;;
0061     *)    # unknown option
0062       #POSITIONAL+=("$1") # save it in an array for later
0063       echo "unknown option $1"
0064       print_the_help
0065       exit
0066       shift # past argument
0067       ;;
0068   esac
0069 done
0070 set -- "${POSITIONAL[@]}" # restore positional parameters
0071 
0072 #yes_or_no "Upload these plots to logbook HALOG? " && some_command
0073 
0074 echo " " 
0075 echo "ssh -n -D ${PROXY_PORT} ${SSH_HOST}"
0076 echo " " 
0077 
0078 ssh -n -D ${PROXY_PORT} ${SSH_HOST} &
0079 
0080 chromium-browser     \
0081   --user-data-dir="$HOME/.proxy-profiles/${PROXY_PROFILE}" \
0082   --proxy-server="socks5://localhost:${PROXY_PORT}"  &> /dev/null &
0083 
0084 echo " " 
0085 echo "You are now tunneling all traffic through proxy ${SSH_HOST} on port ${PROXY_PORT}"
0086 echo " " 
0087 
0088