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
HOTFIXDIR=/tmp/sohotfixapply
UPDATE_DIR=/tmp/sohotfixapply
if [ -z "$1" ]; then
echo "No tarball given. Please provide the filename so I can run the hotfix"
@@ -29,13 +29,13 @@ else
exit 1
else
echo "Determining if we need to apply this hotfix"
rm -rf $HOTFIXDIR
mkdir -p $HOTFIXDIR
tar xvf $1 -C $HOTFIXDIR
rm -rf $UPDATE_DIR
mkdir -p $UPDATE_DIR
tar xvf $1 -C $UPDATE_DIR
# Compare some versions
NEWVERSION=$(cat $HOTFIXDIR/VERSION)
HOTFIXVERSION=$(cat $HOTFIXDIR/HOTFIX)
NEWVERSION=$(cat $UPDATE_DIR/VERSION)
HOTFIXVERSION=$(cat $UPDATE_DIR/HOTFIX)
CURRENTHOTFIX=$(cat /etc/sohotfix)
INSTALLEDVERSION=$(cat /etc/soversion)
@@ -43,24 +43,21 @@ else
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
rm -rf $UPDATE_DIR
exit 1
else
echo "We need to apply a hotfix"
cd $HOTFIXDIR
DEFAULT_SALT_DIR=/opt/so/saltstack/default
copy_new_files
echo $HOTFIXVERSION > /etc/sohotfix
salt-call state.highstate -l info queue=True
echo "The Hotfix $HOTFIXVERSION has been applied"
# Clean up
cd /tmp
rm -rf $HOTFIXDIR
rm -rf $UPDATE_DIR
exit 0
fi
else
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

View File

@@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
DEFAULT_SALT_DIR=/opt/so/saltstack/default
# Check for prerequisites
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run using sudo!"
@@ -124,10 +126,12 @@ check_elastic_license() {
copy_new_files() {
# Copy new files over to the salt dir
cd $UPDATE_DIR
rsync -a salt $DEFAULT_SALT_DIR/
rsync -a pillar $DEFAULT_SALT_DIR/
chown -R socore:socore $DEFAULT_SALT_DIR/
chmod 755 $DEFAULT_SALT_DIR/pillar/firewall/addfirewall.sh
cd /tmp
}
disable_fastestmirror() {

View File

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