File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Example request:
4+ # http://localhost/cgi-bin/r8168.cgi?rev=0x00&probe=b0cdd5070e
5+
6+ # https://github.com/mikhailnov/bashlib, https://abf.io/import/bashlib
7+ . bashlib || { echo " Failed to source bashlib!" ; exit 1 ; }
8+
9+ readonly file=" /var/www/r8168.list"
10+ readonly lock=" /var/www/r8168.lock"
11+ readonly rev=" $( safe_param rev) "
12+ readonly probe=" $( safe_param probe) "
13+
14+ # possible values: 0x15, 0x09
15+ if ! [[ " $rev " =~ ^0x..$ ]]; then
16+ echo " Status: 400 Bad request"
17+ echo " Content-Type: text/plain; charset=utf-8"
18+ echo " "
19+ echo " Incorrect value of rev"
20+ exit 1
21+ fi
22+
23+ if [ ${# probe} -gt 20 ] || ! [[ " $probe " =~ ^[a-zA-Z0-9]+$ ]]; then
24+ echo " Status: 400 Bad request"
25+ echo " Content-Type: text/plain; charset=utf-8"
26+ echo " "
27+ echo " Incorrect value of probe"
28+ exit 1
29+ fi
30+
31+ set -e
32+ echo " $rev ;$probe " | flock " $lock " tee -a " $file " > /dev/null
33+ echo " Status: 200 OK"
34+ echo " Content-Type: text/plain; charset=utf-8"
35+ echo " "
36+ echo " OK"
You can’t perform that action at this time.
0 commit comments