[feat] Initial work for running setup through proxy

This commit is contained in:
William Wernert
2020-05-22 11:40:16 -04:00
parent 967148890c
commit b029d9aca6
4 changed files with 58 additions and 4 deletions

View File

@@ -948,6 +948,35 @@ node_pillar() {
cat "$pillar_file" >> "$setup_log" 2>&1 cat "$pillar_file" >> "$setup_log" 2>&1
} }
parse_options() {
case "$1" in
--turbo=*)
local proxy
proxy=$(echo "$1" | awk -F'--turbo=' '{print $2}')
use_proxy "http://$proxy"
;;
--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 user
local password
proxy=$(echo "$1" | awk -F'--proxy=' '{print $2}')
user=$(echo "$2" | awk -F'--proxy-user=' '{print $2}')
password=$(echo "$3" | awk -F'--proxy-pass=' '{print $2}')
use_proxy "$proxy" "$user" "$password"
fi
;;
*)
echo "Invalid option"
esac
}
patch_pillar() { patch_pillar() {
local pillar_file=$temp_install_dir/pillar/minions/$MINION_ID.sls local pillar_file=$temp_install_dir/pillar/minions/$MINION_ID.sls
@@ -1443,6 +1472,26 @@ update_packages() {
fi fi
} }
use_proxy() {
local proxy_addr=$1
#TODO: add options for username + pass
if [[ $OS == 'centos' ]]; then
printf '%s\n'\
"proxy=\"$proxy_addr\"" >> /etc/yum.conf
else
printf '%s\n'\
"Acquire {"\
"HTTP::proxy \"$proxy_addr\";"\
"HTTPS::proxy \"$proxy_addr\";"\
"}" > /etc/apt/apt.conf.d/proxy.conf
fi
mkdir -p /etc/systemd/system/docker.service.d
printf '%s\n'\
"[Service]"\
"ExecStart=/usr/bin/dockerd /usr/bin/dockerd -H fd:// --registry-mirror \"$proxy_addr\"" > /etc/systemd/system/docker.service.d/docker.conf
}
ls_heapsize() { ls_heapsize() {
if [ "$total_mem" -ge 32000 ]; then if [ "$total_mem" -ge 32000 ]; then

View File

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

View File

@@ -1048,7 +1048,7 @@ whiptail_you_sure() {
[ -n "$TESTING" ] && return [ -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=$? local exitstatus=$?
return $exitstatus return $exitstatus

View File

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