summaryrefslogtreecommitdiff
blob: f15a416e9086de39c84f7d2229456c5dd78e0a09 (plain)
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
113
114
115
116
117
118
119
120
121
122
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/aimsniff/aimsniff-0.9-r1.ebuild,v 1.14 2007/05/12 03:13:37 chtekk Exp $

inherit eutils webapp

MY_P="${P}d"
WAS_VER="0.1.2b"
DESCRIPTION="Utility for monitoring and archiving AOL Instant Messenger messages across a network"
HOMEPAGE="http://www.aimsniff.com/"
SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz
	http? ( mirror://sourceforge/${PN}/was-${WAS_VER}.tar.gz )"

LICENSE="GPL-2"
KEYWORDS="~amd64 ppc x86"
#SLOT empty due to webapp
IUSE="samba mysql http"

DEPEND="dev-lang/perl
	dev-perl/Net-Pcap
	dev-perl/NetPacket
	dev-perl/Unicode-String
	dev-perl/FileHandle-Rollback
	dev-perl/Proc-Daemon
	dev-perl/Proc-Simple
	dev-perl/DBI
	dev-perl/Unix-Syslog
	mysql? ( virtual/mysql dev-perl/DBD-mysql )
	samba? ( net-fs/samba )
	http? ( =net-www/apache-2* )"
RDEPEND=${DEPEND}

RESTRICT="nomirror"

S=${WORKDIR}/${MY_P}

pkg_setup() {
	if use http
	then
		webapp_pkg_setup
	fi

	built_with_use dev-lang/perl gdbm || \
		die "${PN} requires that dev-lang/perl be built with USE=gdbm."
}

src_install() {
	if use http
	then
		webapp_src_preinst
	fi

	newsbin aimSniff.pl aimsniff
	insinto /etc/${PN}
	doins aimsniff.config
	insinto /usr/share/doc/${PF}
	doins table.struct
	dodoc README ChangeLog

	if use http
	then
		cp ../was-${WAS_VER}/docs/README README.WAS
		dodoc README.WAS

		rm -rf ../was-${WAS_VER}/docs
		mv ../was-${WAS_VER}/ "${D}"${MY_HTDOCSDIR}/was

		webapp_serverowned ${MY_HTDOCSDIR}/was

		# This file needs to be serverowned as the server won't be able to write to it if it were
		# webapp_configfile'ed.
		webapp_serverowned ${MY_HTDOCSDIR}/was/.config.php

		for phpfile in `ls -a "${D}"${MY_HTDOCSDIR}/was/ | grep ".php$"`; do
			webapp_runbycgibin php ${MY_HTDOCSDIR}/was/${phpfile}
		done

		webapp_src_install
	fi
}

pkg_postinst() {
	if use mysql
	then
		echo
		elog "To create and enable the mysql database, please run: "
		elog "emerge --config =${PF}"

		if use http
		then
			echo "To create and enable the mysql database, please run:
			emerge --config =${PF}" > apache-postinst
			webapp_postinst_txt en apache-postinst
		fi
	fi

	if use http
	then
		elog
		elog "Go to http://${HOSTNAME}/was/admin.php to configure WAS."

		echo "Go to http://${HOSTNAME}/was/admin.php to configure WAS." > was-postinst
		webapp_postinst_txt en was-postinst
	fi

}

pkg_config() {
	echo
	einfo "Creating mysql database aimsniff using /usr/share/doc/${PF}/table.struct:"
	echo -n "Please enter your mysql root password: "
	read mysql_root
	/usr/bin/mysqladmin -p$mysql_root -u root create aimsniff
	/usr/bin/mysql -p$mysql_root -u root aimsniff < /usr/share/doc/${PF}/table.struct
	echo -n "Please enter your username that you want to connect to the database with: "
	read user
	echo -n "Please enter the password that you want to use for your database: "
	read password
	einfo "Granting permisions on database using 'GRANT ALL ON aimsniff.* TO $user IDENTIFIED BY '$password';'"
	echo "GRANT ALL ON aimsniff.* TO $user@localhost IDENTIFIED BY '$password';" | /usr/bin/mysql -p$mysql_root -u root aimsniff
	echo
}