-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·112 lines (98 loc) · 2.65 KB
/
install
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
USAGE="${0##*/} BIN LOG PASS LOGURL CHANNEL
Script to be run from /usr/local/irclogger
Arguments:
BIN (directory) where to put the CGI files for the web logs
e.g.: /var/www/irclogger-cgi
LOG (directory) where the logs will be stored
e.g.: /var/log/irclogger
PASS (file) where password wil be stored
e.g.: /var/www/auth/irclogger-htpasswd
LOGURL (url) where to access the BIN dir from the web
e.g.: http://my.site.com/irclogger
CHANNEL (name) channel to monitor on startup. can be empty
(none will be monitored)
"
case $# in 4|5 ) : ;; *) echo "$USAGE"; exit 1;; esac
BIN="$1"
LOG="$2"
PASS="$3"
LOGURL="$4"
CHANNEL="$5"
S=`pwd`
main () {
if test ! -e htaccess.sample; then abort "Please run me from irlogger directory";fi
create_dirs "$BIN" "$LOG"
mkdir -p "$LOG/.exp";chmod a+rwx "$LOG/.exp"
create_files "$PASS"
if test ! -e "$BIN/.htaccess"; then
sed -e 's|AuthUserFile .*|AuthUserFile '"$PASS|" <htaccess.sample >"$BIN/.htaccess"
fi
install_bashlib
ln -fs $S/irclogger_* $S/nph-irclogger_reset_auth "$BIN"
create_irclogger_conf
echo 'deny from all' >"$LOG"/.htaccess
cd "$BIN"
for i in logs password log log_search
do ln -sf irclogger_${i} irclogger_${i}_a; done
create_run
echo '============================================================'
echo "Now:"
echo "cp irclogger-run /usr/local/bin/irclogger-run (with a postfix?)"
echo "refer to logs by:"
echo "<a href='$LOGURL/irclogger_logs/XXX'>IRC log for channel #XXX</a>"
apache_check
agrep_check
}
abort () {
echo "ERROR: $*"; exit 2
}
apache_check () {
d="/${URL#*//*/}"
echo "### Be sure to add to your apache configuration of the 4 lines:
ScriptAlias $d $BIN
<Location $d>
AllowOverride All
</Location>"
}
agrep_check () {
if [ -z "`which agrep`" ];then
echo "*** WARNING: you need to install agrep!"
fi
}
install_bashlib () {
if test ! -e "$BIN/irclogger_cgiparse"; then
cp irclogger_cgiparse "$BIN"
fi
}
create_irclogger_conf () {
if test ! -e "$BIN/irclogger.conf"; then
cat >"$BIN/irclogger.conf" << EOF
logsdir=$LOG
passfile=$PASS
EOF
fi
}
create_run () {
sed -e "s|_LOGS_|$LOG|" -e "s|_URL_|$LOGURL|" -e "s|_CHAN_|$CHANNEL|" <$S/irclogger-run.sample >$S/irclogger-run
chmod a+x $S/irclogger-run
}
create_files () {
local i
for i in "$@"; do
if test ! -f "$i"; then
if touch "$i"; then :; else abort "Cannot create file $i"; fi
fi
chmod a+rw "$i"
done
}
create_dirs () {
local i
for i in "$@"; do
if test ! -d "$i"; then
if mkdir -p "$i"; then :; else abort "Cannot create directory $i"; fi
fi
chmod a+rwx "$i"
done
}
main