0477.html 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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="How To,Tutorial,i12bretro,Linux,Bash,Script Repository,Apache,CURL">
  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. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  12. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  13. <script type="text/javascript" src="includes/js/steps.js"></script>
  14. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  15. </head>
  16. <body>
  17. <div id="gridContainer">
  18. <div class="topMargin"></div>
  19. <div id="listName" class="topMargin">
  20. <h1>Create An Easy to Use, Locally Hosted Bash Script Repository</h1>
  21. </div>
  22. <div></div>
  23. <div id="content">
  24. <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>
  25. <h2>Installing a Web Server</h2>
  26. <ol>
  27. <li>Log into the Linux device</li>
  28. <li>Run the following commands in a terminal window:
  29. <div class="codeBlock"># update software repositories<br />
  30. sudo apt update<br />
  31. # install available software updates<br />
  32. sudo apt upgrade -y<br />
  33. # install apache2 webserver and curl<br />
  34. sudo apt install apache2 curl -y<br />
  35. # create a subfolder in the webroot to store .sh files<br />
  36. sudo mkdir /var/www/html/bash -p</div>
  37. </li>
  38. </ol>
  39. <h2>Creating a Sample Bash Script</h2>
  40. <ol>
  41. <li>Continue with the following command to create a sample bash script
  42. <div class="codeBlock">sudo nano /var/www/html/bash/whoami.sh</div>
  43. </li>
  44. <li>Paste the following script into whoami.sh
  45. <p>#!/bin/bash<br />
  46. echo &quot;hello, today is $(date &#39;+%A&#39;). You are running me as $(whoami).&quot;</p>
  47. </li>
  48. <li>Press CTRL+O, Enter, CTRL+X to write the changes to whoami.sh</li>
  49. </ol>
  50. <h2>Executing the Sample Bash Script</h2>
  51. <ol>
  52. <li>Continue with the following command to execute the sample script
  53. <div class="codeBlock">curl http://DNSorIP/bash/whoami.sh | bash</div>
  54. </li>
  55. </ol>
  56. </div>
  57. </div>
  58. </body>
  59. </html>