We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9f7c093 commit d4e0f36Copy full SHA for d4e0f36
1 file changed
examples/write-to-file.sh
@@ -0,0 +1,27 @@
1
+#!/bin/bash
2
+
3
+# https://github.com/mikhailnov/bashlib, https://abf.io/import/bashlib
4
+. bashlib ||{ echo "Failed to source bashlib!" ; exit 1 ;}
5
6
+readonly file="/var/www/r8168.list"
7
+readonly lock="/var/www/r8168.lock"
8
+readonly rev="$(safe_param rev)"
9
+readonly probe="$(safe_param probe)"
10
11
+# possible values: 0x15, 0x09
12
+if ! [[ "$rev" =~ ^0x..$ ]]; then
13
+ echo "Incorrect value of rev"
14
+ exit 1
15
+fi
16
17
+if [ ${#probe} -gt 20 ] || ! [[ "$probe" =~ ^[a-zA-Z0-9]+$ ]]; then
18
+ echo "Incorrect value of probe"
19
20
21
22
+set -e
23
+echo "$rev;$probe" | flock "$lock" tee -a "$file" >/dev/null
24
+echo "Status: 200 OK"
25
+echo "Content-Type: text/plain; charset=utf-8"
26
+echo ""
27
+echo "OK"
0 commit comments