|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 3 | +# Author: rcastley |
| 4 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 5 | +# Source: https://www.splunk.com/en_us/download.html |
| 6 | + |
| 7 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
| 8 | +color |
| 9 | +verb_ip6 |
| 10 | +catch_errors |
| 11 | +setting_up_container |
| 12 | +network_check |
| 13 | +update_os |
| 14 | + |
| 15 | +echo -e "${TAB3}┌─────────────────────────────────────────────────────────────────────────┐" |
| 16 | +echo -e "${TAB3}│ SPLUNK GENERAL TERMS │" |
| 17 | +echo -e "${TAB3}└─────────────────────────────────────────────────────────────────────────┘" |
| 18 | +echo "" |
| 19 | +echo -e "${TAB3}Before proceeding with the Splunk Enterprise installation, you must" |
| 20 | +echo -e "${TAB3}review and accept the Splunk General Terms." |
| 21 | +echo "" |
| 22 | +echo -e "${TAB3}Please review the terms at:" |
| 23 | +echo -e "${TAB3}${GATEWAY}${BGN}https://www.splunk.com/en_us/legal/splunk-general-terms.html${CL}" |
| 24 | +echo "" |
| 25 | + |
| 26 | +while true; do |
| 27 | + echo -e "${TAB3}Do you accept the Splunk General Terms? (y/N): \c" |
| 28 | + read -r response |
| 29 | + case $response in |
| 30 | + [Yy]|[Yy][Ee][Ss]) |
| 31 | + msg_ok "Terms accepted. Proceeding with installation..." |
| 32 | + break |
| 33 | + ;; |
| 34 | + [Nn]|[Nn][Oo]|"") |
| 35 | + msg_error "Terms not accepted. Installation cannot proceed." |
| 36 | + msg_error "Please review the terms and run the script again if you wish to proceed." |
| 37 | + exit 1 |
| 38 | + ;; |
| 39 | + *) |
| 40 | + msg_error "Invalid response. Please enter 'y' for yes or 'n' for no." |
| 41 | + ;; |
| 42 | + esac |
| 43 | +done |
| 44 | + |
| 45 | +msg_info "Setup Splunk Enterprise" |
| 46 | +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$") |
| 47 | +RELEASE=$(echo "$DOWNLOAD_URL" | sed 's|.*/releases/\([^/]*\)/.*|\1|') |
| 48 | +$STD curl -fsSL -o "splunk-enterprise.deb" "$DOWNLOAD_URL" || { |
| 49 | + msg_error "Failed to download Splunk Enterprise from the provided link." |
| 50 | + exit 1 |
| 51 | +} |
| 52 | +$STD dpkg -i "splunk-enterprise.deb" |
| 53 | +rm -f "splunk-enterprise.deb" |
| 54 | +msg_ok "Setup Splunk Enterprise v${RELEASE}" |
| 55 | + |
| 56 | +msg_info "Creating Splunk admin user" |
| 57 | +ADMIN_USER="admin" |
| 58 | +ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) |
| 59 | +{ |
| 60 | + echo "Splunk-Credentials" |
| 61 | + echo "Username: $ADMIN_USER" |
| 62 | + echo "Password: $ADMIN_PASS" |
| 63 | +} >> ~/splunk.creds |
| 64 | + |
| 65 | +cat > "/opt/splunk/etc/system/local/user-seed.conf" << EOF |
| 66 | +[user_info] |
| 67 | +USERNAME = $ADMIN_USER |
| 68 | +PASSWORD = $ADMIN_PASS |
| 69 | +EOF |
| 70 | +msg_ok "Created Splunk admin user" |
| 71 | + |
| 72 | +msg_info "Starting Service" |
| 73 | +$STD /opt/splunk/bin/splunk start --accept-license --answer-yes --no-prompt |
| 74 | +$STD /opt/splunk/bin/splunk enable boot-start |
| 75 | +msg_ok "Started Service" |
| 76 | + |
| 77 | +motd_ssh |
| 78 | +customize |
| 79 | +cleanup_lxc |
0 commit comments