copy_new_files usage consistent across soup and hotfixapply scripts

This commit is contained in:
Jason Ertel
2021-05-03 15:42:24 -04:00
parent a489b369d7
commit 6768e8ddf6
3 changed files with 13 additions and 16 deletions

View File

@@ -17,7 +17,7 @@
. /usr/sbin/so-common . /usr/sbin/so-common
HOTFIXDIR=/tmp/sohotfixapply UPDATE_DIR=/tmp/sohotfixapply
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "No tarball given. Please provide the filename so I can run the hotfix" echo "No tarball given. Please provide the filename so I can run the hotfix"
@@ -29,13 +29,13 @@ else
exit 1 exit 1
else else
echo "Determining if we need to apply this hotfix" echo "Determining if we need to apply this hotfix"
rm -rf $HOTFIXDIR rm -rf $UPDATE_DIR
mkdir -p $HOTFIXDIR mkdir -p $UPDATE_DIR
tar xvf $1 -C $HOTFIXDIR tar xvf $1 -C $UPDATE_DIR
# Compare some versions # Compare some versions
NEWVERSION=$(cat $HOTFIXDIR/VERSION) NEWVERSION=$(cat $UPDATE_DIR/VERSION)
HOTFIXVERSION=$(cat $HOTFIXDIR/HOTFIX) HOTFIXVERSION=$(cat $UPDATE_DIR/HOTFIX)
CURRENTHOTFIX=$(cat /etc/sohotfix) CURRENTHOTFIX=$(cat /etc/sohotfix)
INSTALLEDVERSION=$(cat /etc/soversion) INSTALLEDVERSION=$(cat /etc/soversion)
@@ -43,24 +43,21 @@ else
echo "Checking to see if there are hotfixes needed" echo "Checking to see if there are hotfixes needed"
if [ "$HOTFIXVERSION" == "$CURRENTHOTFIX" ]; then if [ "$HOTFIXVERSION" == "$CURRENTHOTFIX" ]; then
echo "You are already running the latest version of Security Onion." echo "You are already running the latest version of Security Onion."
rm -rf $HOTFIXDIR rm -rf $UPDATE_DIR
exit 1 exit 1
else else
echo "We need to apply a hotfix" echo "We need to apply a hotfix"
cd $HOTFIXDIR
DEFAULT_SALT_DIR=/opt/so/saltstack/default
copy_new_files copy_new_files
echo $HOTFIXVERSION > /etc/sohotfix echo $HOTFIXVERSION > /etc/sohotfix
salt-call state.highstate -l info queue=True salt-call state.highstate -l info queue=True
echo "The Hotfix $HOTFIXVERSION has been applied" echo "The Hotfix $HOTFIXVERSION has been applied"
# Clean up # Clean up
cd /tmp rm -rf $UPDATE_DIR
rm -rf $HOTFIXDIR
exit 0 exit 0
fi fi
else else
echo "This hotfix is not compatible with your current version. Download the latest ISO and run soup" echo "This hotfix is not compatible with your current version. Download the latest ISO and run soup"
rm -rf $HOTFIXDIR rm -rf $UPDATE_DIR
fi fi
fi fi

View File

@@ -15,6 +15,8 @@
# 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/>.
DEFAULT_SALT_DIR=/opt/so/saltstack/default
# Check for prerequisites # Check for prerequisites
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run using sudo!" echo "This script must be run using sudo!"
@@ -124,10 +126,12 @@ check_elastic_license() {
copy_new_files() { copy_new_files() {
# Copy new files over to the salt dir # Copy new files over to the salt dir
cd $UPDATE_DIR
rsync -a salt $DEFAULT_SALT_DIR/ rsync -a salt $DEFAULT_SALT_DIR/
rsync -a pillar $DEFAULT_SALT_DIR/ rsync -a pillar $DEFAULT_SALT_DIR/
chown -R socore:socore $DEFAULT_SALT_DIR/ chown -R socore:socore $DEFAULT_SALT_DIR/
chmod 755 $DEFAULT_SALT_DIR/pillar/firewall/addfirewall.sh chmod 755 $DEFAULT_SALT_DIR/pillar/firewall/addfirewall.sh
cd /tmp
} }
disable_fastestmirror() { disable_fastestmirror() {

View File

@@ -21,7 +21,6 @@ UPDATE_DIR=/tmp/sogh/securityonion
INSTALLEDVERSION=$(cat /etc/soversion) INSTALLEDVERSION=$(cat /etc/soversion)
POSTVERSION=$INSTALLEDVERSION POSTVERSION=$INSTALLEDVERSION
INSTALLEDSALTVERSION=$(salt --versions-report | grep Salt: | awk {'print $2'}) INSTALLEDSALTVERSION=$(salt --versions-report | grep Salt: | awk {'print $2'})
DEFAULT_SALT_DIR=/opt/so/saltstack/default
BATCHSIZE=5 BATCHSIZE=5
SOUP_LOG=/root/soup.log SOUP_LOG=/root/soup.log
WHATWOULDYOUSAYYAHDOHERE=soup WHATWOULDYOUSAYYAHDOHERE=soup
@@ -714,9 +713,7 @@ upgrade_check_salt
if [[ $is_hotfix ]]; then if [[ $is_hotfix ]]; then
echo "Applying $HOTFIXVERSION" echo "Applying $HOTFIXVERSION"
cd $UPDATE_DIR
copy_new_files copy_new_files
cd /tmp
echo "" echo ""
update_version update_version
salt-call state.highstate -l info queue=True salt-call state.highstate -l info queue=True
@@ -787,7 +784,6 @@ else
echo "" echo ""
echo "Copying new Security Onion code from $UPDATE_DIR to $DEFAULT_SALT_DIR." echo "Copying new Security Onion code from $UPDATE_DIR to $DEFAULT_SALT_DIR."
copy_new_files copy_new_files
cd /tmp
echo "" echo ""
update_version update_version