0477.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Create An Easy to Use, Locally Hosted Bash Script Repository</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Linux,Bash,Script Repository,Apache,CURL,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Create An Easy to Use, Locally Hosted Bash Script Repository">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="06/17/2022 08:43:36 AM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Create An Easy to Use, Locally Hosted Bash Script Repository</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <p><em>In this example I&#39;ll be installing Apache2 on a Debian VM, but the server can be hosted on any OS or web server capable of serving .sh files.</em></p>
  26. <h2>Installing a Web Server</h2>
  27. <ol>
  28. <li>Log into the Linux device</li>
  29. <li>Run the following commands in a terminal window:
  30. <div class="codeBlock"># update software repositories<br />
  31. sudo apt update<br />
  32. # install available software updates<br />
  33. sudo apt upgrade -y<br />
  34. # install apache2 webserver and curl<br />
  35. sudo apt install apache2 curl -y<br />
  36. # create a subfolder in the webroot to store .sh files<br />
  37. sudo mkdir /var/www/html/bash -p</div>
  38. </li>
  39. </ol>
  40. <h2>Creating a Sample Bash Script</h2>
  41. <ol>
  42. <li>Continue with the following command to create a sample bash script
  43. <div class="codeBlock">sudo nano /var/www/html/bash/whoami.sh</div>
  44. </li>
  45. <li>Paste the following script into whoami.sh
  46. <p>#!/bin/bash<br />
  47. echo &quot;hello, today is $(date &#39;+%A&#39;). You are running me as $(whoami).&quot;</p>
  48. </li>
  49. <li>Press CTRL+O, Enter, CTRL+X to write the changes to whoami.sh</li>
  50. </ol>
  51. <h2>Executing the Sample Bash Script</h2>
  52. <ol>
  53. <li>Continue with the following command to execute the sample script
  54. <div class="codeBlock">curl http://DNSorIP/bash/whoami.sh | bash</div>
  55. </li>
  56. </ol>
  57. </div>
  58. </div>
  59. </body>
  60. </html>