Bash On Steroids Save

Use bash scrpts for writing beautiful web apps. :globe_with_meridians:

Project README

Use !#bash scripts for writing beautiful web apps :sparkles

pageres

DEMO bos.tino.sh

BoS MIT Build Status Gitter GitHub issues Awesome k3s GitHub Super-Linter last-commit

Features

  • easy to use <?bash echo "hello world" ?>
  • write fast wabapps in pure #!bash script
  • QUERY_STRING and POST_STRING variables can used as normal bash variables (e.g example?var1=foo&var2=bar&var3=nase becomes to echo "${var1} ${var2} ${var3})
  • Funktion for decoding URL-encoding: var_dec=$(urldecode $var1)
  • Bash for Web Applications

Why?

  • Because there's nothing you can't fix with a #!Bash Script.

Install Apache2

apt-get update; apt-get install -y apache2
tee /etc/apache2/sites-enabled/000-default.conf >/dev/null <<EOF
<VirtualHost *:80>
 ServerName example.org
 ServerAdmin [email protected]
 DocumentRoot /var/www/html/
 
        ScriptAlias "/index.html" "/usr/lib/cgi-bin/index.cgi"
        ScriptAlias "/index" "/usr/lib/cgi-bin/index.cgi"
        RedirectMatch 404 .*\.htsh
        <Directory /var/www/html/>
          AllowOverride none
          Options -Indexes
          Require all granted
        </Directory>
 ErrorLog /var/log/apache2/error.log
 CustomLog /var/log/apache2/access.log combined
 Include conf-available/serve-cgi-bin.conf
</VirtualHost>
EOF
a2enmod cgid
service apache2 restart

install BoS

cd /var/www/html # your html folder
wget https://raw.githubusercontent.com/tinoschroeter/bash_on_steroids/master/build.sh
wget https://raw.githubusercontent.com/tinoschroeter/bash_on_steroids/master/index.htsh # example file
chmod +x build.sh
./build.sh

$ index.cgi can be found in  /usr/lib/cgi-bin

Usage

All bash codes are to be enclosed within <?bash ... ?> or in short, <? ... ?> tags.

<!DOCTYPE html>
<html>
 <body>
 <ul>
    <?bash
      for i in Buzz Rex Bo Hamm Slink Potato; do
        echo "<li>$i</li>"
      done
      ?>
</ul>
</body>
</html>

The Template Enginge will create this cgi script out of it

#!/bin/bash 
echo "X-Bash-On-Steroids: Because there's nothing you can't fix with a #!Bash Script."
echo Content-type: text/html
echo ""
## make POST and GET stings 
## as bash variables available
if [ ! -z $CONTENT_LENGTH ] && [ "$CONTENT_LENGTH" -gt 0 ] && [ $CONTENT_TYPE != "multipart/form-data" ]; then
read -n $CONTENT_LENGTH POST_STRING <&0
eval $(echo "${POST_STRING//;}"|grep '='|tr '&' ';')
fi
eval $(echo "${QUERY_STRING//;}"|grep '='|tr '&' ';')
## decode URL-encoding
urldecode() { : "${*//+/ }"; echo -e "${_//%/\x}"; }
echo  "<!DOCTYPE html>"
echo  "<html>"
echo  " <body>"
echo  " <ul>"
    
      for i in Buzz Rex Bo Hamm Slink Potato; do
        echo "<li>$i</li>"
      done
      
echo  "</ul>"
echo  "</body>"
echo  "</html>"

list

Decode URL-encoding

transform this %23%21%2Fbin%2Fbash to that #!/bin/bash
example:

var_dec=$(urldecode $var)

https://en.wikipedia.org/wiki/Percent-encoding

build

./build.sh 
index.htsh --->> /usr/lib/cgi-bin/index.cgi

Vagrant

git clone https://github.com/tinoschroeter/bash_on_steroids.git
cd bash_on_steroids

vagrant up

open http://localhost:8090/

STvsSW

DEMO

Wiki

Wiki --> wiki

License

MIT

Open Source Agenda is not affiliated with "Bash On Steroids" Project. README Source: tinoschroeter/bash_on_steroids

Open Source Agenda Badge

Open Source Agenda Rating