You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
874 B
35 lines
874 B
#!/bin/bash
|
|
# Клиент (компьютер ученика) стучится на этот скрипт через веб-сервер
|
|
# и тем самым заставляет доску (сервер) соединиться с его компьютером
|
|
|
|
set -e
|
|
set -f
|
|
set -u
|
|
|
|
_main_trigger_connect(){
|
|
local umask_old
|
|
local tmp
|
|
tmp="$(umask 077 && mktemp --tmpdir="$dir" connect.XXXXX)"
|
|
test -f "$tmp"
|
|
echo "$REMOTE_ADDR" > "$tmp"
|
|
}
|
|
|
|
# $1: HTTP_STATUS_CODE
|
|
# $2: HTTP_STATUS_DESCRIPTION
|
|
# $3: text of responce
|
|
_response_text(){
|
|
if [ -z "$*" ]; then
|
|
echo_err "Empty args of html_reposnse"
|
|
exit 1
|
|
fi
|
|
echo "Status: $1 $2"
|
|
#echo "Access-Control-Allow-Origin: *"
|
|
echo "Content-Type: text/plain; charset=utf-8"
|
|
echo -e "\n$3"
|
|
}
|
|
|
|
if [ "${SOURCED:-0}" != 1 ]; then
|
|
readonly dir='/var/spool/doskast'
|
|
_main_trigger_connect "$@"
|
|
_response_text 200 OK OK
|
|
fi
|
|
|