mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 18:22:47 +01:00
Support multiple command line options for setup, along with dynamic values per option
This commit is contained in:
@@ -954,59 +954,6 @@ 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" | tr -d '"' | awk -F'--turbo=' '{print $2}')
|
|
||||||
proxy_url="http://$proxy"
|
|
||||||
TURBO="$proxy_url"
|
|
||||||
;;
|
|
||||||
--proxy=*)
|
|
||||||
local proxy
|
|
||||||
proxy=$(echo "$1" | tr -d '"' | awk -F'--proxy=' '{print $2}')
|
|
||||||
|
|
||||||
local proxy_protocol
|
|
||||||
proxy_protocol=$(echo "$proxy" | awk 'match($0, /http|https/) { print substr($0, RSTART, RLENGTH) }')
|
|
||||||
|
|
||||||
if [[ ! $proxy_protocol =~ ^(http|https)$ ]]; then
|
|
||||||
echo "Invalid proxy protocol"
|
|
||||||
echo "Ignoring proxy"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $2 == --proxy-user=* && $3 == --proxy-pass=* ]]; then
|
|
||||||
local proxy_user
|
|
||||||
local proxy_password
|
|
||||||
proxy_user=$(echo "$2" | tr -d '"' | awk -F'--proxy-user=' '{print $2}')
|
|
||||||
proxy_password=$(echo "$3" | tr -d '"' | awk -F'--proxy-pass=' '{print $2}')
|
|
||||||
|
|
||||||
local proxy_addr
|
|
||||||
proxy_addr=$(echo "$proxy" | awk -F'http\:\/\/|https\:\/\/' '{print $2}')
|
|
||||||
|
|
||||||
export http_proxy="${proxy_protocol}://${proxy_user}:${proxy_password}@${proxy_addr}"
|
|
||||||
|
|
||||||
elif [[ (-z $2 || -z $3) && (-n $2 || -n $3) || ( -n $2 && -n $3 && ($2 != --proxy-user=* || $3 != --proxy-pass=*) ) ]]; then
|
|
||||||
echo "Invalid options passed for proxy. Order is --proxy-user=<user> --proxy-pass=<password>"
|
|
||||||
echo "Ignoring proxy"
|
|
||||||
return
|
|
||||||
|
|
||||||
else
|
|
||||||
export http_proxy="$proxy"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export {https,ftp,rsync,all}_proxy="$http_proxy"
|
|
||||||
;;
|
|
||||||
"--allow-analyst"|"--allow=a")
|
|
||||||
export allow='a'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [[ $1 = --* ]]; then
|
|
||||||
echo "Invalid option"
|
|
||||||
fi
|
|
||||||
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
|
||||||
|
|||||||
@@ -21,15 +21,31 @@ source ./so-common-functions
|
|||||||
source ./so-whiptail
|
source ./so-whiptail
|
||||||
source ./so-variables
|
source ./so-variables
|
||||||
|
|
||||||
|
# Parse command line arguments
|
||||||
setup_type=$1
|
setup_type=$1
|
||||||
export setup_type
|
|
||||||
|
|
||||||
automation=$2
|
automation=$2
|
||||||
|
|
||||||
automated=no
|
while [[ $# -gt 0 ]]; do
|
||||||
|
arg="$1"
|
||||||
|
shift
|
||||||
|
case "$arg" in
|
||||||
|
"--turbo="* )
|
||||||
|
export TURBO="http://${arg#*=}";;
|
||||||
|
"--proxy="* )
|
||||||
|
export {http,https,ftp,rsync,all}_proxy="${arg#*=}";;
|
||||||
|
"--allow="* )
|
||||||
|
export allow="${arg#*=}";;
|
||||||
|
* )
|
||||||
|
if [[ "$arg" == "--"* ]]; then
|
||||||
|
echo "Invalid option"
|
||||||
|
fi
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Begin Installation pre-processing
|
||||||
echo "---- Starting setup at $(date -u) ----" >> $setup_log 2>&1
|
echo "---- Starting setup at $(date -u) ----" >> $setup_log 2>&1
|
||||||
|
|
||||||
|
automated=no
|
||||||
function progress() {
|
function progress() {
|
||||||
if [ $automated == no ]; then
|
if [ $automated == no ]; then
|
||||||
whiptail --title "Security Onion Install" --gauge 'Please wait while installing' 6 60 0
|
whiptail --title "Security Onion Install" --gauge 'Please wait while installing' 6 60 0
|
||||||
@@ -43,7 +59,7 @@ if [[ -f automation/$automation && $(basename $automation) == $automation ]]; th
|
|||||||
source automation/$automation
|
source automation/$automation
|
||||||
automated=yes
|
automated=yes
|
||||||
|
|
||||||
echo "Checking network configuration" >> $setup_log 2>&1g
|
echo "Checking network configuration" >> $setup_log 2>&1
|
||||||
ip a >> $setup_log 2>&1
|
ip a >> $setup_log 2>&1
|
||||||
|
|
||||||
attempt=1
|
attempt=1
|
||||||
@@ -78,11 +94,6 @@ export PATH=$PATH:../salt/common/tools/sbin
|
|||||||
|
|
||||||
got_root
|
got_root
|
||||||
|
|
||||||
if [[ $# -gt 1 ]]; then
|
|
||||||
set -- "${@:2}"
|
|
||||||
parse_options "$@" >> $setup_log 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
detect_os
|
detect_os
|
||||||
|
|
||||||
if [ "$OS" == ubuntu ]; then
|
if [ "$OS" == ubuntu ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user