#!/usr/bin/env bash # proxy setup # # Make sure this file defines CURL in any case # Only define http_proxy if you will be using a proxy # # Sample setup using a local squid cache at 10.0.100.2 - the # hypervisor. Change to reflect your real proxy info #export PROXY="10.0.100.2:3128" # define APTPROXY if your apt mirror is accessed via the proxy # do not define if it's local (e.g. on the bootstrap node as per the apache-mirror recipe). #export APTPROXY=$PROXY export CURL='curl' if test -n $PROXY { echo "Setting up and testing proxy" export http_proxy=http://$(PROXY) export https_proxy=https://$(PROXY) # to ignore SSL errors export GIT_SSL_NO_VERIFY=true export CURL="curl -k -x http://$(PROXY)" # sanity check $CURL -s --connect-timeout 1 http://www.ubuntu.com > /dev/null if [[ $? != 0 ]] { echo "Error: proxy $PROXY not responding" exit 1 } else { echo "Using a proxy at $PROXY" } } else { echo "\$PROXY not defined, not defining \$http_proxy and \$https_proxy" } (CommandList children: [ (C {(export)} {(Lit_VarLike "CURL=") (SQ )}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ ($ VSub_Name "$PROXY"))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(echo)} {(DQ ("Setting up and testing proxy"))}) (C {(export)} {(Lit_VarLike "http_proxy=") (http) (Lit_Other ":") (//) (${ VSub_Name PROXY)} ) (C {(export)} {(Lit_VarLike "https_proxy=") (https) (Lit_Other ":") (//) (${ VSub_Name PROXY)} ) (C {(export)} {(Lit_VarLike "GIT_SSL_NO_VERIFY=") (true)}) (C {(export)} {(Lit_VarLike "CURL=") (DQ ("curl -k -x http://") (${ VSub_Name PROXY))}) (SimpleCommand words: [ {($ VSub_Name "$CURL")} {(-s)} {(--connect-timeout)} {(1)} {(http) (Lit_Other ":") (//www.ubuntu.com)} ] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[134])] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_QMark "$?")} right: {(0)} ) ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Error: proxy ") ($ VSub_Name "$PROXY") (" not responding"))}) (C {(exit)} {(1)}) ] spids: [-1 152] ) ] else_action: [(C {(echo)} {(DQ ("Using a proxy at ") ($ VSub_Name "$PROXY"))})] spids: [169 180] ) ] spids: [-1 58] ) ] else_action: [ (C {(echo)} { (DQ (EscapedLiteralPart token:) ("PROXY not defined, not defining ") (EscapedLiteralPart token:) ("http_proxy and ") (EscapedLiteralPart token:) (https_proxy) ) } ) ] spids: [182 196] ) ] )