Skip to content

Commit

Permalink
chore: Refactor install_insight_agent script
Browse files Browse the repository at this point in the history
  • Loading branch information
talltechy committed Apr 19, 2024
1 parent 86c6bda commit dd8fb04
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/rapid7/tools/install_insight_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,41 @@
import glob
import subprocess

# Get the current directory
current_directory = os.path.dirname(os.path.abspath(__file__))
def install_insight_agent():
"""
Installs the Rapid7 Insight Agent.
# Search for the installer files in the current directory
installer_files = glob.glob(os.path.join(current_directory, "agent_installer-*.sh"))
This script searches for the installer files in the current directory and prompts the user to provide the location
of the installer file if none is found. It then makes the installer file executable, prompts the user to input the
token, and proceeds with the installation using the provided token.
if not installer_files:
# Prompt the user to provide the location of the installer file
installer_file = input("Please enter the location of the installer file: ")
else:
# Use the first found installer file
installer_file = installer_files[0]
Returns:
None
"""
# Get the current directory
current_directory = os.path.dirname(os.path.abspath(__file__))

# Make the installer file executable
os.chmod(installer_file, 0o755)
# Search for the installer files in the current directory
installer_files = glob.glob(os.path.join(current_directory, "agent_installer-*.sh"))

# Prompt the user to input the token
token = input("Please enter the token: ")
if not installer_files:
# Prompt the user to provide the location of the installer file
installer_file = input("Please enter the location of the installer file: ")
else:
# Use the first found installer file
installer_file = installer_files[0]

# Continue with the installation
print("Installing Rapid7 Insight Agent...")
subprocess.run(["sudo", installer_file, "install_start", "--token", token], check=True)
# Make the installer file executable
os.chmod(installer_file, 0o755)

print("Installation completed successfully!")
# Prompt the user to input the token
token = input("Please enter the token: ")

# Continue with the installation
print("Installing Rapid7 Insight Agent...")
subprocess.run(["sudo", installer_file, "install_start", "--token", token], check=True)

print("Installation completed successfully!")

# Call the function to install the Rapid7 Insight Agent
install_insight_agent()

0 comments on commit dd8fb04

Please sign in to comment.