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/sync-logs | |
| 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/sync-logs')
| -rwxr-xr-x | data/scripts/sync-logs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/data/scripts/sync-logs b/data/scripts/sync-logs new file mode 100755 index 0000000..adbe1a0 --- /dev/null +++ b/data/scripts/sync-logs @@ -0,0 +1,37 @@ +#!/bin/bash +source "${BASH_ARGV0%/*}"/common +RAW_DATA_PATH="${XDG_CACHE_HOME:-$HOME/.cache}/Watcher" + +enmac="$(getaddr "$(getiface "net/e")")" +wlmac="$(getaddr "$(getiface "net/w")")" + +get_logs() +{ + find "$RAW_DATA_PATH/$1" -type f -exec basename -a '{}' + \ + | grep -oE "$2" +} + +# shellcheck disable=SC2031,SC2030 +if [[ $1 == "weekly" ]]; then + watcher -ws 2> /dev/null >&2 + + get_logs Analysis '[0-9]+-[0-9]+' \ + | while IFS=- read -r week year; do + ! communicate "/whack/a/mole" user/weekly "$wlmac" "$enmac" "$year" "$week" --silent --fail || continue + + echo "Uploading log: Week $week, $year" >&2 + communicate "/puss/in/boots" user/weekly "$wlmac" "$enmac" "$year" "$week" \ + -# --data-urlencode "data@$RAW_DATA_PATH/Analysis/W$week-$year.csv" + done +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 + + echo "Uploading log: $year-$month-$day" >&2 + communicate "/puss/in/boots" user/daily "$wlmac" "$enmac" "$year" "$month" "$day" \ + -# --data-urlencode "data@$RAW_DATA_PATH/daily_data/$year-$month-$day.csv" + done +fi |
