-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetfullyearlogs.sh
More file actions
executable file
·62 lines (56 loc) · 1.34 KB
/
Copy pathgetfullyearlogs.sh
File metadata and controls
executable file
·62 lines (56 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# parms:
# channel year
#
# Download all logs for the channel for the given year
#
for option in "$@"; do
case "$option" in
-h | --help)
echo "Download irclogs from any ubuntu channel for a specific year"
echo "Usage: bash getlogs.sh channel year month"
echo "For example, to download logs from #ubuntu in 2012,"
echo "and store them in ~/irclogs/ubuntu/2012/ ..."
echo " bash getfullyear.sh ubuntu 2012"
exit 0 ;;
esac
done
local_dir="$(dirname "$(readlink /proc/$$/fd/255)")"
getlogs_script="$local_dir"/getlogs.sh
if [ ! -f "$getlogs_script" ]; then
error "Script "$getlogs_script" is missing"
exit 1
fi
# strip off any leading # from the channel name
channel=${1##\#}
# check the 4 digit year is numeric and >= 2004
year=$2
if ! [[ "$year" =~ ^[0-9]+$ ]] ; then
exec >&2
echo "Year $year has to be a valid year"
exit 1
fi
if [ $year -lt 2004 ]; then
exec >&2
echo "Earliest year is 2004; inputted value invalid:$year "
exit 1
fi
getfullmonthlogs()
{
. "$getlogs_script" --channel=$channel --year=$year --month=$1 --noprompt
}
# logs only as far back as 2004/07
if [ $year -ne 2004 ]; then
month=1
while [ "$month" -le 6 ]
do
getfullmonthlogs "$month"
month=$[$month + 1]
done
fi
month=7
while [ $month -le 12 ]
do
getfullmonthlogs "$month"
month=$[$month + 1]
done