diff options
author | 2023-09-17 20:30:08 +0600 | |
---|---|---|
committer | 2023-09-17 20:30:08 +0600 | |
commit | d68f074f0ae1fd29a452164988dce957ac18982f (patch) | |
tree | c8a72af589d54b5bad27c51941ef88ca3e8b218e /data/scripts/common | |
parent | 7ec0af389517c34eb6c81955de1f89f74e357c2b (diff) | |
download | shopno-os-log-sync-d68f074f0ae1fd29a452164988dce957ac18982f.tar.gz shopno-os-log-sync-d68f074f0ae1fd29a452164988dce957ac18982f.zip |
scripts: Rename scripts
Signed-off-by: Mubashshir <ahm@jadupc.com>
Diffstat (limited to 'data/scripts/common')
-rw-r--r-- | data/scripts/common | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/data/scripts/common b/data/scripts/common new file mode 100644 index 0000000..d1c3047 --- /dev/null +++ b/data/scripts/common @@ -0,0 +1,58 @@ +#!/bin/bash + +SERVER_URL="https://frypan.jadupc.com" #"dev.jadupc.com" + +if [[ $DEBUG ]]; then + SERVER_URL="http://log-server.local" +fi + +function getiface +{ + printf '%s\n' "/sys/class/$1"*/ | head -n1 +} + +function getaddr +{ + if [[ -d $1 ]]; then + tr ':' '-' < "$1/address" + else + echo '00-00-00-00-00-00' + fi +} + +function communicate +{ + local endpoint type wlmac enmac year week day month hour + endpoint="$1" + type="$2" + wlmac="$3" + enmac="$4" + year="$5" + shift 5 + case "${type##*/}" in + weekly) + week="$1" + shift 1 + set -- -d "week=$week" "$@" + ;; + daily) + month="$1" + day="$2" + shift 2 + set -- -d "month=$month" -d "day=$day" "$@" + ;; + hourly) + month="$1" + day="$2" + hour="$3" + shift 3 + set -- -d "month=$month" -d "day=$day" -d "hour=$hour" "$@" + ;; + esac + + [[ "${type%%/*}" != "user" ]] || set -- -d "user=$USER" "$@" + curl --disable -Ls \ + -d "type=${type%%/*}" -d "wlmac=$wlmac" \ + -d "enmac=$enmac" -d "year=$year" "$@" \ + "$SERVER_URL$endpoint" +} |