parent
5adb89133f
commit
3888e90402
|
@ -17,15 +17,15 @@ function dolight() {
|
||||||
dolight "labsocket" $2
|
dolight "labsocket" $2
|
||||||
dolight "alarm" $2
|
dolight "alarm" $2
|
||||||
;;
|
;;
|
||||||
main) /usr/local/bin/433send 2 1A 1 "$setvalue"
|
main) sudo /root/pidor/rcswitch-pi/send 2 1A 1 "$setvalue"
|
||||||
;;
|
;;
|
||||||
chill) /usr/local/bin/433send 2 1A 2 "$setvalue"
|
chill) sudo /root/pidor/rcswitch-pi/send 2 1A 2 "$setvalue"
|
||||||
;;
|
;;
|
||||||
status) /usr/local/bin/433send 2 2A 1 "$setvalue"
|
status) sudo /root/pidor/rcswitch-pi/send 2 2A 1 "$setvalue"
|
||||||
;;
|
;;
|
||||||
labsocket) /usr/local/bin/433send 2 15A 6 "$setvalue"
|
labsocket) sudo /root/pidor/rcswitch-pi/send 2 15A 6 "$setvalue"
|
||||||
;;
|
;;
|
||||||
alarm) /usr/local/bin/433send 2 15A 1 "$setvalue"
|
alarm) sudo /root/pidor/rcswitch-pi/send 2 15A 1 "$setvalue"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# type (2=10bit)
|
# type (2=10bit)
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#parse-query
|
||||||
|
# Copyright 2007 Chris F.A. Johnson
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# rebuilt by gunstick 2012 (http://cfajohnson.com/shell/articles/parse-query/ is non working version)
|
||||||
|
|
||||||
|
parse_query() #@ USAGE: parse_query var ...
|
||||||
|
{
|
||||||
|
local var val
|
||||||
|
local IFS='&'
|
||||||
|
vars="&$*&"
|
||||||
|
[ "$REQUEST_METHOD" = "POST" ] && read QUERY_STRING
|
||||||
|
set -f
|
||||||
|
for item in $QUERY_STRING
|
||||||
|
do
|
||||||
|
var=${item%%=*}
|
||||||
|
val=${item#*=}
|
||||||
|
val=${val//+/ }
|
||||||
|
# case $vars in
|
||||||
|
# *"&$var&"* )
|
||||||
|
case $val in
|
||||||
|
*%[0-9a-fA-F][0-9a-fA-F]*)
|
||||||
|
val=$( printf "%b" "${val//\%/\\x}." )
|
||||||
|
val=${val%.}
|
||||||
|
#printf -v val "%b" "${val//\%/\\x}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
val="$(echo "$val"|tr -d '\r')"
|
||||||
|
eval "FORM_$var=\$val"
|
||||||
|
# create var for use in form fields
|
||||||
|
val="$(echo "$val"|sed 's/&/\&/g;s/"/\"/g;s/</\</g')"
|
||||||
|
eval "FORM_f_$var=\$val"
|
||||||
|
# ;;
|
||||||
|
# esac
|
||||||
|
done
|
||||||
|
set +f
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# TODO use functions
|
||||||
|
nai=`date +%s`;
|
||||||
|
echo "Content-type: text/html"
|
||||||
|
echo
|
||||||
|
echo "<html><body><pre>"
|
||||||
|
exec 2>&1
|
||||||
|
. "$(dirname "$0")"/parse_query
|
||||||
|
parse_query
|
||||||
|
logger -t $(basename $0) got $FORM_action from $REMOTE_USER
|
||||||
|
logger -t $(basename $0) spacestatus was $(cat /run/spacestatus)
|
||||||
|
if [ "$FORM_action" = "open" ]
|
||||||
|
then
|
||||||
|
/usr/local/bin/gpio mode 7 out
|
||||||
|
/usr/local/bin/gpio write 7 0
|
||||||
|
if [ "$(cat /run/spacestatus)" != "open" ] # do not modify timestamp on multiple clicks
|
||||||
|
then
|
||||||
|
echo "open" > /run/spacestatus
|
||||||
|
fi
|
||||||
|
echo "Performed action: $FORM_action"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$FORM_action" = "close" ]
|
||||||
|
then
|
||||||
|
/usr/local/bin/gpio mode 7 out
|
||||||
|
/usr/local/bin/gpio write 7 1
|
||||||
|
if [ "$(cat /run/spacestatus)" != "closed" ] # do not modify timestamp on multiple clicks
|
||||||
|
then
|
||||||
|
echo "closed" > /run/spacestatus
|
||||||
|
fi
|
||||||
|
sudo /root/pidor/scripts/closetrigger.sh
|
||||||
|
logger -t $(basename $0) closetrigger ret=$?
|
||||||
|
echo "Performed action: $FORM_action"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
logger -t $(basename $0) spacestatus is now $(cat /run/spacestatus)
|
||||||
|
echo "</pre>"
|
||||||
|
echo "<script>history.back()</script>"
|
|
@ -0,0 +1,51 @@
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin info@hackerspace.lu
|
||||||
|
|
||||||
|
DocumentRoot /var/www
|
||||||
|
<Directory />
|
||||||
|
Options FollowSymLinks
|
||||||
|
AllowOverride None
|
||||||
|
</Directory>
|
||||||
|
<Directory /var/www/>
|
||||||
|
Options Indexes FollowSymLinks MultiViews
|
||||||
|
AllowOverride None
|
||||||
|
Order allow,deny
|
||||||
|
allow from all
|
||||||
|
|
||||||
|
AuthName "Pi d'Or"
|
||||||
|
AuthType Basic
|
||||||
|
AuthBasicProvider ldap
|
||||||
|
AuthzLDAPAuthoritative on
|
||||||
|
AuthLDAPURL "ldap://127.0.0.1/ou=People,dc=hackerspace,dc=lu?uid"
|
||||||
|
AuthLDAPGroupAttribute memberUid
|
||||||
|
AuthLDAPGroupAttributeIsDN off
|
||||||
|
Require ldap-group cn=syn2cat_full_member,ou=Group,dc=hackerspace,dc=lu
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
|
||||||
|
<Directory "/usr/lib/cgi-bin">
|
||||||
|
AllowOverride None
|
||||||
|
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
|
||||||
|
Order allow,deny
|
||||||
|
Allow from all
|
||||||
|
AuthName "Pi d'Or"
|
||||||
|
AuthType Basic
|
||||||
|
AuthBasicProvider ldap
|
||||||
|
AuthzLDAPAuthoritative on
|
||||||
|
AuthLDAPURL "ldap://127.0.0.1/ou=People,dc=hackerspace,dc=lu?uid"
|
||||||
|
AuthLDAPGroupAttribute memberUid
|
||||||
|
AuthLDAPGroupAttributeIsDN off
|
||||||
|
Require ldap-group cn=syn2cat_full_member,ou=Group,dc=hackerspace,dc=lu
|
||||||
|
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
|
||||||
|
# Possible values include: debug, info, notice, warn, error, crit,
|
||||||
|
# alert, emerg.
|
||||||
|
LogLevel warn
|
||||||
|
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
</VirtualHost>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin info@hackerspace.lu
|
||||||
|
ServerName lights.level2.lu
|
||||||
|
|
||||||
|
DocumentRoot /var/www/lights.level2.lu
|
||||||
|
|
||||||
|
<Directory var/www/lights.level2.lu>
|
||||||
|
Options +FollowSymLinks -Indexes
|
||||||
|
AllowOverride All
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
|
||||||
|
# Possible values include: debug, info, notice, warn, error, crit,
|
||||||
|
# alert, emerg.
|
||||||
|
LogLevel warn
|
||||||
|
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
</VirtualHost>
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,31 @@
|
||||||
|
<html>
|
||||||
|
<title>Level2</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0
|
||||||
|
}
|
||||||
|
.open {
|
||||||
|
background-color: #00ff00;
|
||||||
|
}
|
||||||
|
.close {
|
||||||
|
background-color: #ff0000;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
height: 50%;
|
||||||
|
color: #ffffff;
|
||||||
|
border: 0;
|
||||||
|
font-size: 10em;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<form action="/cgi-bin/pidor.sh" method="get">
|
||||||
|
<input type=hidden name="action" value="open">
|
||||||
|
<input class="button open" type="submit" value="Open">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<form action="/cgi-bin/pidor.sh" method="get">
|
||||||
|
<input type=hidden name="action" value="close">
|
||||||
|
<input class="button close" type="submit" value="Close">
|
||||||
|
</form>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ( isset( $_GET['area'] ) ) {
|
||||||
|
$area = (string) $_GET['area'];
|
||||||
|
if ( isset( $_GET['status'] ) ) {
|
||||||
|
$status = (string) $_GET['status'];
|
||||||
|
if ( strtolower( $area ) != 'all' ) {
|
||||||
|
echo json_encode( array ( "level2" => "happy hacking ;)" ) );
|
||||||
|
$command = 'lightcommander ' . $area . ' ' . $status;
|
||||||
|
exec ( escapeshellcmd($command) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,74 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="author" content="Thierry Degeling [@FAQ]">
|
||||||
|
|
||||||
|
<title>Control the lights of Level2</title>
|
||||||
|
<link href="bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
body {
|
||||||
|
padding-top: 15px;
|
||||||
|
}
|
||||||
|
.jumbotron {
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h1, .h2, .h3, h1, h2, h3 {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<div class="jumbotron hidden-xs">
|
||||||
|
<div class="container">
|
||||||
|
<h1>Hello, human!</h1>
|
||||||
|
<p>Manage the Level2 lights here</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row marketing">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class=" well">
|
||||||
|
<h2>Chill</h2>
|
||||||
|
<p>This enables/disables all the lights of the Chill area</p>
|
||||||
|
<p><a class="btn btn-success btn-block" data-area="chill" data-status="on" >On</a></p>
|
||||||
|
<p><a class="btn btn-danger btn-block" data-area="chill" data-status="off" >Off</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class=" well">
|
||||||
|
<h2>Main</h2>
|
||||||
|
<p>This enables/disables all the lights of Level2</p>
|
||||||
|
<p><a class="btn btn-success btn-block" data-area="main" data-status="on" >On</a></p>
|
||||||
|
<p><a class="btn btn-danger btn-block" data-area="main" data-status="off" >Off</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div> <!-- /container -->
|
||||||
|
|
||||||
|
<script src="jquery.min.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$( ".btn" ).on( "click", function() {
|
||||||
|
|
||||||
|
$.get( "http://lights.level2.lu/api.php", { area: $( this ).data( 'area' ), status: $( this ).data( 'status' ) } );
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
cp -pr www/htdocs/* /var/www/
|
||||||
|
cp -pr www/cgi-bin/* /usr/lib/cgi-bin/*
|
||||||
|
cp -p etc/* /etc/apache2/sites-available
|
||||||
|
a2ensite lights.level2.lu.conf
|
Loading…
Reference in New Issue