ninja.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. set -e
  3. #get OAuth Token
  4. curl --request POST \
  5. --url https://app.ninjarmm.com/ws/oauth/token \
  6. --header 'Content-Type: application/x-www-form-urlencoded' \
  7. --data grant_type=client_credentials \
  8. --data client_id=Exx51oPGv_hZ8fgQh2IqtpX5VpA \
  9. --data client_secret=AAv3WeKnUjSOSRuW94plKdrihEw8AEZCJd38VK56aSGjAa4BAtm_zw \
  10. --data scope=management
  11. # Generate installer URL
  12. curl -X 'GET' \
  13. 'https://app.ninjarmm.com/v2/organization/26/location/45/installer/LINUX_RPM' \
  14. -H 'accept: application/json' \
  15. -H 'Authorization: Bearer GYEHTy3-reBtoPz-vvqQkqMePKk8LU0cJoUwMf7T7VA.2c_ZrDl1CxNRA6Y5Cuy2o94ZDMZsbUkAIeKUUeOE64U'
  16. # Download installer
  17. curl -o ninja-agent.deb https://app.ninjarmm.com/agent/installer/e99519fc-b76e-4c50-b5ff-ef68db95b032/serverslinuxmainoffice-5.6.7925-installer-x86-64.rpm
  18. #!/bin/bash
  19. # Step 1: Get OAuth token
  20. oauth_response=$(curl --request POST \
  21. --url https://app.ninjarmm.com/ws/oauth/token \
  22. --header 'Content-Type: application/x-www-form-urlencoded' \
  23. --data grant_type=client_credentials \
  24. --data client_id=Exx51oPGv_hZ8fgQh2IqtpX5VpA \
  25. --data client_secret=AAv3WeKnUjSOSRuW94plKdrihEw8AEZCJd38VK56aSGjAa4BAtm_zw \
  26. --data scope=management)
  27. # Extract access token from response
  28. access_token=$(echo "$oauth_response" | jq -r '.access_token')
  29. # Step 2: Generate installer URL
  30. installer_response=$(curl -X 'GET' \
  31. 'https://app.ninjarmm.com/v2/organization/26/location/45/installer/LINUX_RPM' \
  32. -H 'accept: application/json' \
  33. -H "Authorization: Bearer $access_token")
  34. # Extract installer URL from response
  35. installer_url=$(echo "$installer_response" | jq -r '.url')
  36. # Step 3: Download installer using generated URL
  37. curl -o ninja-agent.deb "$installer_url"