mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 09:12:45 +01:00
setup and so-verify/so-status interop
This commit is contained in:
@@ -24,11 +24,13 @@ def showUsage(options, args):
|
||||
print(' -h - Prints this usage information')
|
||||
print(' -q - Suppress output; useful for automation of exit code value')
|
||||
print(' -j - Output in JSON format')
|
||||
print(' -i - Consider the installation outcome regardless of whether the system appears healthy')
|
||||
print('')
|
||||
print(' Exit codes:')
|
||||
print(' 0 - Success, system appears to be running correctly')
|
||||
print(' 1 - Error, one or more subsystems are not running')
|
||||
print(' 2 - System is starting')
|
||||
print(' 3 - System installation encountered errors')
|
||||
print(' 99 - Installation in progress')
|
||||
sys.exit(1)
|
||||
|
||||
@@ -38,6 +40,12 @@ def fail(msg):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def check_installation_status(options, console):
|
||||
if "-i" in options and os.path.isfile('/root/failure'):
|
||||
return 3
|
||||
return 0
|
||||
|
||||
|
||||
def check_system_status(options, console):
|
||||
code = 0
|
||||
highstate_end_time = 0
|
||||
@@ -64,6 +72,8 @@ def output(options, console, code, data):
|
||||
elif "-q" not in options:
|
||||
if code == 2:
|
||||
console.print(" [bold yellow]:hourglass: [bold white]System appears to be starting. No highstate has completed since the system was restarted.")
|
||||
if code == 3:
|
||||
console.print(" [bold red]:exclamation: [bold white]Installation encountered errors.")
|
||||
elif code == 99:
|
||||
console.print(" [bold red]:exclamation: [bold white]Installation does not appear to be complete. A highstate has not fully completed.")
|
||||
else:
|
||||
@@ -137,7 +147,9 @@ def check_container_status(options, console):
|
||||
|
||||
def check_status(options, console):
|
||||
container_list = []
|
||||
code = check_system_status(options, console)
|
||||
code = check_installation_status(options, console)
|
||||
if code == 0:
|
||||
code = check_system_status(options, console)
|
||||
if code == 0:
|
||||
code, container_list = check_container_status(options, console)
|
||||
output(options, console, code, container_list)
|
||||
@@ -150,9 +162,8 @@ def main():
|
||||
for option in args:
|
||||
if option.startswith("-"):
|
||||
options.append(option)
|
||||
args.remove(option)
|
||||
|
||||
if len(args) != 0 or "-h" in options:
|
||||
if "-h" in options or "--help" in options or "-?" in options:
|
||||
showUsage(options, None)
|
||||
|
||||
if os.environ["USER"] != "root":
|
||||
|
||||
@@ -1774,6 +1774,10 @@ reinstall_init() {
|
||||
|
||||
local service_retry_count=20
|
||||
|
||||
# Disregard previous install outcomes
|
||||
rm -f /root/failure
|
||||
rm -f /root/success
|
||||
|
||||
{
|
||||
# remove all of root's cronjobs
|
||||
logCmd "crontab -r -u root"
|
||||
|
||||
@@ -81,18 +81,27 @@ status_failed() {
|
||||
|
||||
main() {
|
||||
exit_code=0
|
||||
if log_has_errors; then
|
||||
echo "WARNING: Errors detected during setup"
|
||||
if [ -f /root/success ]; then
|
||||
echo "Successfully completed setup a while ago"
|
||||
elif [ -f /root/failure ]; then
|
||||
echo "WARNING: Failed setup a while ago"
|
||||
exit_code=1
|
||||
elif log_has_errors; then
|
||||
echo "WARNING: Errors detected during setup"
|
||||
exit_code=1
|
||||
touch /root/failure
|
||||
elif using_iso && cron_error_in_mail_spool; then
|
||||
echo "WARNING: Unexpected cron job output in mail spool"
|
||||
echo "WARNING: Unexpected cron job output in mail spool"
|
||||
exit_code=1
|
||||
touch /root/failure
|
||||
elif is_manager_node && status_failed; then
|
||||
echo "WARNING: Containers are not in a healthy state"
|
||||
exit_code=1
|
||||
touch /root/failure
|
||||
else
|
||||
echo "Successfully completed setup!"
|
||||
fi
|
||||
echo "Successfully completed setup!"
|
||||
touch /root/success
|
||||
fi
|
||||
|
||||
exit $exit_code
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user