Replace all references to Splunk Add-on with Technical Add-on Replace URLs Remove splunkbase stuff Add copyright
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# Copyright (C) 2025 Michael Erdely All Rights Reserved.
|
|
# SPDX-FileCopyrightText: 2024 Splunk, Inc.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import json
|
|
import sys
|
|
|
|
import splunk
|
|
import splunk.bundle as bundle
|
|
|
|
|
|
class SetupService(splunk.rest.BaseRestHandler):
|
|
def handle_GET(self):
|
|
try:
|
|
is_recognized_unix = not sys.platform.startswith("win")
|
|
self.response.write(json.dumps(is_recognized_unix))
|
|
except Exception as e:
|
|
self.response.write(e)
|
|
|
|
def handle_POST(self):
|
|
sessionKey = self.sessionKey
|
|
try:
|
|
conf = bundle.getConf(
|
|
"app", sessionKey, namespace="TA-unix", owner="nobody"
|
|
)
|
|
stanza = conf.stanzas["install"].findKeys("is_configured")
|
|
if stanza:
|
|
if stanza["is_configured"] == "0" or stanza["is_configured"] == "false":
|
|
conf["install"]["is_configured"] = "true"
|
|
splunk.rest.simpleRequest(
|
|
"/apps/local/TA-unix/_reload", sessionKey=sessionKey
|
|
)
|
|
else:
|
|
conf["install"]["is_configured"] = "true"
|
|
splunk.rest.simpleRequest(
|
|
"/apps/local/TA-unix/_reload", sessionKey=sessionKey
|
|
)
|
|
except Exception as e:
|
|
self.response.write(e)
|