Merge pull request #759 from Security-Onion-Solutions/feature/turbo-proxy

Feature/turbo proxy
This commit is contained in:
William Wernert
2020-05-22 16:31:20 -04:00
committed by GitHub
4 changed files with 62 additions and 5 deletions

View File

@@ -619,9 +619,10 @@ docker_registry() {
echo "Setting up Docker Registry" >> "$setup_log" 2>&1
mkdir -p /etc/docker >> "$setup_log" 2>&1
# Make the host use the master docker registry
if [ -n "$TURBO" ]; then local proxy="$TURBO"; else local proxy="https://$MSRV"; fi
printf '%s\n'\
"{"\
" \"registry-mirrors\": [\"https://$MSRV:5000\"]"\
" \"registry-mirrors\": [ \"$proxy:5000\" ]"\
"}" > /etc/docker/daemon.json
echo "Docker Registry Setup - Complete" >> "$setup_log" 2>&1
@@ -951,6 +952,41 @@ node_pillar() {
cat "$pillar_file" >> "$setup_log" 2>&1
}
parse_options() {
case "$1" in
--turbo=*)
if [[ $is_master || $is_helix ]]; then
local proxy
proxy=$(echo "$1" | tr -d '"' | awk -F'--turbo=' '{print $2}')
proxy_addr="http://$proxy"
use_proxy "$proxy_addr"
TURBO="$proxy_addr"
else
echo "turbo is not supported on this install type" >> $setup_log 2>&1
fi
;;
--proxy=*)
echo "Unimplimented"
return
if [[ $2 != --proxy-user=* ]] || [[ $3 != --proxy-pass=* ]]; then
echo "Invalid options passed for proxy. Order is --proxy-user=<user> --proxy-pass=<password>"
else
local proxy
local proxy_user
local proxy_password
proxy=$(echo "$1" | tr -d '"' | awk -F'--proxy=' '{print $2}')
proxy_user=$(echo "$2" | tr -d '"' | awk -F'--proxy-user=' '{print $2}')
proxy_password=$(echo "$3" | tr -d '"' | awk -F'--proxy-pass=' '{print $2}')
use_proxy "$proxy" "$proxy_user" "$proxy_password"
fi
;;
*)
echo "Invalid option"
esac
}
patch_pillar() {
local pillar_file=$temp_install_dir/pillar/minions/$MINION_ID.sls
@@ -1446,6 +1482,22 @@ update_packages() {
fi
}
use_proxy() {
local proxy_addr=$1
#TODO: add options for username + pass
if [[ $OS == 'centos' ]]; then
printf '%s\n'\
"proxy=${proxy_addr}:3142" >> /etc/yum.conf
else
printf '%s\n'\
"Acquire {"\
"HTTP::proxy \"${proxy_addr}:3142\";"\
"HTTPS::proxy \"${proxy_addr}:3142\";"\
"}" > /etc/apt/apt.conf.d/proxy.conf
fi
}
ls_heapsize() {
if [ "$total_mem" -ge 32000 ]; then

View File

@@ -54,7 +54,7 @@ fi
setterm -blank 0
if (whiptail_you_sure); then
if [ "$setup_type" == 'iso' ] || (whiptail_you_sure); then
true
else
echo "User cancelled setup." >> $setup_log 2>&1
@@ -247,6 +247,11 @@ fi
whiptail_make_changes
if [[ $# -gt 1 ]]; then
set -- "${@:2}"
parse_options "$@" >> $setup_log 2>&1
fi
if [[ "$setup_type" == 'iso' ]]; then
# Init networking so rest of install works
set_hostname_iso

View File

@@ -1048,7 +1048,7 @@ whiptail_you_sure() {
[ -n "$TESTING" ] && return
whiptail --title "Security Onion Setup" --yesno "Are you sure you want to install Security Onion over the internet?" 8 75
whiptail --title "Security Onion Setup" --yesno "Are you sure you want to continue a network install of Security Onion?" 8 75
local exitstatus=$?
return $exitstatus

View File

@@ -15,6 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cd setup
cd setup || exit
./so-setup network
./so-setup network "$@"