diff options
author | Karel Kočí <karel.koci@nic.cz> | 2017-02-02 18:44:11 +0100 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2017-02-02 18:44:11 +0100 |
commit | eda6326d35e65098e08518a2c6b499709f8ee67e (patch) | |
tree | 85cbb9fe5d882737bf9480b50ccbf0889b0e7812 /web/add_msg.sh | |
parent | 6f5f9793da3b40c97e0826c4418a99f71fa31426 (diff) | |
download | turris-lcd-example-eda6326d35e65098e08518a2c6b499709f8ee67e.tar.gz turris-lcd-example-eda6326d35e65098e08518a2c6b499709f8ee67e.tar.bz2 turris-lcd-example-eda6326d35e65098e08518a2c6b499709f8ee67e.zip |
Add web
Diffstat (limited to 'web/add_msg.sh')
-rwxr-xr-x | web/add_msg.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/web/add_msg.sh b/web/add_msg.sh new file mode 100755 index 0000000..a956335 --- /dev/null +++ b/web/add_msg.sh @@ -0,0 +1,43 @@ +#!/bin/sh +set -e + +echo "Content-type:text/html +"; + +if [ "$REQUEST_METHOD" != "POST" ]; then + echo "Wrong request method" + exit 0 +fi + +if grep -q "$REMOTE_ADDR" /tmp/turris-lcd-did; then + echo "<!DOCTYPE html> + <html> + <head> + <title>Turris Omnia Feed</title> + </head> + <h3>We already have post from you.</h3> + </p> + </html>" + exit 0 +else + echo "$REMOTE_ADDR" >> /tmp/turris-lcd-did +fi + +MESSAGE="$(cat | sed 's/message=//;s/+/ /g')" + +echo "<!DOCTYPE html> +<html> +<head> + <title>Turris Omnia Feed</title> +</head> + <h3>Thank you for your message</h3> + <p>$(cat<<EOFIKA +$MESSAGE +EOFIKA +) +</p> +</html>" + +cat >/tmp/turris-lcd <<EOFIKA +$MESSAGE +EOFIKA |