mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Move container status check to so-common
This commit is contained in:
@@ -19,24 +19,29 @@ IMAGEREPO=securityonion
|
|||||||
|
|
||||||
# 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!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define a banner to separate sections
|
# Define a banner to separate sections
|
||||||
banner="========================================================================="
|
banner="========================================================================="
|
||||||
|
|
||||||
header() {
|
header() {
|
||||||
echo
|
echo
|
||||||
printf '%s\n' "$banner" "$*" "$banner"
|
printf '%s\n' "$banner" "$*" "$banner"
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup_pillar() {
|
lookup_pillar() {
|
||||||
key=$1
|
key=$1
|
||||||
cat /opt/so/saltstack/local/pillar/global.sls | grep $key | awk '{print $2}'
|
cat /opt/so/saltstack/local/pillar/global.sls | grep $key | awk '{print $2}'
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup_pillar_secret() {
|
lookup_pillar_secret() {
|
||||||
key=$1
|
key=$1
|
||||||
cat /opt/so/saltstack/local/pillar/secrets.sls | grep $key | awk '{print $2}'
|
cat /opt/so/saltstack/local/pillar/secrets.sls | grep $key | awk '{print $2}'
|
||||||
|
}
|
||||||
|
|
||||||
|
check_container() {
|
||||||
|
docker ps | grep "$1:" > /dev/null 2>&1
|
||||||
|
return $?
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ resp=$(curl -sk -XPOST -H "Authorization: Bearer $CORTEX_KEY" -H "Content-Type:
|
|||||||
if [[ "$resp" =~ \"status\":\"Ok\" ]]; then
|
if [[ "$resp" =~ \"status\":\"Ok\" ]]; then
|
||||||
echo "Successfully added user to Cortex."
|
echo "Successfully added user to Cortex."
|
||||||
else
|
else
|
||||||
echo "Failed to add user to Cortex. See API response below."
|
echo "Failed to add user to Cortex."
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ resp=$(curl -sk -XPOST -H "Authorization: Bearer $THEHIVE_KEY" -H "Content-Type:
|
|||||||
if [[ "$resp" =~ \"status\":\"Ok\" ]]; then
|
if [[ "$resp" =~ \"status\":\"Ok\" ]]; then
|
||||||
echo "Successfully added user to TheHive."
|
echo "Successfully added user to TheHive."
|
||||||
else
|
else
|
||||||
echo "Failed to add user to TheHive. See API response below."
|
echo "Failed to add user to TheHive."
|
||||||
echo $resp
|
echo $resp
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -8,18 +8,7 @@
|
|||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
got_root() {
|
. /usr/sbin/so-common
|
||||||
|
|
||||||
# Make sure you are root
|
|
||||||
if [ "$(id -u)" -ne 0 ]; then
|
|
||||||
echo "This script must be run using sudo!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Make sure the user is root
|
|
||||||
got_root
|
|
||||||
|
|
||||||
if [[ $# < 1 || $# > 2 ]]; then
|
if [[ $# < 1 || $# > 2 ]]; then
|
||||||
echo "Usage: $0 <list|add|update|delete|validate|valemail|valpass> [email]"
|
echo "Usage: $0 <list|add|update|delete|validate|valemail|valpass> [email]"
|
||||||
@@ -190,9 +179,9 @@ case "${operation}" in
|
|||||||
validateEmail "$email"
|
validateEmail "$email"
|
||||||
createUser "$email"
|
createUser "$email"
|
||||||
echo "Successfully added new user to SOC"
|
echo "Successfully added new user to SOC"
|
||||||
docker ps | grep so-thehive > /dev/null 2>&1 && echo $password | so-thehive-user-add "$email"
|
check_container thehive && echo $password | so-thehive-user-add "$email"
|
||||||
docker ps | grep so-cortex > /dev/null 2>&1 && echo $password | so-cortex-user-add "$email"
|
check_container cortex && echo $password | so-cortex-user-add "$email"
|
||||||
docker ps | grep so-fleet > /dev/null 2>&1 && echo $password | so-fleet-user-add "$email"
|
check_container fleet && echo $password | so-fleet-user-add "$email"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"list")
|
"list")
|
||||||
|
|||||||
Reference in New Issue
Block a user