mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 17:52:46 +01:00
merge with 2.3.40
This commit is contained in:
78
setup/automation/standalone-net-centos-proxy
Normal file
78
setup/automation/standalone-net-centos-proxy
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014,2015,2016,2017,2018,2019,2020,2021 Security Onion Solutions, LLC
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
TESTING=true
|
||||
|
||||
# address_type=DHCP
|
||||
ADMINUSER=onionuser
|
||||
ADMINPASS1=onionuser
|
||||
ADMINPASS2=onionuser
|
||||
ALLOW_CIDR=0.0.0.0/0
|
||||
ALLOW_ROLE=a
|
||||
BASICZEEK=2
|
||||
BASICSURI=2
|
||||
# BLOGS=
|
||||
BNICS=eth1
|
||||
ZEEKVERSION=ZEEK
|
||||
# CURCLOSEDAYS=
|
||||
# EVALADVANCED=BASIC
|
||||
GRAFANA=1
|
||||
# HELIXAPIKEY=
|
||||
HNMANAGER=10.0.0.0/8,192.168.0.0/16,172.16.0.0/12
|
||||
HNSENSOR=inherit
|
||||
HOSTNAME=standalone
|
||||
install_type=STANDALONE
|
||||
# LSINPUTBATCHCOUNT=
|
||||
# LSINPUTTHREADS=
|
||||
# LSPIPELINEBATCH=
|
||||
# LSPIPELINEWORKERS=
|
||||
MANAGERADV=BASIC
|
||||
MANAGERUPDATES=1
|
||||
# MDNS=
|
||||
# MGATEWAY=
|
||||
# MIP=
|
||||
# MMASK=
|
||||
MNIC=eth0
|
||||
# MSEARCH=
|
||||
# MSRV=
|
||||
# MTU=
|
||||
NIDS=Suricata
|
||||
# NODE_ES_HEAP_SIZE=
|
||||
# NODE_LS_HEAP_SIZE=
|
||||
NODESETUP=NODEBASIC
|
||||
NSMSETUP=BASIC
|
||||
NODEUPDATES=MANAGER
|
||||
# OINKCODE=
|
||||
OSQUERY=1
|
||||
# PATCHSCHEDULEDAYS=
|
||||
# PATCHSCHEDULEHOURS=
|
||||
PATCHSCHEDULENAME=auto
|
||||
PLAYBOOK=1
|
||||
so_proxy=http://onionuser:0n10nus3r@10.66.166.30:3128
|
||||
# REDIRECTHOST=
|
||||
REDIRECTINFO=IP
|
||||
RULESETUP=ETOPEN
|
||||
# SHARDCOUNT=
|
||||
# SKIP_REBOOT=
|
||||
SOREMOTEPASS1=onionuser
|
||||
SOREMOTEPASS2=onionuser
|
||||
STRELKA=1
|
||||
THEHIVE=1
|
||||
WAZUH=1
|
||||
WEBUSER=onionuser@somewhere.invalid
|
||||
WEBPASSWD1=0n10nus3r
|
||||
WEBPASSWD2=0n10nus3r
|
||||
@@ -1,2 +0,0 @@
|
||||
[Service]
|
||||
ExecStart=/usr/bin/dockerd /usr/bin/dockerd -H fd:// --registry-mirror "$proxy_addr"
|
||||
@@ -535,6 +535,56 @@ collect_patch_schedule_name_import() {
|
||||
done
|
||||
}
|
||||
|
||||
collect_proxy() {
|
||||
[[ -n $TESTING ]] && return
|
||||
collect_proxy_details
|
||||
while ! proxy_validate; do
|
||||
if whiptail_invalid_proxy; then
|
||||
collect_proxy_details no_ask
|
||||
else
|
||||
so_proxy=""
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
collect_proxy_details() {
|
||||
local ask=${1:-true}
|
||||
local use_proxy
|
||||
if [[ $ask != true ]]; then
|
||||
use_proxy=0
|
||||
else
|
||||
whiptail_proxy_ask
|
||||
use_proxy=$?
|
||||
fi
|
||||
|
||||
if [[ $use_proxy == 0 ]]; then
|
||||
whiptail_proxy_addr "$proxy_addr"
|
||||
|
||||
while ! valid_proxy "$proxy_addr"; do
|
||||
whiptail_invalid_input
|
||||
whiptail_proxy_addr "$proxy_addr"
|
||||
done
|
||||
|
||||
if whiptail_proxy_auth_ask; then
|
||||
whiptail_proxy_auth_user "$proxy_user"
|
||||
whiptail_proxy_auth_pass "$proxy_pass"
|
||||
|
||||
local url_prefixes=( 'http://' 'https://' )
|
||||
for prefix in "${url_prefixes[@]}"; do
|
||||
if echo "$proxy_addr" | grep -q "$prefix"; then
|
||||
local proxy=${proxy_addr#"$prefix"}
|
||||
so_proxy="${prefix}${proxy_user}:${proxy_pass}@${proxy}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
so_proxy="$proxy_addr"
|
||||
fi
|
||||
export proxy
|
||||
fi
|
||||
}
|
||||
|
||||
collect_redirect_host() {
|
||||
whiptail_set_redirect_host "$HOSTNAME"
|
||||
|
||||
@@ -691,10 +741,10 @@ check_requirements() {
|
||||
else
|
||||
req_storage=100
|
||||
fi
|
||||
if (( $(echo "$free_space_root < $req_storage" | bc -l) )); then
|
||||
if [[ $free_space_root -lt $req_storage ]]; then
|
||||
whiptail_storage_requirements "/" "${free_space_root} GB" "${req_storage} GB"
|
||||
fi
|
||||
if (( $(echo "$free_space_nsm < $req_storage" | bc -l) )); then
|
||||
if [[ $free_space_nsm -lt $req_storage ]]; then
|
||||
whiptail_storage_requirements "/nsm" "${free_space_nsm} GB" "${req_storage} GB"
|
||||
fi
|
||||
else
|
||||
@@ -703,7 +753,7 @@ check_requirements() {
|
||||
else
|
||||
req_storage=200
|
||||
fi
|
||||
if (( $(echo "$free_space_root < $req_storage" | bc -l) )); then
|
||||
if [[ $free_space_root -lt $req_storage ]]; then
|
||||
whiptail_storage_requirements "/" "${free_space_root} GB" "${req_storage} GB"
|
||||
fi
|
||||
fi
|
||||
@@ -743,12 +793,14 @@ check_sos_appliance() {
|
||||
compare_main_nic_ip() {
|
||||
if ! [[ $MNIC =~ ^(tun|wg|vpn).*$ ]]; then
|
||||
if [[ "$MAINIP" != "$MNIC_IP" ]]; then
|
||||
error "[ERROR] Main gateway ($MAINIP) does not match ip address of managament NIC ($MNIC_IP)."
|
||||
|
||||
read -r -d '' message <<- EOM
|
||||
The IP being routed by Linux is not the IP address assigned to the management interface ($MNIC).
|
||||
|
||||
This is not a supported configuration, please remediate and rerun setup.
|
||||
EOM
|
||||
whiptail --title "Security Onion Setup" --msgbox "$message" 10 75
|
||||
EOM
|
||||
[[ -n $TESTING ]] || whiptail --title "Security Onion Setup" --msgbox "$message" 10 75
|
||||
kill -SIGINT "$(ps --pid $$ -oppid=)"; exit 1
|
||||
fi
|
||||
else
|
||||
@@ -897,7 +949,7 @@ create_repo() {
|
||||
}
|
||||
|
||||
detect_cloud() {
|
||||
echo "Testing if setup is running on a cloud instance..." >> "$setup_log" 2>&1
|
||||
echo "Testing if setup is running on a cloud instance..." | tee -a "$setup_log"
|
||||
if ( curl --fail -s -m 5 http://169.254.169.254/latest/meta-data/instance-id > /dev/null ) || ( dmidecode -s bios-vendor | grep -q Google > /dev/null); then export is_cloud="true"; fi
|
||||
}
|
||||
|
||||
@@ -939,36 +991,29 @@ detect_os() {
|
||||
|
||||
}
|
||||
|
||||
installer_prereq_packages() {
|
||||
installer_progress_loop() {
|
||||
local i=0
|
||||
while true; do
|
||||
[[ $i -lt 98 ]] && ((i++))
|
||||
set_progress_str "$i" 'Checking that all required packages are installed and enabled...' nolog
|
||||
[[ $i -gt 0 ]] && sleep 5s
|
||||
done
|
||||
}
|
||||
|
||||
installer_prereq_packages() {
|
||||
if [ "$OS" == centos ]; then
|
||||
# Print message to stdout so the user knows setup is doing something
|
||||
echo "Installing required packages to run installer..."
|
||||
# Install bind-utils so the host command exists
|
||||
if [[ ! $is_iso ]]; then
|
||||
if ! command -v host > /dev/null 2>&1; then
|
||||
yum -y install bind-utils >> "$setup_log" 2>&1
|
||||
fi
|
||||
if ! command -v nmcli > /dev/null 2>&1; then
|
||||
{
|
||||
yum -y install NetworkManager;
|
||||
systemctl enable NetworkManager;
|
||||
systemctl start NetworkManager;
|
||||
} >> "$setup_log" 2<&1
|
||||
fi
|
||||
if ! command -v bc > /dev/null 2>&1; then
|
||||
yum -y install bc >> "$setup_log" 2>&1
|
||||
fi
|
||||
if ! yum versionlock > /dev/null 2>&1; then
|
||||
yum -y install yum-plugin-versionlock >> "$setup_log" 2>&1
|
||||
fi
|
||||
else
|
||||
logCmd "systemctl enable NetworkManager"
|
||||
logCmd "systemctl start NetworkManager"
|
||||
fi
|
||||
if ! yum versionlock > /dev/null 2>&1; then
|
||||
yum -y install yum-plugin-versionlock >> "$setup_log" 2>&1
|
||||
fi
|
||||
if ! command -v nmcli > /dev/null 2>&1; then
|
||||
yum -y install NetworkManager >> "$setup_log" 2>&1
|
||||
fi
|
||||
fi
|
||||
logCmd "systemctl enable NetworkManager"
|
||||
logCmd "systemctl start NetworkManager"
|
||||
elif [ "$OS" == ubuntu ]; then
|
||||
# Print message to stdout so the user knows setup is doing something
|
||||
echo "Installing required packages to run installer..."
|
||||
retry 50 10 "apt-get update" >> "$setup_log" 2>&1 || exit 1
|
||||
# Install network manager so we can do interface stuff
|
||||
if ! command -v nmcli > /dev/null 2>&1; then
|
||||
@@ -978,7 +1023,7 @@ installer_prereq_packages() {
|
||||
systemctl start NetworkManager
|
||||
} >> "$setup_log" 2<&1
|
||||
fi
|
||||
retry 50 10 "apt-get -y install bc curl" >> "$setup_log" 2>&1 || exit 1
|
||||
retry 50 10 "apt-get -y install curl" >> "$setup_log" 2>&1 || exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1002,11 +1047,11 @@ disable_ipv6() {
|
||||
sysctl -w net.ipv6.conf.all.disable_ipv6=1
|
||||
sysctl -w net.ipv6.conf.default.disable_ipv6=1
|
||||
} >> "$setup_log" 2>&1
|
||||
{
|
||||
echo "net.ipv6.conf.all.disable_ipv6 = 1"
|
||||
echo "net.ipv6.conf.default.disable_ipv6 = 1"
|
||||
echo "net.ipv6.conf.lo.disable_ipv6 = 1"
|
||||
} >> /etc/sysctl.conf
|
||||
{
|
||||
echo "net.ipv6.conf.all.disable_ipv6 = 1"
|
||||
echo "net.ipv6.conf.default.disable_ipv6 = 1"
|
||||
echo "net.ipv6.conf.lo.disable_ipv6 = 1"
|
||||
} >> /etc/sysctl.conf
|
||||
}
|
||||
|
||||
#disable_misc_network_features() {
|
||||
@@ -1044,10 +1089,11 @@ docker_install() {
|
||||
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo;
|
||||
fi
|
||||
if [[ ! $is_iso ]]; then
|
||||
yum -y install docker-ce-19.03.14-3.el7 containerd.io-1.2.13-3.2.el7;
|
||||
yum -y install docker-ce-20.10.5-3.el7 containerd.io-1.4.4-3.1.el7;
|
||||
fi
|
||||
yum versionlock docker-ce-19.03.14-3.el7;
|
||||
yum versionlock containerd.io-1.2.13-3.2.el7
|
||||
yum versionlock docker-ce-20.10.5-3.el7;
|
||||
yum versionlock docker-ce-cli-20.10.5-3.el7;
|
||||
yum versionlock containerd.io-1.4.4-3.1.el7
|
||||
} >> "$setup_log" 2>&1
|
||||
|
||||
else
|
||||
@@ -1201,8 +1247,13 @@ es_heapsize() {
|
||||
# https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html
|
||||
ES_HEAP_SIZE="25000m"
|
||||
else
|
||||
# Set heap size to 25% of available memory
|
||||
ES_HEAP_SIZE=$(( total_mem / 4 ))"m"
|
||||
# Set heap size to 33% of available memory
|
||||
ES_HEAP_SIZE=$(( total_mem / 3 ))
|
||||
if [ "$ES_HEAP_SIZE" -ge 25001 ] ; then
|
||||
ES_HEAP_SIZE="25000m"
|
||||
else
|
||||
ES_HEAP_SIZE=$ES_HEAP_SIZE"m"
|
||||
fi
|
||||
fi
|
||||
export ES_HEAP_SIZE
|
||||
|
||||
@@ -1385,6 +1436,8 @@ install_cleanup() {
|
||||
info "Removing so-setup permission entry from sudoers file"
|
||||
sed -i '/so-setup/d' /etc/sudoers
|
||||
fi
|
||||
|
||||
so-ssh-harden -q
|
||||
}
|
||||
|
||||
import_registry_docker() {
|
||||
@@ -1432,6 +1485,8 @@ manager_pillar() {
|
||||
"manager:"\
|
||||
" mainip: '$MAINIP'"\
|
||||
" mainint: '$MNIC'"\
|
||||
" proxy: '$so_proxy'"\
|
||||
" no_proxy: '$no_proxy_string'"\
|
||||
" esheap: '$ES_HEAP_SIZE'"\
|
||||
" esclustername: '{{ grains.host }}'"\
|
||||
" freq: 0"\
|
||||
@@ -1446,7 +1501,6 @@ manager_pillar() {
|
||||
printf '%s\n'\
|
||||
" elastalert: 1"\
|
||||
" es_port: $node_es_port"\
|
||||
" log_size_limit: $log_size_limit"\
|
||||
" cur_close_days: $CURCLOSEDAYS"\
|
||||
" grafana: $GRAFANA"\
|
||||
" osquery: $OSQUERY"\
|
||||
@@ -1512,7 +1566,6 @@ manager_global() {
|
||||
" hnmanager: '$HNMANAGER'"\
|
||||
" ntpserver: '$NTPSERVER'"\
|
||||
" dockernet: '$DOCKERNET'"\
|
||||
" proxy: '$PROXY'"\
|
||||
" mdengine: '$ZEEKVERSION'"\
|
||||
" ids: '$NIDS'"\
|
||||
" url_base: '$REDIRECTIT'"\
|
||||
@@ -1642,8 +1695,8 @@ manager_global() {
|
||||
" so-zeek:"\
|
||||
" shards: 5"\
|
||||
" warm: 7"\
|
||||
" close: 365"\
|
||||
" delete: 45"\
|
||||
" close: 45"\
|
||||
" delete: 365"\
|
||||
"minio:"\
|
||||
" access_key: '$ACCESS_KEY'"\
|
||||
" access_secret: '$ACCESS_SECRET'"\
|
||||
@@ -1695,7 +1748,6 @@ network_init() {
|
||||
network_init_whiptail() {
|
||||
case "$setup_type" in
|
||||
'iso')
|
||||
collect_hostname
|
||||
whiptail_management_nic
|
||||
whiptail_dhcp_or_static
|
||||
|
||||
@@ -1709,7 +1761,6 @@ network_init_whiptail() {
|
||||
'network')
|
||||
whiptail_network_notice
|
||||
whiptail_dhcp_warn
|
||||
collect_hostname
|
||||
whiptail_management_nic
|
||||
;;
|
||||
esac
|
||||
@@ -1777,6 +1828,22 @@ print_salt_state_apply() {
|
||||
echo "Applying $state Salt state"
|
||||
}
|
||||
|
||||
proxy_validate() {
|
||||
local test_url="https://raw.githubusercontent.com/Security-Onion-Solutions/securityonion/master/KEYS"
|
||||
proxy_test_err=$(curl -sS "$test_url" --proxy "$so_proxy" 2>&1)
|
||||
local ret=$?
|
||||
|
||||
if [[ $ret != 0 ]]; then
|
||||
error "Could not reach $test_url using proxy $so_proxy"
|
||||
error "Received error: $proxy_test_err"
|
||||
if [[ -n $TESTING ]]; then
|
||||
error "Exiting setup"
|
||||
kill -SIGINT "$(ps --pid $$ -oppid=)"; exit 1
|
||||
fi
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
|
||||
reserve_group_ids() {
|
||||
# This is a hack to fix CentOS from taking group IDs that we need
|
||||
groupadd -g 928 kratos
|
||||
@@ -1870,6 +1937,24 @@ reinstall_init() {
|
||||
} >> "$setup_log" 2>&1
|
||||
}
|
||||
|
||||
reset_proxy() {
|
||||
[[ -f /etc/profile.d/so-proxy.sh ]] && rm -f /etc/profile.d/so-proxy.sh
|
||||
|
||||
[[ -f /etc/systemd/system/docker.service.d/http-proxy.conf ]] && rm -f /etc/systemd/system/docker.service.d/http-proxy.conf
|
||||
systemctl daemon-reload
|
||||
command -v docker &> /dev/null && echo "Restarting Docker..." | tee -a "$setup_log" && systemctl restart docker
|
||||
|
||||
[[ -f /root/.docker/config.json ]] && rm -f /root/.docker/config.json
|
||||
|
||||
[[ -f /etc/gitconfig ]] && rm -f /etc/gitconfig
|
||||
|
||||
if [[ $OS == 'centos' ]]; then
|
||||
sed -i "/proxy=/d" /etc/yum.conf
|
||||
else
|
||||
[[ -f /etc/apt/apt.conf.d/00-proxy.conf ]] && rm -f /etc/apt/apt.conf.d/00-proxy.conf
|
||||
fi
|
||||
}
|
||||
|
||||
backup_dir() {
|
||||
dir=$1
|
||||
backup_suffix=$2
|
||||
@@ -1964,6 +2049,7 @@ saltify() {
|
||||
python36-dateutil\
|
||||
python36-m2crypto\
|
||||
python36-mysql\
|
||||
python36-packaging\
|
||||
yum-utils\
|
||||
device-mapper-persistent-data\
|
||||
lvm2\
|
||||
@@ -2052,9 +2138,9 @@ saltify() {
|
||||
retry 50 10 "apt-get -y install salt-minion=3002.5+ds-1 salt-common=3002.5+ds-1" >> "$setup_log" 2>&1 || exit 1
|
||||
retry 50 10 "apt-mark hold salt-minion salt-common" >> "$setup_log" 2>&1 || exit 1
|
||||
if [[ $OSVER != 'xenial' ]]; then
|
||||
retry 50 10 "apt-get -y install python3-pip python3-dateutil python3-m2crypto python3-mysqldb python3-influxdb" >> "$setup_log" 2>&1 || exit 1
|
||||
retry 50 10 "apt-get -y install python3-pip python3-dateutil python3-m2crypto python3-mysqldb python3-packaging python3-influxdb" >> "$setup_log" 2>&1 || exit 1
|
||||
else
|
||||
retry 50 10 "apt-get -y install python-pip python-dateutil python-m2crypto python-mysqldb python-influxdb" >> "$setup_log" 2>&1 || exit 1
|
||||
retry 50 10 "apt-get -y install python-pip python-dateutil python-m2crypto python-mysqldb python-packaging python-influxdb" >> "$setup_log" 2>&1 || exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -2196,7 +2282,70 @@ set_main_ip() {
|
||||
|
||||
# Add /usr/sbin to everyone's path
|
||||
set_path() {
|
||||
echo "complete -cf sudo" > /etc/profile.d/securityonion.sh
|
||||
echo "complete -cf sudo" >> /etc/profile.d/securityonion.sh
|
||||
}
|
||||
|
||||
set_proxy() {
|
||||
|
||||
# Don't proxy localhost, local ip, and management ip
|
||||
no_proxy_string="localhost, 127.0.0.1, ${MAINIP}, ${HOSTNAME}"
|
||||
if [[ -n $MSRV ]] && [[ -n $MSRVIP ]];then
|
||||
no_proxy_string="${no_proxy_string}, ${MSRVIP}, ${MSRV}"
|
||||
fi
|
||||
|
||||
# Set proxy environment variables used by curl, wget, docker, and others
|
||||
{
|
||||
echo "export use_proxy=on"
|
||||
echo "export http_proxy=\"${so_proxy}\""
|
||||
echo "export https_proxy=\"\$http_proxy\""
|
||||
echo "export ftp_proxy=\"\$http_proxy\""
|
||||
echo "export no_proxy=\"${no_proxy_string}\""
|
||||
} > /etc/profile.d/so-proxy.sh
|
||||
|
||||
source /etc/profile.d/so-proxy.sh
|
||||
|
||||
[[ -d '/etc/systemd/system/docker.service.d' ]] || mkdir -p /etc/systemd/system/docker.service.d
|
||||
|
||||
# Create proxy config for dockerd
|
||||
printf '%s\n'\
|
||||
"[Service]"\
|
||||
"Environment=\"HTTP_PROXY=${so_proxy}\""\
|
||||
"Environment=\"HTTPS_PROXY=${so_proxy}\""\
|
||||
"Environment=\"NO_PROXY=${no_proxy_string}\"" > /etc/systemd/system/docker.service.d/http-proxy.conf
|
||||
|
||||
systemctl daemon-reload
|
||||
command -v docker &> /dev/null && systemctl restart docker
|
||||
|
||||
# Create config.json for docker containers
|
||||
[[ -d /root/.docker ]] || mkdir /root/.docker
|
||||
printf '%s\n'\
|
||||
"{"\
|
||||
" \"proxies\":"\
|
||||
" {"\
|
||||
" \"default\":"\
|
||||
" {"\
|
||||
" \"httpProxy\":\"${so_proxy}\","\
|
||||
" \"httpsProxy\":\"${so_proxy}\","\
|
||||
" \"ftpProxy\":\"${so_proxy}\","\
|
||||
" \"noProxy\":\"${no_proxy_string}\""\
|
||||
" }"\
|
||||
" }"\
|
||||
"}" > /root/.docker/config.json
|
||||
|
||||
# Set proxy for package manager
|
||||
if [ "$OS" = 'centos' ]; then
|
||||
echo "proxy=$so_proxy" >> /etc/yum.conf
|
||||
else
|
||||
# Set it up so the updates roll through the manager
|
||||
printf '%s\n'\
|
||||
"Acquire::http::Proxy \"$so_proxy\";"\
|
||||
"Acquire::https::Proxy \"$so_proxy\";" > /etc/apt/apt.conf.d/00-proxy.conf
|
||||
fi
|
||||
|
||||
# Set global git proxy
|
||||
printf '%s\n'\
|
||||
"[http]"\
|
||||
" proxy = ${so_proxy}" > /etc/gitconfig
|
||||
}
|
||||
|
||||
setup_salt_master_dirs() {
|
||||
@@ -2227,6 +2376,7 @@ set_progress_str() {
|
||||
local percentage_input=$1
|
||||
progress_bar_text=$2
|
||||
export progress_bar_text
|
||||
local nolog=$2
|
||||
|
||||
if (( "$percentage_input" >= "$percentage" )); then
|
||||
percentage="$percentage_input"
|
||||
@@ -2236,12 +2386,14 @@ set_progress_str() {
|
||||
|
||||
echo -e "$percentage_str"
|
||||
|
||||
info "Progressing ($percentage%): $progress_bar_text"
|
||||
if [[ -z $nolog ]]; then
|
||||
info "Progressing ($percentage%): $progress_bar_text"
|
||||
|
||||
printf '%s\n' \
|
||||
'----'\
|
||||
"$percentage% - ${progress_bar_text^^}"\
|
||||
"----" >> "$setup_log" 2>&1
|
||||
# printf '%s\n' \
|
||||
# '----'\
|
||||
# "$percentage% - ${progress_bar_text^^}"\
|
||||
# "----" >> "$setup_log" 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
set_ssh_cmds() {
|
||||
|
||||
100
setup/so-setup
100
setup/so-setup
@@ -27,6 +27,8 @@ original_args=("$@")
|
||||
|
||||
cd "$(dirname "$0")" || exit 255
|
||||
|
||||
echo "Getting started..."
|
||||
|
||||
# Source the generic function libraries that are also used by the product after
|
||||
# setup. These functions are intended to be reusable outside of the setup process.
|
||||
source ../salt/common/tools/sbin/so-common
|
||||
@@ -93,12 +95,23 @@ if ! [ -f $install_opt_file ]; then
|
||||
analyze_system
|
||||
fi
|
||||
|
||||
# Set up handler for setup to exit early (use `kill -SIGUSR1 "$setup_proc"; exit 1` in child scripts)
|
||||
trap 'catch $LINENO' SIGUSR1
|
||||
setup_proc="$$"
|
||||
catch() {
|
||||
info "Fatal error occurred at $1 in so-setup, failing setup."
|
||||
grep --color=never "ERROR" "$setup_log" > "$error_log"
|
||||
whiptail_setup_failed
|
||||
exit 1
|
||||
}
|
||||
|
||||
automated=no
|
||||
function progress() {
|
||||
local title='Security Onion Install'
|
||||
progress() {
|
||||
local title='Security Onion Setup'
|
||||
local msg=${1:-'Please wait while installing...'}
|
||||
|
||||
if [ $automated == no ]; then
|
||||
whiptail --title "$title" --gauge 'Please wait while installing...' 6 60 0 # append to text
|
||||
whiptail --title "$title" --gauge "$msg" 6 70 0 # append to text
|
||||
else
|
||||
cat >> $setup_log 2>&1
|
||||
fi
|
||||
@@ -154,12 +167,9 @@ set_ssh_cmds $automated
|
||||
local_sbin="$(pwd)/../salt/common/tools/sbin"
|
||||
export PATH=$PATH:$local_sbin
|
||||
|
||||
installer_prereq_packages && detect_cloud
|
||||
set_network_dev_status_list
|
||||
set_palette >> $setup_log 2>&1
|
||||
|
||||
if [ "$OS" == ubuntu ]; then
|
||||
update-alternatives --set newt-palette /etc/newt/palette.original >> $setup_log 2>&1
|
||||
fi
|
||||
|
||||
# Kernel messages can overwrite whiptail screen #812
|
||||
# https://github.com/Security-Onion-Solutions/securityonion/issues/812
|
||||
@@ -192,19 +202,24 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
if [[ $setup_type == 'iso' ]] && [ "$automated" == no ]; then
|
||||
whiptail_first_menu_iso
|
||||
if [[ $option == "CONFIGURENETWORK" ]]; then
|
||||
collect_hostname
|
||||
network_init_whiptail
|
||||
whiptail_management_interface_setup
|
||||
network_init
|
||||
printf '%s\n' \
|
||||
"MNIC=$MNIC" \
|
||||
"HOSTNAME=$HOSTNAME" > "$net_init_file"
|
||||
set_main_ip >> $setup_log 2>&1
|
||||
compare_main_nic_ip
|
||||
reset_proxy
|
||||
collect_proxy
|
||||
[[ -n "$so_proxy" ]] && set_proxy >> $setup_log 2>&1
|
||||
whiptail_net_setup_complete
|
||||
else
|
||||
whiptail_install_type
|
||||
true
|
||||
fi
|
||||
else
|
||||
whiptail_install_type
|
||||
fi
|
||||
whiptail_install_type
|
||||
else
|
||||
source $install_opt_file
|
||||
fi
|
||||
@@ -257,6 +272,10 @@ if [[ ( $is_manager || $is_import ) && $is_iso ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $is_manager || $is_import ]]; then
|
||||
check_elastic_license
|
||||
fi
|
||||
|
||||
if ! [[ -f $install_opt_file ]]; then
|
||||
if [[ $is_manager && $is_sensor ]]; then
|
||||
check_requirements "standalone"
|
||||
@@ -273,25 +292,31 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
[[ -f $net_init_file ]] && whiptail_net_reinit && reinit_networking=true
|
||||
|
||||
if [[ $reinit_networking ]] || ! [[ -f $net_init_file ]]; then
|
||||
collect_hostname
|
||||
network_init_whiptail
|
||||
else
|
||||
source "$net_init_file"
|
||||
fi
|
||||
|
||||
if [[ $reinit_networking ]] || ! [[ -f $net_init_file ]]; then
|
||||
network_init
|
||||
fi
|
||||
|
||||
set_main_ip >> $setup_log 2>&1
|
||||
compare_main_nic_ip
|
||||
|
||||
if [[ $is_minion ]]; then
|
||||
collect_mngr_hostname
|
||||
fi
|
||||
|
||||
if [[ $is_minion ]] || [[ $reinit_networking ]] || [[ $is_iso ]] && ! [[ -f $net_init_file ]]; then
|
||||
whiptail_management_interface_setup
|
||||
reset_proxy
|
||||
if [[ -z $is_airgap ]]; then
|
||||
collect_proxy
|
||||
[[ -n "$so_proxy" ]] && set_proxy >> $setup_log 2>&1
|
||||
fi
|
||||
|
||||
if [[ $reinit_networking ]] || ! [[ -f $net_init_file ]]; then
|
||||
network_init
|
||||
fi
|
||||
|
||||
if [[ -n "$TURBO" ]]; then
|
||||
use_turbo_proxy
|
||||
if [[ $is_minion ]] || [[ $reinit_networking ]] || [[ $is_iso ]] && ! [[ -f $net_init_file ]]; then
|
||||
whiptail_management_interface_setup
|
||||
fi
|
||||
|
||||
if [[ $is_minion ]]; then
|
||||
@@ -310,6 +335,7 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
"HOSTNAME=$HOSTNAME" \
|
||||
"MSRV=$MSRV" \
|
||||
"MSRVIP=$MSRVIP" > "$install_opt_file"
|
||||
[[ -n $so_proxy ]] && echo "so_proxy=$so_proxy" >> "$install_opt_file"
|
||||
download_repo_tarball
|
||||
exec bash /root/manager_setup/securityonion/setup/so-setup "${original_args[@]}"
|
||||
fi
|
||||
@@ -323,6 +349,22 @@ else
|
||||
rm -rf $install_opt_file >> "$setup_log" 2>&1
|
||||
fi
|
||||
|
||||
percentage=0
|
||||
{
|
||||
installer_progress_loop & # Run progress bar to 98 in ~8 minutes while waiting for package installs
|
||||
progress_bg_proc=$!
|
||||
installer_prereq_packages
|
||||
install_success=$?
|
||||
kill -9 "$progress_bg_proc"
|
||||
wait "$progress_bg_proc" &> /dev/null # Kill just sends signal, redirect output of wait to catch stdout
|
||||
if [[ $install_success -gt 0 ]]; then
|
||||
echo "Could not install packages required for setup, exiting now." >> "$setup_log" 2>&1
|
||||
kill -SIGUSR1 "$setup_proc"; exit 1
|
||||
fi
|
||||
} | progress '...'
|
||||
|
||||
detect_cloud
|
||||
|
||||
short_name=$(echo "$HOSTNAME" | awk -F. '{print $1}')
|
||||
|
||||
MINION_ID=$(echo "${short_name}_${install_type}" | tr '[:upper:]' '[:lower:]')
|
||||
@@ -336,14 +378,14 @@ minion_type=$(get_minion_type)
|
||||
set_default_log_size >> $setup_log 2>&1
|
||||
|
||||
if [[ $is_helix ]]; then
|
||||
RULESETUP=${RULESETUP:-ETOPEN}
|
||||
RULESETUP=${RULESETUP:-ETOPEN}
|
||||
NSMSETUP=${NSMSETUP:-BASIC}
|
||||
HNSENSOR=${HNSENSOR:-inherit}
|
||||
MANAGERUPDATES=${MANAGERUPDATES:-0}
|
||||
fi
|
||||
|
||||
if [[ $is_helix || ( $is_manager && $is_node ) ]]; then
|
||||
RULESETUP=${RULESETUP:-ETOPEN}
|
||||
RULESETUP=${RULESETUP:-ETOPEN}
|
||||
NSMSETUP=${NSMSETUP:-BASIC}
|
||||
fi
|
||||
|
||||
@@ -363,7 +405,7 @@ fi
|
||||
if [[ $is_import ]]; then
|
||||
PATCHSCHEDULENAME=${PATCHSCHEDULENAME:-auto}
|
||||
MTU=${MTU:-1500}
|
||||
RULESETUP=${RULESETUP:-ETOPEN}
|
||||
RULESETUP=${RULESETUP:-ETOPEN}
|
||||
NSMSETUP=${NSMSETUP:-BASIC}
|
||||
HNSENSOR=${HNSENSOR:-inherit}
|
||||
MANAGERUPDATES=${MANAGERUPDATES:-0}
|
||||
@@ -527,21 +569,10 @@ whiptail_make_changes
|
||||
# From here on changes will be made.
|
||||
echo "1" > /root/accept_changes
|
||||
|
||||
# Set up handler for setup to exit early (use `kill -SIGUSR1 "$(ps --pid $$ -oppid=)"; exit 1` in child scripts)
|
||||
trap 'catch $LINENO' SIGUSR1
|
||||
|
||||
catch() {
|
||||
info "Fatal error occurred at $1 in so-setup, failing setup."
|
||||
grep --color=never "ERROR" "$setup_log" > "$error_log"
|
||||
whiptail_setup_failed
|
||||
exit
|
||||
}
|
||||
|
||||
# This block sets REDIRECTIT which is used by a function outside the below subshell
|
||||
set_main_ip >> $setup_log 2>&1
|
||||
compare_main_nic_ip
|
||||
set_redirect >> $setup_log 2>&1
|
||||
|
||||
|
||||
# Begin install
|
||||
{
|
||||
# Set initial percentage to 0
|
||||
@@ -768,6 +799,9 @@ set_redirect >> $setup_log 2>&1
|
||||
|
||||
set_progress_str 70 "$(print_salt_state_apply 'kibana')"
|
||||
salt-call state.apply -l info kibana >> $setup_log 2>&1
|
||||
|
||||
set_progress_str 70 "Setting up default Space in Kibana"
|
||||
so-kibana-space-defaults >> $setup_log 2>&1
|
||||
fi
|
||||
|
||||
if [[ "$PLAYBOOK" = 1 ]]; then
|
||||
|
||||
@@ -215,7 +215,7 @@ whiptail_create_web_user() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
WEBUSER=$(whiptail --title "Security Onion Install" --inputbox \
|
||||
"Please enter an email address to create an administrator account for the web interface: \nThis will also be used for TheHive, Cortex, and Fleet." 10 60 "$1" 3>&1 1>&2 2>&3)
|
||||
"Please enter an email address to create an administrator account for the web interface.\n\nThis will also be used for TheHive, Cortex, and Fleet." 12 60 "$1" 3>&1 1>&2 2>&3)
|
||||
|
||||
local exitstatus=$?
|
||||
whiptail_check_exitstatus $exitstatus
|
||||
@@ -376,7 +376,7 @@ whiptail_dockernet_check(){
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
whiptail --title "Security Onion Setup" --yesno \
|
||||
"Do you want to keep the default Docker IP range? \n \n(Choose yes if you don't know what this means)" 10 75
|
||||
"Do you want to keep the default Docker IP range?\n\nIf you are unsure, please accept the default option of Yes." 10 75
|
||||
|
||||
}
|
||||
|
||||
@@ -588,8 +588,21 @@ whiptail_invalid_input() { # TODO: This should accept a list of arguments to spe
|
||||
|
||||
}
|
||||
|
||||
whiptail_invalid_proxy() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
local message
|
||||
read -r -d '' message <<- EOM
|
||||
Could not reach test url using proxy ${proxy_addr}.
|
||||
|
||||
Error was: ${proxy_test_err}
|
||||
EOM
|
||||
|
||||
whiptail --title "Security Onion Setup" --yesno "$message" --yes-button "Enter Again" --no-button "Skip" 11 60
|
||||
}
|
||||
|
||||
whiptail_invalid_string() {
|
||||
[ -n "$TESTING" ] && return
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
whiptail --title "Security Onion Setup" --msgbox "Invalid input, please try again.\n\nThe $1 cannot contain spaces." 9 45
|
||||
|
||||
@@ -1129,7 +1142,7 @@ whiptail_patch_schedule() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
patch_schedule=$(whiptail --title "Security Onion Setup" --radiolist \
|
||||
"Choose OS patch schedule: \nThis will NOT update Security Onion related tools such as Zeek, Elasticsearch, Kibana, SaltStack, etc." 15 75 5 \
|
||||
"Choose OS patch schedule.\n\nThis schedule will update the operating system packages but will NOT update Security Onion related tools such as Zeek, Elasticsearch, Kibana, SaltStack, etc." 20 75 5 \
|
||||
"Automatic" "Updates installed every 8 hours if available" ON \
|
||||
"Manual" "Updates will be installed manually" OFF \
|
||||
"Import Schedule" "Import named schedule on following screen" OFF \
|
||||
@@ -1216,6 +1229,58 @@ whiptail_patch_schedule_select_hours() {
|
||||
|
||||
}
|
||||
|
||||
whiptail_proxy_ask() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
whiptail --title "Security Onion Setup" --yesno "Do you want to set a proxy server for this installation?" 7 60 --defaultno
|
||||
}
|
||||
|
||||
whiptail_proxy_addr() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
local message
|
||||
read -r -d '' message <<- EOM
|
||||
Please input the proxy server you wish to use, including the URL prefix (ex: https://your.proxy.com:1234).
|
||||
|
||||
If your proxy requires a username and password do not include them in your input. Setup will ask for those values next.
|
||||
EOM
|
||||
|
||||
proxy_addr=$(whiptail --title "Security Onion Setup" --inputbox "$message" 13 60 "$1" 3>&1 1>&2 2>&3)
|
||||
|
||||
local exitstatus=$?
|
||||
whiptail_check_exitstatus $exitstatus
|
||||
}
|
||||
|
||||
whiptail_proxy_auth_ask() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
whiptail --title "Security Onion Setup" --yesno "Does your proxy require authentication?" 7 60
|
||||
}
|
||||
|
||||
whiptail_proxy_auth_user() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
proxy_user=$(whiptail --title "Security Onion Setup" --inputbox "Please input the proxy user:" 8 60 "$1" 3>&1 1>&2 2>&3)
|
||||
|
||||
local exitstatus=$?
|
||||
whiptail_check_exitstatus $exitstatus
|
||||
}
|
||||
|
||||
whiptail_proxy_auth_pass() {
|
||||
local arg=$1
|
||||
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
if [[ $arg != 'confirm' ]]; then
|
||||
proxy_pass=$(whiptail --title "Security Onion Setup" --passwordbox "Please input the proxy password:" 8 60 3>&1 1>&2 2>&3)
|
||||
else
|
||||
proxy_pass_confirm=$(whiptail --title "Security Onion Setup" --passwordbox "Please confirm the proxy password:" 8 60 3>&1 1>&2 2>&3)
|
||||
fi
|
||||
|
||||
local exitstatus=$?
|
||||
whiptail_check_exitstatus $exitstatus
|
||||
}
|
||||
|
||||
whiptail_requirements_error() {
|
||||
|
||||
local requirement_needed=$1
|
||||
@@ -1318,8 +1383,8 @@ whiptail_set_redirect() {
|
||||
[ -n "$TESTING" ] && return
|
||||
|
||||
REDIRECTINFO=$(whiptail --title "Security Onion Setup" --radiolist \
|
||||
"Choose the access method for the web interface: \nNOTE: For security reasons, we use strict cookie enforcement" 20 75 4 \
|
||||
"IP" "Use IP to access the web interface" ON \
|
||||
"How would you like to access the web interface?\n\nSecurity Onion uses strict cookie enforcement, so whatever you choose here will be the only way that you can access the web interface.\n\nIf you choose something other than IP address, then you'll need to ensure that you can resolve the name via DNS or hosts entry. If you are unsure, please select IP." 20 75 4 \
|
||||
"IP" "Use IP address to access the web interface" ON \
|
||||
"HOSTNAME" "Use hostname to access the web interface" OFF \
|
||||
"OTHER" "Use a different name like a FQDN or Load Balancer" OFF 3>&1 1>&2 2>&3 )
|
||||
local exitstatus=$?
|
||||
|
||||
Reference in New Issue
Block a user