From 296c1c5a3c64e66e3fc49a032cc0e6967255e4a7 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Mon, 3 May 2021 14:30:53 -0400 Subject: [PATCH] Adding airgap hotfix --- salt/common/tools/sbin/so-airgap-hotfixapply | 67 +++++++++++++++++++ .../tools/sbin/so-airgap-hotfixdownload | 33 +++++++++ 2 files changed, 100 insertions(+) create mode 100644 salt/common/tools/sbin/so-airgap-hotfixapply create mode 100644 salt/common/tools/sbin/so-airgap-hotfixdownload diff --git a/salt/common/tools/sbin/so-airgap-hotfixapply b/salt/common/tools/sbin/so-airgap-hotfixapply new file mode 100644 index 000000000..cb6bf6451 --- /dev/null +++ b/salt/common/tools/sbin/so-airgap-hotfixapply @@ -0,0 +1,67 @@ +#!/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 . + +. /usr/sbin/so-common + +HOTFIXDIR=/tmp/sohotfixapply + +if [ -z "$1" ]; then + echo "No tarball given. Please provide the filename so I can run the hotfix" + echo "so-airgap-hotfixapply /path/to/sohotfix.tar" + exit 1 +else + if [ ! -f "$1" ]; then + echo "Unable to find $1. Make sure your path is correct and retry." + exit 1 + else + echo "Determining if we need to apply this hotfix" + rm -rf $HOTFIXDIR + mkdir -p $HOTFIXDIR + tar xvf $1 -C $HOTFIXDIR + + # Compare some versions + NEWVERSION=$(cat $HOTFIXDIR/VERSION) + HOTFIXVERSION=$(cat $HOTFIXDIR/HOTFIX) + CURRENTHOTFIX=$(cat /etc/sohotfix) + INSTALLEDVERSION=$(cat /etc/soversion) + + if [ "$INSTALLEDVERSION" == "$NEWVERSION" ]; then + echo "Checking to see if there are hotfixes needed" + if [ "$HOTFIXVERSION" == "$CURRENTHOTFIX" ]; then + echo "You are already running the latest version of Security Onion." + rm -rf $HOTFIXDIR + exit 1 + else + echo "We need to apply a hotfix" + rsync -a $HOTFIXDIR/salt /opt/so/saltstack/default/ + rsync -a $HOTFIXDIR/pillar /opt/so/saltstack/default/ + chown -R socore:socore /opt/so/saltstack/default/ + chmod 755 /opt/so/saltstack/default/pillar/firewall/addfirewall.sh + echo $HOTFIXVERSION > /etc/sohotfix + salt-call state.highstate -l info queue=True + echo "The Hotfix $HOTFIXVERSION has been applied" + # Clean up + rm -rf $HOTFIXDIR + exit 0 + fi + else + echo "This hotfix is not compatible with your current version. Download the latest ISO and run soup" + rm -rf $HOTFIXDIR + fi + + fi +fi \ No newline at end of file diff --git a/salt/common/tools/sbin/so-airgap-hotfixdownload b/salt/common/tools/sbin/so-airgap-hotfixdownload new file mode 100644 index 000000000..422fa5f1f --- /dev/null +++ b/salt/common/tools/sbin/so-airgap-hotfixdownload @@ -0,0 +1,33 @@ +#!/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 . + +# Get the latest code +rm -rf /tmp/sohotfix +mkdir -p /tmp/sohotfix +cd /tmp/sohotfix +git clone https://github.com/Security-Onion-Solutions/securityonion +if [ ! -d "/tmp/sohotfix/securityonion" ]; then + echo "I was unable to get the latest code. Check your internet and try again." + exit 1 +else + echo "Looks like we have the code lets create the tarball." + cd /tmp/sohotfix/securityonion + tar cvf /tmp/sohotfix/sohotfix.tar HOTFIX VERSION salt pillar + echo "" + echo "Copy /tmp/sohotfix/sohotfix.tar to portable media and then copy it to your airgap manager." + exit 0 +fi \ No newline at end of file