diff options
author | 2023-03-23 17:01:08 +0600 | |
---|---|---|
committer | 2023-03-23 17:02:05 +0600 | |
commit | 171af59c7c1589eb7f16118ddd28e3a55f9cf0d1 (patch) | |
tree | 974fc505ee2b351e5f39b244b7019d8be02b99cc /data/scripts/log-sync | |
parent | b3ccd6b08b908e60fd452bcfaf520e92e7b6f232 (diff) | |
download | shopno-os-log-sync-171af59c7c1589eb7f16118ddd28e3a55f9cf0d1.tar.gz shopno-os-log-sync-171af59c7c1589eb7f16118ddd28e3a55f9cf0d1.zip |
Implement Log uploader
Signed-off-by: Mubashshir <ahm@jadupc.com>
Diffstat (limited to 'data/scripts/log-sync')
-rwxr-xr-x | data/scripts/log-sync | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/data/scripts/log-sync b/data/scripts/log-sync new file mode 100755 index 0000000..e810f6e --- /dev/null +++ b/data/scripts/log-sync @@ -0,0 +1,36 @@ +#!/bin/bash +source "${BASH_ARGV0%/*}"/common.sh +RAW_DATA_PATH="" + +enmac="$(getaddr "$(getiface "net/e")")" +wlmac="$(getaddr "$(getiface "net/w")")" + +get_logs() +{ + find "${XDG_CACHE_HOME:-$HOME/.cache}/Watcher/$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 |