Skip to content

Commit

Permalink
Merge pull request #13003 from Security-Onion-Solutions/localdirs
Browse files Browse the repository at this point in the history
create local directories during soup if needed
  • Loading branch information
m0duspwnens authored May 13, 2024
2 parents 2419066 + 1ef9509 commit 437d002
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
15 changes: 15 additions & 0 deletions salt/common/tools/sbin/so-common
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,21 @@ copy_new_files() {
cd /tmp
}

create_local_directories() {
echo "Creating local pillar and salt directories if needed"
PILLARSALTDIR=$1
local_salt_dir="/opt/so/saltstack/local"
for i in "pillar" "salt"; do
for d in $(find $PILLARSALTDIR/$i -type d); do
suffixdir=${d//$PILLARSALTDIR/}
if [ ! -d "$local_salt_dir/$suffixdir" ]; then
mkdir -pv $local_salt_dir$suffixdir
fi
done
chown -R socore:socore $local_salt_dir/$i
done
}

disable_fastestmirror() {
sed -i 's/enabled=1/enabled=0/' /etc/yum/pluginconf.d/fastestmirror.conf
}
Expand Down
2 changes: 2 additions & 0 deletions salt/manager/tools/sbin/soup
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ main() {
backup_old_states_pillars
fi
copy_new_files
create_local_directories "/opt/so/saltstack/default"
apply_hotfix
echo "Hotfix applied"
update_version
Expand Down Expand Up @@ -1113,6 +1114,7 @@ main() {
echo "Copying new Security Onion code from $UPDATE_DIR to $DEFAULT_SALT_DIR."
copy_new_files
echo ""
create_local_directories "/opt/so/saltstack/default"
update_version

echo ""
Expand Down
15 changes: 0 additions & 15 deletions setup/so-functions
Original file line number Diff line number Diff line change
Expand Up @@ -762,21 +762,6 @@ copy_salt_master_config() {
logCmd "systemctl restart salt-master"
}

create_local_directories() {
info "Creating local pillar and salt directories"
PILLARSALTDIR=${SCRIPTDIR::-5}
for i in "pillar" "salt"; do
for d in $(find $PILLARSALTDIR/$i -type d); do
suffixdir=${d//$PILLARSALTDIR/}
if [ ! -d "$local_salt_dir/$suffixdir" ]; then
logCmd "mkdir -pv $local_salt_dir$suffixdir"
fi
done
logCmd "chown -R socore:socore $local_salt_dir/$i"
done

}

create_local_nids_rules() {
title "Create a local.rules file so it doesn't get removed on updates"
logCmd "mkdir -p /opt/so/saltstack/local/salt/idstools"
Expand Down
2 changes: 1 addition & 1 deletion setup/so-setup
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ if ! [[ -f $install_opt_file ]]; then
# Add the socore user
add_socore_user_manager

create_local_directories
create_local_directories ${SCRIPTDIR::-5}
setup_salt_master_dirs
create_manager_pillars

Expand Down

0 comments on commit 437d002

Please sign in to comment.