From b7a977184d29317fab2f9a1c404e1e803c7a4e90 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Wed, 4 Mar 2020 14:30:41 -0500 Subject: [PATCH 1/9] Fix Salt Repo --- setup/so-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 124db4f9b..95495e2fd 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1061,8 +1061,8 @@ EOF # Install the repo for salt wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest xenial main" > /etc/apt/sources.list.d/saltstack.list - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 xenial main" > /etc/apt/sources.list.d/saltstack2019.list + echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list + echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list # Lets get the docker repo added curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - From ef47a87715b82cedd7e98ae2e4f3955362f0db24 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Wed, 4 Mar 2020 14:33:31 -0500 Subject: [PATCH 2/9] Fix Salt Repo --- setup/so-functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/so-functions b/setup/so-functions index 95495e2fd..8dc0bd169 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1094,7 +1094,7 @@ EOF echo "Using apt-key add to add SALTSTACK-GPG-KEY.pub and GPG-KEY-WAZUH" apt-key add $TMP/gpg/SALTSTACK-GPG-KEY.pub apt-key add $TMP/gpg/GPG-KEY-WAZUH - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest xenial main" > /etc/apt/sources.list.d/saltstack.list + echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list echo "deb https://packages.wazuh.com/3.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list # Initialize the new repos apt-get update >> $SETUPLOG 2>&1 From dd47b5825d99283b245c0e5c363abfd62893e175 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Wed, 4 Mar 2020 15:42:15 -0500 Subject: [PATCH 3/9] Fix Salt Repo for Python 3 --- setup/so-functions | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 8dc0bd169..4a946aea2 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1058,12 +1058,19 @@ EOF # Nasty hack but required for now if [ $INSTALLTYPE == 'MASTERONLY' ] || [ $INSTALLTYPE == 'EVALMODE' ] || [ $INSTALLTYPE == 'MASTERSEARCH' ]; then - # Install the repo for salt - wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - - wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list - + if [ $OSVER != "xenial" ]; then + # Install the repo for salt + wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - + wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - + echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list + echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list + else + # Install the repo for salt + wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/3000/SALTSTACK-GPG-KEY.pub | apt-key add - + wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - + echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list + echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list + fi # Lets get the docker repo added curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" From cb8493551dcda7c7af3b6087d3f408f24724322a Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Wed, 4 Mar 2020 16:10:32 -0500 Subject: [PATCH 4/9] Fix Salt Repo for Python 3 --- setup/so-functions | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 4a946aea2..a965b57d4 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1059,15 +1059,15 @@ EOF if [ $INSTALLTYPE == 'MASTERONLY' ] || [ $INSTALLTYPE == 'EVALMODE' ] || [ $INSTALLTYPE == 'MASTERSEARCH' ]; then if [ $OSVER != "xenial" ]; then - # Install the repo for salt - wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - - wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - + # Install the repo for salt py3 edition + wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/3000/SALTSTACK-GPG-KEY.pub | apt-key add - + wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list else # Install the repo for salt - wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/3000/SALTSTACK-GPG-KEY.pub | apt-key add - - wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - + wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - + wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list fi From 4e9f1b1a7b3985ac557144eebda910d1dc4487a9 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Wed, 4 Mar 2020 17:01:48 -0500 Subject: [PATCH 5/9] Make Ubuntu 18 defautl to python 3 --- setup/so-functions | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup/so-functions b/setup/so-functions index a965b57d4..6f1f79b86 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1049,6 +1049,12 @@ EOF ADDUSER=useradd DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade + if [ $OSVER != "xenial" ]; then + + # Switch to Python 3 as default is this is not xenial + update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10 + + fi # Add the pre-requisites for installing docker-ce apt-get -y install ca-certificates curl software-properties-common apt-transport-https openssl jq >> $SETUPLOG 2>&1 From 746a1d1c3a1298500d0f6280cc5c9bee3f572275 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Thu, 5 Mar 2020 13:53:27 -0500 Subject: [PATCH 6/9] More Ubuntu 18 Python --- setup/so-functions | 52 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 6f1f79b86..8f17d810d 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -423,7 +423,11 @@ docker_install() { if [ $INSTALLTYPE == 'MASTERONLY' ] || [ $INSTALLTYPE == 'EVALMODE' ]; then apt-get update >> $SETUPLOG 2>&1 - apt-get -y install docker-ce python3-docker >> $SETUPLOG 2>&1 + if [ $OSVER != "xenial" ]; then + apt-get -y install docker-ce python3-docker >> $SETUPLOG 2>&1 + else + apt-get -y install docker-ce python-docker >> $SETUPLOG 2>&1 + fi docker_registry >> $SETUPLOG 2>&1 echo "Restarting Docker" >> $SETUPLOG 2>&1 systemctl restart docker >> $SETUPLOG 2>&1 @@ -431,7 +435,11 @@ docker_install() { apt-key add $TMP/gpg/docker.pub >> $SETUPLOG 2>&1 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" >> $SETUPLOG 2>&1 apt-get update >> $SETUPLOG 2>&1 - apt-get -y install docker-ce python3-docker >> $SETUPLOG 2>&1 + if [ $OSVER != "xenial" ]; then + apt-get -y install docker-ce python3-docker >> $SETUPLOG 2>&1 + else + apt-get -y install docker-ce python-docker >> $SETUPLOG 2>&1 + fi docker_registry >> $SETUPLOG 2>&1 echo "Restarting Docker" >> $SETUPLOG 2>&1 systemctl restart docker >> $SETUPLOG 2>&1 @@ -651,8 +659,13 @@ install_master() { #wget --inet4-only -O /opt/so/gpg/GPG-KEY-WAZUH https://packages.wazuh.com/key/GPG-KEY-WAZUH else - apt-get install -y salt-common=2019.2.3+ds-1 salt-master=2019.2.3+ds-1 salt-minion=2019.2.3+ds-1 libssl-dev python-m2crypto - apt-mark hold salt-common salt-master salt-minion + if [ $OSVER != "xenial" ]; then + apt-get install -y salt-common=2019.2.3+ds-1 salt-master=2019.2.3+ds-1 salt-minion=2019.2.3+ds-1 libssl-dev python-m2crypto + apt-mark hold salt-common salt-master salt-minion + else + apt-get install -y salt-common=2019.2.3+ds-1 salt-master=2019.2.3+ds-1 salt-minion=2019.2.3+ds-1 libssl-dev python-m2crypto + apt-mark hold salt-common salt-master salt-minion + fi fi copy_master_config @@ -1050,7 +1063,7 @@ EOF DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade if [ $OSVER != "xenial" ]; then - + # Switch to Python 3 as default is this is not xenial update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10 @@ -1094,10 +1107,14 @@ EOF # Initialize the new repos apt-get update >> $SETUPLOG 2>&1 - # Need to add python packages here - apt-get -y install salt-minion=2019.2.3+ds-1 salt-common=2019.2.3+ds-1 python-dateutil python-m2crypto >> $SETUPLOG 2>&1 - apt-mark hold salt-minion salt-common - + if [ $OSVER != "xenial" ]; then + apt-get -y install salt-minion=2019.2.3+ds-1 salt-common=2019.2.3+ds-1 python3-dateutil python3-m2crypto >> $SETUPLOG 2>&1 + apt-mark hold salt-minion salt-common + else + # Need to add python packages here + apt-get -y install salt-minion=2019.2.3+ds-1 salt-common=2019.2.3+ds-1 python-dateutil python-m2crypto >> $SETUPLOG 2>&1 + apt-mark hold salt-minion salt-common + fi else # Copy down the gpg keys and install them from the master @@ -1111,9 +1128,14 @@ EOF echo "deb https://packages.wazuh.com/3.x/apt/ stable main" | tee /etc/apt/sources.list.d/wazuh.list # Initialize the new repos apt-get update >> $SETUPLOG 2>&1 - apt-get -y install salt-minion=2019.2.3+ds-1 salt-common=2019.2.3+ds-1 python-dateutil python-m2crypto >> $SETUPLOG 2>&1 - apt-mark hold salt-minion salt-common - + if [ $OSVER != "xenial" ]; then + apt-get -y install salt-minion=2019.2.3+ds-1 salt-common=2019.2.3+ds-1 python3-dateutil python3-m2crypto >> $SETUPLOG 2>&1 + apt-mark hold salt-minion salt-common + else + # Need to add python packages here + apt-get -y install salt-minion=2019.2.3+ds-1 salt-common=2019.2.3+ds-1 python-dateutil python-m2crypto >> $SETUPLOG 2>&1 + apt-mark hold salt-minion salt-common + fi fi fi @@ -1180,7 +1202,11 @@ salt_install_mysql_deps() { if [ $OS == 'centos' ]; then yum -y install mariadb-devel elif [ $OS == 'ubuntu' ]; then - apt-get -y install python-mysqldb + if [ $OSVER != "xenial" ]; then + apt-get -y install python3-mysql >> $SETUPLOG 2>&1 + else + apt-get -y install python-mysqldb + fi fi } From 868e7bd807ffbedafbea4fdda326b1b7e8ce6d3b Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Mon, 9 Mar 2020 09:52:03 -0400 Subject: [PATCH 7/9] Fix the repo definition --- setup/so-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 8f17d810d..6026510fb 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1081,8 +1081,8 @@ EOF # Install the repo for salt py3 edition wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/3000/SALTSTACK-GPG-KEY.pub | apt-key add - wget --inet4-only -O - https://repo.saltstack.com/py3/ubuntu/$UVER/amd64/2019.2/SALTSTACK-GPG-KEY.pub | apt-key add - - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list - echo "deb http://repo.saltstack.com/apt/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list + echo "deb http://repo.saltstack.com/py3/ubuntu/$UVER/amd64/latest $OSVER main" > /etc/apt/sources.list.d/saltstack.list + echo "deb http://repo.saltstack.com/py3/ubuntu/$UVER/amd64/2019.2 $OSVER main" > /etc/apt/sources.list.d/saltstack2019.list else # Install the repo for salt wget --inet4-only -O - https://repo.saltstack.com/apt/ubuntu/$UVER/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - From f74bc4cfa0077a9629a721b59adb87da69ac6565 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Tue, 10 Mar 2020 15:56:05 -0400 Subject: [PATCH 8/9] Fix IP Calculation --- setup/so-functions | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/setup/so-functions b/setup/so-functions index 6026510fb..77d0bf236 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -611,7 +611,14 @@ get_filesystem_root(){ get_main_ip() { # Get the main IP address the box is using - MAINIP=$(ip route get 1 | awk '{print $NF;exit}') + + # Add some logic because Bubntu 18.04 like to be different + if [ $OSVER == 'bionic' ]; then + MAINIP=$(ip route get 1 | awk '{print $7;exit}') + else + MAINIP=$(ip route get 1 | awk '{print $NF;exit}') + fi + MAININT=$(ip route get 1 | awk '{print $5;exit}') } From 16d549ce031d2ef40071e0e000d466c6d3e0e7cd Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Wed, 11 Mar 2020 10:58:54 -0400 Subject: [PATCH 9/9] Fix mysql --- setup/so-functions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 77d0bf236..02900b999 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -618,7 +618,7 @@ get_main_ip() { else MAINIP=$(ip route get 1 | awk '{print $NF;exit}') fi - + MAININT=$(ip route get 1 | awk '{print $5;exit}') } @@ -1210,7 +1210,7 @@ salt_install_mysql_deps() { yum -y install mariadb-devel elif [ $OS == 'ubuntu' ]; then if [ $OSVER != "xenial" ]; then - apt-get -y install python3-mysql >> $SETUPLOG 2>&1 + apt-get -y install python3-mysqldb >> $SETUPLOG 2>&1 else apt-get -y install python-mysqldb fi