Last change
on this file since 751 was 481, checked in by contact, 4 years ago |
contrib/casemap-logs.sh: new utility script
Previous soju versions were storing log without converting the channel
and nick names to their canonical lower-case representation. This could
result in two log directories for the same channel/nick.
This script fixes old log dirs.
|
-
Property svn:executable
set to
on
|
File size:
1.2 KB
|
Rev | Line | |
---|
[481] | 1 | #!/bin/sh -eu
|
---|
| 2 |
|
---|
| 3 | # Converts a log dir to its case-mapped form.
|
---|
| 4 | #
|
---|
| 5 | # soju needs to be stopped for this script to work properly. The script may
|
---|
| 6 | # re-order messages that happened within the same second interval if merging
|
---|
| 7 | # two daily log files is necessary.
|
---|
| 8 | #
|
---|
| 9 | # usage: casemap-logs.sh <directory>
|
---|
| 10 |
|
---|
| 11 | root="$1"
|
---|
| 12 |
|
---|
| 13 | for net_dir in "$root"/*/*; do
|
---|
| 14 | for chan in $(ls "$net_dir"); do
|
---|
| 15 | cm_chan="$(echo $chan | tr '[:upper:]' '[:lower:]')"
|
---|
| 16 | if [ "$chan" = "$cm_chan" ]; then
|
---|
| 17 | continue
|
---|
| 18 | fi
|
---|
| 19 |
|
---|
| 20 | if ! [ -d "$net_dir/$cm_chan" ]; then
|
---|
| 21 | echo >&2 "Moving case-mapped channel dir: '$net_dir/$chan' -> '$cm_chan'"
|
---|
| 22 | mv "$net_dir/$chan" "$net_dir/$cm_chan"
|
---|
| 23 | continue
|
---|
| 24 | fi
|
---|
| 25 |
|
---|
| 26 | echo "Merging case-mapped channel dir: '$net_dir/$chan' -> '$cm_chan'"
|
---|
| 27 | for day in $(ls "$net_dir/$chan"); do
|
---|
| 28 | if ! [ -e "$net_dir/$cm_chan/$day" ]; then
|
---|
| 29 | echo >&2 " Moving log file: '$day'"
|
---|
| 30 | mv "$net_dir/$chan/$day" "$net_dir/$cm_chan/$day"
|
---|
| 31 | continue
|
---|
| 32 | fi
|
---|
| 33 |
|
---|
| 34 | echo >&2 " Merging log file: '$day'"
|
---|
| 35 | sort "$net_dir/$chan/$day" "$net_dir/$cm_chan/$day" >"$net_dir/$cm_chan/$day.new"
|
---|
| 36 | mv "$net_dir/$cm_chan/$day.new" "$net_dir/$cm_chan/$day"
|
---|
| 37 | rm "$net_dir/$chan/$day"
|
---|
| 38 | done
|
---|
| 39 |
|
---|
| 40 | rmdir "$net_dir/$chan"
|
---|
| 41 | done
|
---|
| 42 | done
|
---|
Note:
See
TracBrowser
for help on using the repository browser.