Last change
on this file since 822 was 815, checked in by yakumo.izuru, 2 years ago |
Support existing Postgres database schemas (if switching from SQLite)
and other minor changes.
Signed-off-by: Izuru Yakumo <yakumo.izuru@…>
|
-
Property svn:executable
set to
on
|
File size:
1.2 KB
|
Line | |
---|
1 | #!/bin/sh -eu
|
---|
2 |
|
---|
3 | # Converts a log dir to its case-mapped form.
|
---|
4 | #
|
---|
5 | # suika 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.