mirror of
https://gitlab.com/niansa/simpsh-httpd.git
synced 2025-03-06 20:53:36 +01:00
Compare commits
110 commits
Author | SHA1 | Date | |
---|---|---|---|
|
ec3174b204 | ||
|
84f6721954 | ||
|
3a1d6062c9 | ||
|
ba19b2d8b6 | ||
|
144f4ecd09 | ||
|
7962a5d901 | ||
|
6e700524e3 | ||
|
8feb3f24b1 | ||
|
df16ff520a | ||
|
482feb559a | ||
|
f4b00e82ab | ||
|
9a91175fba | ||
|
c1223801ae | ||
|
0d35ec2a9e | ||
|
5331253809 | ||
|
45cfd2f92e | ||
|
cb40468346 | ||
|
3b4e1e6701 | ||
|
a535f19585 | ||
|
c8369dcebf | ||
|
ca527e1a78 | ||
|
64f1631578 | ||
|
6288a86887 | ||
|
da817cdd97 | ||
|
543fafb364 | ||
|
1443f73e1c | ||
|
68a369a35c | ||
|
2b720e7c24 | ||
|
c6542ec98d | ||
|
92cf8d99b2 | ||
|
9e75ddabf2 | ||
|
6352d21192 | ||
|
7c49789c9b | ||
|
48374a7eec | ||
|
609d19a287 | ||
|
cf1c5694ba | ||
|
cc3734e2f1 | ||
|
a601aba795 | ||
|
7117ecacaf | ||
|
fe3580e776 | ||
|
4c030ab5bb | ||
|
138caa6ec7 | ||
|
26f767532c | ||
|
ee9145b3a5 | ||
|
08692030c7 | ||
|
b773ca7aca | ||
|
ebbe1cf65a | ||
|
6205888968 | ||
|
bdf8c224bb | ||
|
a714550f23 | ||
|
fab4b83c1e | ||
|
c64178fd03 | ||
|
5c0e379078 | ||
|
248905e487 | ||
|
82930f4dd1 | ||
|
99937bf9ae | ||
|
a0a7631e0e | ||
|
1f1781f911 | ||
|
9e8eb031dd | ||
|
671678c573 | ||
|
9f90ed22e9 | ||
|
5fbf0cb95b | ||
|
cb15992a8d | ||
|
aa8914259e | ||
|
16ed196e0f | ||
|
d3bc9d4edb | ||
|
89d7dce9ac | ||
|
a0ea76cddb | ||
|
b7b7a10358 | ||
|
4a39a37f87 | ||
|
13d321498c | ||
|
5ac6f6404a | ||
|
14bd41264e | ||
|
4039accefd | ||
|
9180357bd6 | ||
|
2d432acdfa | ||
|
0889b980fe | ||
|
63a78f11e9 | ||
|
a5140f24d8 | ||
|
cb64f53d7b | ||
|
0e551109f7 | ||
|
9946e672c1 | ||
|
a5e64f20bd | ||
|
142a1d4e9d | ||
|
f6446cb9f7 | ||
|
d64e7111db | ||
|
f7258eddfa | ||
|
2ab7a080ff | ||
|
9a7922024d | ||
|
0698650a68 | ||
|
95fac94170 | ||
|
76a49d2b3e | ||
|
f439810637 | ||
|
7753d3eff7 | ||
|
f808c3f852 | ||
|
15a8ff1c09 | ||
|
2dddace612 | ||
|
3fe0bc0a08 | ||
|
232abbb467 | ||
|
52e63d6f90 | ||
|
348682f157 | ||
|
8d116aaac8 | ||
|
8a00db6458 | ||
|
1e9a30ba1b | ||
|
5c711243e4 | ||
|
c1ca209835 | ||
|
d9a68f5333 | ||
|
2fdc38a4dd | ||
|
35e7706a70 | ||
|
e862dceacf |
16 changed files with 142 additions and 122 deletions
3
.gitlab-ci.yml
Normal file
3
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
job:
|
||||
script:
|
||||
- chmod +x ./ci-test.sh && ./ci-test.sh
|
60
README.md
60
README.md
|
@ -1,40 +1,26 @@
|
|||
# simpsh-httpd
|
||||
|
||||
An usable bash-httpserver with easy configuration and PHP.
|
||||
|
||||
## Installation
|
||||
|
||||
### *Recomended*: Release installation
|
||||
1. Download a release from the [Tags](https://gitlab.com/niansa/simpsh-httpd/tags/) page
|
||||
2. Follow step 4 and 5 of "Installation as package" if you selected to download and install the Prebuild Debian package. Otherwise follow step 3-6 of "Standard installation"
|
||||
|
||||
### Installation as package (Debian based distros only)
|
||||
1. Install build dependencies: `sudo apt install fakeroot`
|
||||
2. Build package: `cd ; curl https://gitlab.com/niansa/simpsh-httpd/raw/master/mkdeb.sh | bash -`
|
||||
3. Install package: `sudo dpkg --install ./simpsh-httpd.deb && sudo apt -f install`
|
||||
4. Edit /etc/simpsh-httpd/config.sh: `sudoedit /etc/simpsh-httpd/config.sh`:
|
||||
* `FILES` Here is the webroot (homefolder for the website).
|
||||
* `HTMLTITLE` This is the title for the filelist.
|
||||
* `OUTFILE` The finished Document will saved here. ${OUTFILEID} must be included!
|
||||
* `DEFAULTCONTENTTYPE` This Content-Type send the Server, if the requested File isn't a folder or phpfile.
|
||||
* `PORT` This port will used for listening.
|
||||
* `WEBSITE` This is the URL of the website (Example: "http://localhost:$PORT")
|
||||
* `ERROR404` This is the error page 404
|
||||
* `ERROR403` This is the error page 403
|
||||
1. Install build dependencies: `sudo apt install fakeroot curl git`
|
||||
2. Build package: `curl https://gitlab.com/niansa/simpsh-httpd/raw/master/mkdeb.sh | bash -`
|
||||
3. Install package: `sudo apt install ~/simpsh-httpd.deb`
|
||||
4. Edit /etc/simpsh-httpd/config.sh: `sudoedit /etc/simpsh-httpd/config.sh`
|
||||
5. Start simpsh-httpd: `simpsh-httpd-socat -d`
|
||||
|
||||
|
||||
### Standard installation
|
||||
|
||||
1. Install following packages: `bash socat dos2unix`
|
||||
2. Download simpsh-httpd:
|
||||
* `$ cd ~`
|
||||
* `$ git clone https://github.com/niansa/simpsh-httpd.git`
|
||||
* `$ cd ./simpsh-httpd`
|
||||
3. Edit config.sh:
|
||||
* `FILES` Here is the webroot (homefolder for the website).
|
||||
* `HTMLTITLE` This is the title for the filelist.
|
||||
* `OUTFILE` The finished Document will saved here. ${OUTFILEID} must be included!
|
||||
* `DEFAULTCONTENTTYPE` This Content-Type send the Server, if the requested File isn't a folder or phpfile.
|
||||
* `PORT` This port will used for listening.
|
||||
* `WEBSITE` This is the URL of the website (Example: "http://localhost:$PORT")
|
||||
* `ERROR404` This is the error page 404
|
||||
* `ERROR403` This is the error page 403
|
||||
3. Edit ./config.sh: `nano ./config.sh`
|
||||
4. Make all files executable
|
||||
* `chmod -R a+x ~/simpsh-httpd`
|
||||
5. Start simpsh-httpd:
|
||||
|
@ -43,5 +29,29 @@ An usable bash-httpserver with easy configuration and PHP.
|
|||
6. Have fun with simpsh-httpd!
|
||||
|
||||
|
||||
## Similar projects
|
||||
|
||||
Tip: You don't need to restart simpsh-httpd after update/configchange!
|
||||
### XMB-HTTPD-2
|
||||
http://xmb.ovh/codes/xmb-httpd-2 (Webpage is down)
|
||||
Another HTTPD which is written in bash.
|
||||
|
||||
### Iwanttobash
|
||||
https://github.com/plutesci/Iwanttobash
|
||||
A tool for bash scripting with options for python html etc.
|
||||
|
||||
|
||||
## Entstehung
|
||||
Irgendwann Mitte des Jahres 2016 fing ich an das HTTP-Protokoll zu
|
||||
untersuchen. Ich fand es so interessant, dass ich anfing einen
|
||||
Webserver (HTTPD) zu schreiben! Damals habe ich Bash für alles
|
||||
eingesetzt, also setzte ich es auch für den Webserver ein... Ich
|
||||
hatte damals auf einem shell Provider (bitcoinshell) ein Kommando
|
||||
entdeckt, was mir den Inhalt eines Ordners in HTML als Liste
|
||||
zurückgab. Da ich dachte, mit dem Kommando ließe sich ein
|
||||
Dateiindex wohl sehr einfach einbauen, fing ich damit an. Es wurde
|
||||
aber schwer, als ich feststellte, dass das Kommando nur dort zu
|
||||
finden war! Also schrieb ich den Dateiindexer selber. Nun kam der
|
||||
nächste schwere Punkt: kann man auf einem Port lauschen? Ich
|
||||
probierte es erst mit netcat, was sich als sehr schwierig erwies,
|
||||
schlussendlich erfüllte socat den Zweck.
|
||||
Und so fing dieses kleine Projekt an...
|
||||
|
|
21
ci-test.sh
Executable file
21
ci-test.sh
Executable file
|
@ -0,0 +1,21 @@
|
|||
alias git='"true" ' &&
|
||||
echo "Installing depencies..." &&
|
||||
apt update -qq &&
|
||||
apt install -qq -y fakeroot curl &&
|
||||
echo "Building Debian package..." &&
|
||||
mkdir /tmp/simpsh-httpd &&
|
||||
mv ./* /tmp/simpsh-httpd/ &&
|
||||
mv ./.git /tmp/simpsh-httpd/ &&
|
||||
export HOME="/tmp/" &&
|
||||
cd &&
|
||||
chmod -R a+x ./simpsh-httpd &&
|
||||
./simpsh-httpd/mkdeb.sh &&
|
||||
apt -y install ./simpsh-httpd.deb &&
|
||||
echo "Starting simpsh-httpd..." &&
|
||||
mkdir -p /var/www/html &&
|
||||
simpsh-httpd-socat -d &&
|
||||
echo "Creating test document..." &&
|
||||
(echo "This is a test!" > /var/www/html/testdocument.txt) &&
|
||||
echo "Loading test document from server..."
|
||||
testdoc="$(curl http://localhost:8888/testdocument.txt)" &&
|
||||
(if [[ $testdoc == "This is a test!" ]]; then echo "Server returned expected document"; else echo "Something went wrong... Server returned: $testdoc"; exit 1; fi)
|
24
config.sh
Normal file → Executable file
24
config.sh
Normal file → Executable file
|
@ -1,23 +1,23 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Wo ist der Webroot (Hauptverzeichniss)?
|
||||
# The web server is running under this user (requires to start the socat script as root!). This option may be empty
|
||||
SUUSER=""
|
||||
|
||||
# Here is the webroot (homefolder for the website)
|
||||
FILES="/var/www/html/"
|
||||
|
||||
# Wie soll der Titel der Dateiliste sein, die aufgerufene URL ist in $URL enthalten.
|
||||
HTMLTITLE="Datei: $URL"
|
||||
|
||||
# Wo soll das Fertige HTML-Dokument gespeichert werden? Die Variable $OUTFILEID muss enthalten sein!
|
||||
# The finished Document will saved here. ${OUTFILEID} must be included!
|
||||
OUTFILE="/tmp/simpsh-html.${OUTFILEID}.html"
|
||||
|
||||
# Welcher Content-Type soll bei einem Unbekannten Dateityp gesendet werden?
|
||||
DEFAULTCONTENTTYPE="text/html"
|
||||
|
||||
# Port zum lauschen (Falls start-socat.sh als startscript verwendet wird)
|
||||
# This port will used for listening
|
||||
PORT=8888
|
||||
|
||||
# Wie heisst die Webseite (URL des obersten Verzeichnis)?
|
||||
WEBSITE="http://localhost:$PORT"
|
||||
# Should PHP be enabled? You need to install php-cli package to use it. May be false or true
|
||||
ENABLE_PHP="false"
|
||||
|
||||
# Statuscode-Seiten (Müssen html-Dateien sein)
|
||||
# Should Markdown be enabled? You need to install pandoc package to use it. May be false or true
|
||||
ENABLE_MARKDOWN="false"
|
||||
|
||||
# Error code pages, they need to be HTML documents
|
||||
ERROR404="${FILES}/404.html"
|
||||
ERROR403="${FILES}/403.html"
|
||||
|
|
9
filelist.sh
Normal file → Executable file
9
filelist.sh
Normal file → Executable file
|
@ -1,20 +1,17 @@
|
|||
#! /bin/bash
|
||||
|
||||
status="$URL"
|
||||
|
||||
# Dynamisches HTML
|
||||
echo '<html>
|
||||
<head>
|
||||
<title>'"${HTMLTITLE}"'</title>
|
||||
<title>Index of: '"$URL"'</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>'"$status"'</p>
|
||||
<p>'"$URL"'</p>
|
||||
<h2>Directory list:</h2><br />
|
||||
<a href="../">..</a><br />' >> $OUTFILE
|
||||
|
||||
for i in $( ls "${FILE}" ); do
|
||||
echo ' <a href="./'"${i}"'">'"${i}"'</a><br />' >> $OUTFILE
|
||||
done
|
||||
|
||||
# Statisches HTML
|
||||
echo ' </body>
|
||||
</html>' >> $OUTFILE
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
status="$URL"
|
||||
|
||||
# Statisches HTML
|
||||
echo '<html>
|
||||
<head>
|
||||
<title>'"${HTMLTITLE}"'</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>'"$status"'</p>
|
||||
<h2>Directory list:</h2><br />
|
||||
<a href="../">..</a><br />' >> $HTMLFILE
|
||||
|
||||
# Erstelle Dateiliste im HTML-Format
|
||||
for i in $( ls "${FILE}" ); do
|
||||
echo ' <a href="./'"${i}"'">'"${i}"'</a><br />' >> $HTMLFILE
|
||||
done
|
||||
|
||||
# Statisches HTML
|
||||
echo ' </body>
|
||||
</html>' >> $HTMLFILE
|
2
httpheaders.sh
Normal file → Executable file
2
httpheaders.sh
Normal file → Executable file
|
@ -1,4 +1,6 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Generation of the HTTP-headers
|
||||
echo "$STATUS" >> $OUTFILE
|
||||
echo 'Date: '"$(date)" >> $OUTFILE
|
||||
echo 'Server: httpd' >> $OUTFILE
|
||||
|
|
1
init.sh
Normal file → Executable file
1
init.sh
Normal file → Executable file
|
@ -1,4 +1,5 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Default variables
|
||||
STATUS="HTTP/1.0 200 OK"
|
||||
OUTFILEID="$RANDOM"
|
||||
|
|
20
main.sh
Normal file → Executable file
20
main.sh
Normal file → Executable file
|
@ -1,25 +1,25 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Initalisiere Variablen
|
||||
# Variable initalisation
|
||||
. ./init.sh
|
||||
|
||||
# Lese configdatei
|
||||
# Read the config file
|
||||
. ./config.sh
|
||||
|
||||
# Lese HTTP-Anfrage
|
||||
# Read the HTTP-request
|
||||
. ./readrequest.sh
|
||||
|
||||
# Und vieles andere...
|
||||
# Some URL checks and modifications
|
||||
. ./urlcheck.sh
|
||||
|
||||
# Wenn das Dokument schon fertig ist, dann den folgenden Schritt überspringen
|
||||
# Skip following step, if the document was already created successfully
|
||||
if [ "$DONE" != "true" ]; then
|
||||
# Schreibe fertiges HTML-Dokument
|
||||
# Write finished file
|
||||
. ./sendfile.sh
|
||||
fi
|
||||
|
||||
# Verwende unix2dos auf das Dokument...
|
||||
unix2dos $OUTFILE &> /dev/null
|
||||
|
||||
# Gebe fertiges HTML-Dokument aus
|
||||
# Print finished document
|
||||
cat $OUTFILE
|
||||
|
||||
# Remove the temporary file
|
||||
rm $OUTFILE
|
||||
|
|
22
mkdeb.sh
Normal file → Executable file
22
mkdeb.sh
Normal file → Executable file
|
@ -1,15 +1,31 @@
|
|||
cd ~
|
||||
git clone https://github.com/niansa/simpsh-httpd.git
|
||||
# Change to users home
|
||||
cd
|
||||
|
||||
# Clone the repository
|
||||
git clone https://gitlab.com/niansa/simpsh-httpd.git
|
||||
|
||||
# Make the mkpackage script executable
|
||||
chmod +x ./simpsh-httpd/mkpackage.sh
|
||||
|
||||
# Call package-generator script
|
||||
./simpsh-httpd/mkpackage.sh ~/simpsh-httpd/ ~/simpsh-httpd-pkg/
|
||||
|
||||
# Create Package info
|
||||
mkdir ~/simpsh-httpd-pkg/DEBIAN
|
||||
cd ./simpsh-httpd/
|
||||
echo 'Package: simpsh-httpd
|
||||
Version: 1.2.0
|
||||
Version: '"$(git rev-list --all --count)"'
|
||||
Maintainer: nisa/niansa <nisa@bitcoinshell.mooo.com>
|
||||
Priority: extra
|
||||
Architecture: all
|
||||
Depends: bash, socat
|
||||
Recommends: php-cli, pandoc
|
||||
Description: An usable bash-httpserver with easy configuration and very simple PHP' > ~/simpsh-httpd-pkg/DEBIAN/control
|
||||
cd ..
|
||||
|
||||
# Build package
|
||||
fakeroot dpkg -b ~/simpsh-httpd-pkg ~/simpsh-httpd.deb
|
||||
|
||||
# Clean up
|
||||
rm -rf ~/simpsh-httpd-pkg
|
||||
rm -rf ~/simpsh-httpd
|
||||
|
|
12
mkpackage.sh
Normal file → Executable file
12
mkpackage.sh
Normal file → Executable file
|
@ -1,11 +1,14 @@
|
|||
echo "Bitte warten... Please wait..."
|
||||
|
||||
# Create directories
|
||||
mkdir "$2"
|
||||
cd "$2"
|
||||
mkdir etc
|
||||
mkdir etc/simpsh-httpd
|
||||
mkdir usr
|
||||
mkdir usr/bin
|
||||
mkdir -p etc/simpsh-httpd
|
||||
mkdir -p usr/bin
|
||||
mkdir usr/share
|
||||
mkdir -p var/www/html
|
||||
|
||||
# Copy some files
|
||||
cp -r "$1" usr/share/simpsh-httpd
|
||||
echo 'cd /usr/share/simpsh-httpd
|
||||
./main.sh' > usr/bin/simpsh-httpd
|
||||
|
@ -14,4 +17,5 @@ echo 'cd /usr/share/simpsh-httpd/
|
|||
mv usr/share/simpsh-httpd/config.sh etc/simpsh-httpd
|
||||
ln -sf /etc/simpsh-httpd/config.sh usr/share/simpsh-httpd/config.sh
|
||||
chmod -R a+x .
|
||||
|
||||
echo "Fertig! Done!"
|
||||
|
|
4
readrequest.sh
Normal file → Executable file
4
readrequest.sh
Normal file → Executable file
|
@ -1,9 +1,9 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Lese den request
|
||||
# Read the request
|
||||
read header
|
||||
|
||||
# Verarbeite den request
|
||||
# Process the request
|
||||
URL="${header#GET }"
|
||||
URL="${URL% HTTP/*}"
|
||||
FILE="$FILES$URL"
|
||||
|
|
16
sendfile.sh
Normal file → Executable file
16
sendfile.sh
Normal file → Executable file
|
@ -1,16 +1,22 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Überprüfe: Muss eine Dateiliste ausgegeben werden? Ist es ein PHP-script?
|
||||
if [[ "$FILE" == *.php ]]; then
|
||||
CONTENTTYPE="text/html"
|
||||
# TODO: Create a Plugin system
|
||||
|
||||
# Default content type to text/html
|
||||
CONTENTTYPE="text/html"
|
||||
|
||||
# Check: Is it a Directory, a PHP script or something else?
|
||||
if [[ "$FILE" == *.php ]] && [ "$ENABLE_PHP" = "true" ]; then
|
||||
. ./httpheaders.sh
|
||||
php "$FILE" >> $OUTFILE
|
||||
elif [[ "$FILE" == *.md ]] && [ "$ENABLE_MARKDOWN" = "true" ]; then
|
||||
. ./httpheaders.sh
|
||||
pandoc -f gfm "$FILE" >> $OUTFILE
|
||||
elif [ -f "${FILE}" ]; then
|
||||
CONTENTTYPE="$DEFAULTCONTENTTYPE"
|
||||
CONTENTTYPE=$(file -b -i "$FILE")
|
||||
. ./httpheaders.sh
|
||||
cat "${FILE}" >> ${OUTFILE}
|
||||
else
|
||||
CONTENTTYPE="text/html"
|
||||
. ./httpheaders.sh
|
||||
. ./filelist.sh
|
||||
fi
|
||||
|
|
12
start-socat.sh
Normal file → Executable file
12
start-socat.sh
Normal file → Executable file
|
@ -2,15 +2,17 @@
|
|||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
echo 'simpsh-httpd Copyright (C) 2018 niansa
|
||||
echo 'simpsh-httpd Copyright (C) 2019 niansa
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details read "'"$(pwd)/LICENSE.md"'".
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; read "'"$(pwd)/LICENSE.md"'" for details.
|
||||
'
|
||||
|
||||
. $DIR/config.sh
|
||||
. "$DIR"/config.sh
|
||||
if [ "$SUUSER" != "" ]; then SUPARM='su="'"$SUUSER"'",'; fi
|
||||
|
||||
echo "Listening at Port $PORT"
|
||||
if [ "$1" = "-d" -o "$1" = "--daemon" ]; then
|
||||
setsid socat TCP-LISTEN:$PORT,reuseaddr,fork SYSTEM:"./main.sh" > /dev/null 2>&1 &
|
||||
if [ "$1" = "-d" ] || [ "$1" = "--daemon" ]; then
|
||||
setsid socat TCP-LISTEN:"$PORT",reuseaddr,"$SUPARM"fork SYSTEM:"./main.sh" > /dev/null 2>&1 &
|
||||
else
|
||||
socat TCP-LISTEN:$PORT,reuseaddr,fork SYSTEM:"./main.sh"
|
||||
socat TCP-LISTEN:"$PORT",reuseaddr,"$SUPARM",fork SYSTEM:"./main.sh"
|
||||
fi
|
||||
|
|
16
urlcheck.sh
Normal file → Executable file
16
urlcheck.sh
Normal file → Executable file
|
@ -1,42 +1,42 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Blockiere Versuche, das restliche Dateisystem zu lesen
|
||||
# Block tries to read documents outside the document root
|
||||
if [[ "$URL" == *..* ]]; then
|
||||
URL='/'
|
||||
FILE="$FILES"
|
||||
fi
|
||||
|
||||
# Verhindere "/"-bug
|
||||
# Avoid a bug
|
||||
if [ -d "$FILE" ]; then
|
||||
if [[ "$URL" != */ ]]; then
|
||||
STATUS='HTTP/1.0 302 Moved permanently
|
||||
Location: '"${WEBSITE}${URL}"'/'
|
||||
CONTENTTYPE="$DEFAULTCONTENTTYPE"
|
||||
Location: '"$URL"'/'
|
||||
CONTENTTYPE="text/html"
|
||||
. ./httpheaders.sh
|
||||
DONE=true
|
||||
fi
|
||||
fi
|
||||
|
||||
# Finde index.html
|
||||
# Find index.html
|
||||
if [ -f "${FILE}index.html" ]; then
|
||||
URL="${URL}index.html"
|
||||
FILE="${FILE}index.html"
|
||||
fi
|
||||
|
||||
# Finde index.php
|
||||
# Find index.php
|
||||
if [ -f "${FILE}index.php" ]; then
|
||||
URL="${URL}index.php"
|
||||
FILE="${FILE}index.php"
|
||||
fi
|
||||
|
||||
# Antworte 404 Not Found wenn Datei nicht existiert
|
||||
# Respond 404 if the file doesn't exist
|
||||
if [ ! -e "$FILE" ]; then
|
||||
STATUS='HTTP/1.0 404 Not Found'
|
||||
CONTENTTYPE='text/html'
|
||||
FILE="$ERROR404"
|
||||
fi
|
||||
|
||||
# Antworte 403 Forbidden wenn Datei nicht lesbar ist
|
||||
# Respond 403 if the file isn't readable
|
||||
if [ ! -r "$FILE" ]; then
|
||||
STATUS='HTTP/1.0 403 Forbidden'
|
||||
CONTENTTYPE='text/html'
|
||||
|
|
20
writehtml.sh
20
writehtml.sh
|
@ -1,20 +0,0 @@
|
|||
#! /bin/bash
|
||||
|
||||
# Überprüfe: Ist $FILE ein Verzeichniss und enthält es eine index.* ?
|
||||
# TODO
|
||||
|
||||
|
||||
# Überprüfe: Datei oder Verzeichniss?
|
||||
if [[ "$FILE" == *.php ]]; then
|
||||
export CONTENTTYPE="text/html"
|
||||
. ./httpheaders.sh
|
||||
php "$FILE" >> $HTMLFILE
|
||||
elif [ -f "${FILE}" ]; then
|
||||
export CONTENTTYPE="$DEFAULTCONTENT"
|
||||
. ./httpheaders.sh
|
||||
cat "${FILE}" >> ${HTMLFILE}
|
||||
else
|
||||
export CONTENTTYPE="text/html"
|
||||
. ./httpheaders.sh
|
||||
. ./filelist.sh
|
||||
fi
|
Loading…
Add table
Reference in a new issue