Refactor Splunk installation script messages and paths

This commit is contained in:
CanbiZ 2025-11-07 10:56:50 +01:00 committed by GitHub
parent 112ef045ac
commit 312b4362c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,12 +42,9 @@ while true; do
esac esac
done done
msg_info "Getting Splunk Enterprise download link" msg_info "Setup Splunk Enterprise"
DOWNLOAD_URL=$(curl -s "https://www.splunk.com/en_us/download/splunk-enterprise.html" | grep -o 'data-link="[^"]*' | sed 's/data-link="//' | grep "https.*products/splunk/releases" | grep "\.deb$") DOWNLOAD_URL=$(curl -s "https://www.splunk.com/en_us/download/splunk-enterprise.html" | grep -o 'data-link="[^"]*' | sed 's/data-link="//' | grep "https.*products/splunk/releases" | grep "\.deb$")
RELEASE=$(echo "$DOWNLOAD_URL" | sed 's|.*/releases/\([^/]*\)/.*|\1|') RELEASE=$(echo "$DOWNLOAD_URL" | sed 's|.*/releases/\([^/]*\)/.*|\1|')
msg_ok "Got Splunk Enterprise v${RELEASE} download link"
msg_info "Setup Splunk Enterprise"
$STD curl -fsSL -o "splunk-enterprise.deb" "$DOWNLOAD_URL" || { $STD curl -fsSL -o "splunk-enterprise.deb" "$DOWNLOAD_URL" || {
msg_error "Failed to download Splunk Enterprise from the provided link." msg_error "Failed to download Splunk Enterprise from the provided link."
exit 1 exit 1
@ -57,7 +54,6 @@ rm -f "splunk-enterprise.deb"
msg_ok "Setup Splunk Enterprise v${RELEASE}" msg_ok "Setup Splunk Enterprise v${RELEASE}"
msg_info "Creating Splunk admin user" msg_info "Creating Splunk admin user"
SPLUNK_HOME="/opt/splunk"
ADMIN_USER="admin" ADMIN_USER="admin"
ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
{ {
@ -66,17 +62,17 @@ ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
echo "Password: $ADMIN_PASS" echo "Password: $ADMIN_PASS"
} >> ~/splunk.creds } >> ~/splunk.creds
cat > "${SPLUNK_HOME}/etc/system/local/user-seed.conf" << EOF cat > "/opt/splunk/etc/system/local/user-seed.conf" << EOF
[user_info] [user_info]
USERNAME = $ADMIN_USER USERNAME = $ADMIN_USER
PASSWORD = $ADMIN_PASS PASSWORD = $ADMIN_PASS
EOF EOF
msg_ok "Created Splunk admin user" msg_ok "Created Splunk admin user"
msg_info "Starting Splunk Enterprise" msg_info "Starting Service"
$STD ${SPLUNK_HOME}/bin/splunk start --accept-license --answer-yes --no-prompt $STD /opt/splunk/bin/splunk start --accept-license --answer-yes --no-prompt
$STD ${SPLUNK_HOME}/bin/splunk enable boot-start $STD /opt/splunk/bin/splunk enable boot-start
msg_ok "Splunk Enterprise started" msg_ok "Started Service"
motd_ssh motd_ssh
customize customize