Create An Easy to Use, Locally Hosted Bash Script Repository

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.

Installing a Web Server

  1. Log into the Linux device
  2. Run the following commands in a terminal window:
    # update software repositories
    sudo apt update
    # install available software updates
    sudo apt upgrade -y
    # install apache2 webserver and curl
    sudo apt install apache2 curl -y
    # create a subfolder in the webroot to store .sh files
    sudo mkdir /var/www/html/bash -p

Creating a Sample Bash Script

  1. Continue with the following command to create a sample bash script
    sudo nano /var/www/html/bash/whoami.sh
  2. Paste the following script into whoami.sh

    #!/bin/bash
    echo "hello, today is $(date '+%A'). You are running me as $(whoami)."

  3. Press CTRL+O, Enter, CTRL+X to write the changes to whoami.sh

Executing the Sample Bash Script

  1. Continue with the following command to execute the sample script
    curl http://DNSorIP/bash/whoami.sh | bash