12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Create An Easy to Use, Locally Hosted Bash Script Repository</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="UTF-8">
- <meta name="keywords" content="Linux,Bash,Script Repository,Apache,CURL,How To,Tutorial,i12bretro">
- <meta name="author" content="i12bretro">
- <meta name="description" content="Create An Easy to Use, Locally Hosted Bash Script Repository">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="revised" content="06/17/2022 08:43:36 AM" />
- <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script type="text/javascript" src="includes/js/steps.js"></script>
- <link href="css/steps.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="gridContainer">
- <div class="topMargin"></div>
- <div id="listName" class="topMargin">
- <h1>Create An Easy to Use, Locally Hosted Bash Script Repository</h1>
- </div>
- <div></div>
- <div id="content">
- <p><em>In this example I'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>
- <h2>Installing a Web Server</h2>
- <ol>
- <li>Log into the Linux device</li>
- <li>Run the following commands in a terminal window:
- <div class="codeBlock"># update software repositories<br />
- sudo apt update<br />
- # install available software updates<br />
- sudo apt upgrade -y<br />
- # install apache2 webserver and curl<br />
- sudo apt install apache2 curl -y<br />
- # create a subfolder in the webroot to store .sh files<br />
- sudo mkdir /var/www/html/bash -p</div>
- </li>
- </ol>
- <h2>Creating a Sample Bash Script</h2>
- <ol>
- <li>Continue with the following command to create a sample bash script
- <div class="codeBlock">sudo nano /var/www/html/bash/whoami.sh</div>
- </li>
- <li>Paste the following script into whoami.sh
- <p>#!/bin/bash<br />
- echo "hello, today is $(date '+%A'). You are running me as $(whoami)."</p>
- </li>
- <li>Press CTRL+O, Enter, CTRL+X to write the changes to whoami.sh</li>
- </ol>
- <h2>Executing the Sample Bash Script</h2>
- <ol>
- <li>Continue with the following command to execute the sample script
- <div class="codeBlock">curl http://DNSorIP/bash/whoami.sh | bash</div>
- </li>
- </ol>
- </div>
- </div>
- </body>
- </html>
-
|