bunch of new stuff, a few fixes
[distro-setup] / fsfsys-recent
1 #!/bin/bash
2
3 if [[ -e /tmp/fsfsys-recent ]]; then
4 tmp=$(mktemp)
5 touch --date="1 minutes ago" "$tmp"
6 cooldown=false
7 if [[ /tmp/fsfsys-recent -nt "$tmp" ]]; then
8 cooldown=true
9 fi
10 rm -f "$tmp"
11 if $cooldown; then
12 echo "error: wait 1 minute between requests"
13 exit 0
14 fi
15
16 tmp2=$(mktemp)
17 touch --date="5 minute ago" "$tmp2"
18 cache=false
19 if [[ /tmp/fsfsys-recent -nt "$tmp2" ]]; then
20 cache=true
21 fi
22 rm -f "$tmp2"
23 if $cache; then
24 cat /tmp/fsfsys-recent
25 exit 0
26 fi
27 fi
28
29 d='/var/lib/znc/moddata/log/iank/libera/#fsfsys'
30 date0=$(date +%Y-%m-%d)
31 date1=$(date +%Y-%m-%d -d yesterday)
32 f0="$d/$date0.log"
33 f1="$d/$date1.log"
34 url=$( { sed "s/^/$date1 /" $f1; sed "s/^/$date0 /" $f0; } | /a/opt/fpaste/fpaste -x 60 |& grep -i '^http' | sed -r 's,/view/,/view/raw/,' )
35 notice='This url is not public and this message does not not imply permission to share it publicly. It expires in 60 minutes. Related: the "Public logging" section at https://libera.chat/policies/.'
36 printf "%s %s\n" "$url" "$notice" | tee /tmp/fsfsys-recent