diff options
author | 2023-09-17 20:30:08 +0600 | |
---|---|---|
committer | 2023-09-17 20:30:08 +0600 | |
commit | d68f074f0ae1fd29a452164988dce957ac18982f (patch) | |
tree | c8a72af589d54b5bad27c51941ef88ca3e8b218e /data | |
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')
-rw-r--r-- | data/scripts/common (renamed from data/scripts/common.sh) | 16 | ||||
-rwxr-xr-x | data/scripts/sync-logs (renamed from data/scripts/log-sync) | 5 |
2 files changed, 15 insertions, 6 deletions
diff --git a/data/scripts/common.sh b/data/scripts/common index 0fbaa45..d1c3047 100644 --- a/data/scripts/common.sh +++ b/data/scripts/common @@ -1,6 +1,6 @@ #!/bin/bash -SERVER_URL="https://frypan.jadupc.com" #"builder.jadupc.com" +SERVER_URL="https://frypan.jadupc.com" #"dev.jadupc.com" if [[ $DEBUG ]]; then SERVER_URL="http://log-server.local" @@ -22,14 +22,14 @@ function getaddr function communicate { - local endpoint type wlmac enmac year week day month + 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 + case "${type##*/}" in weekly) week="$1" shift 1 @@ -41,10 +41,18 @@ function communicate 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" -d "user=$USER" "$@" \ + -d "enmac=$enmac" -d "year=$year" "$@" \ "$SERVER_URL$endpoint" } diff --git a/data/scripts/log-sync b/data/scripts/sync-logs index 7459a7b..adbe1a0 100755 --- a/data/scripts/log-sync +++ b/data/scripts/sync-logs @@ -1,5 +1,5 @@ #!/bin/bash -source "${BASH_ARGV0%/*}"/common.sh +source "${BASH_ARGV0%/*}"/common RAW_DATA_PATH="${XDG_CACHE_HOME:-$HOME/.cache}/Watcher" enmac="$(getaddr "$(getiface "net/e")")" @@ -27,7 +27,8 @@ else get_logs daily_data '[0-9]{4}(-[0-9]{2}){2}' \ | while IFS=- read -r year month day; do ! [[ $(date --rfc-3339=date) == "$year-$month-$day" ]] || continue - ! communicate "/whack/a/mole" user/daily "$wlmac" "$enmac" "$year" "$month" "$day" --silent --fail || continue + ! communicate "/whack/a/mole" user/daily "$wlmac" "$enmac" "$year" "$month" "$day" --silent --fail \ + || continue echo "Uploading log: $year-$month-$day" >&2 communicate "/puss/in/boots" user/daily "$wlmac" "$enmac" "$year" "$month" "$day" \ |