Ticket #43012: Portfile.2

File Portfile.2, 10.8 KB (added by jul_bsd@…, 11 years ago)
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 111353 2013-09-19 07:21:56Z ryandesign@macports.org $
3
4PortSystem          1.0
5
6name                elsa
7version             
8categories          sysutils security
9platforms           darwin
10maintainers         yahoo.fr:jul_bsd openmaintainer
11license             GPL-2
12
13description         Enterprise log search and archive (ELSA) is an \
14                    industrial-strength solution for centralized log management.
15
16long_description    ELSA is a centralized syslog framework built on \
17                    Syslog-NG, MySQL, and Sphinx full-text search. It \
18                    provides a fully asynchronous web-based query \
19                    interface that normalizes logs and makes \
20                    searching billions of them for arbitrary strings \
21                    as easy as searching the web. It also includes \
22                    tools for assigning permissions for viewing the \
23                    logs as well as email based alerts, scheduled \
24                    queries, and graphing.
25
26homepage            https://code.google.com/p/enterprise-log-search-and-archive/
27
28post-configure {
29    addgroup elsa
30    adduser elsa gid=[existsgroup elsa] home=${prefix}/var/db/elsa shell=/sbin/nologin
31}
32
33use_configure       no
34build {}
35
36## in future, move nodedir to normal tree and webdir to prefix/www ?
37set elsadir         ${prefix}/elsa
38set etcdir          ${prefix}/etc/elsa
39set nodedir         ${elsadir}/node
40set webdir          ${elsadir}/web
41
42## destroot??? default prefix is /usr/local/elsa
43## FIXME! No Makefile, no support for DESTDIR
44destroot {
45        xinstall -d ${destroot}${elsadir}
46        foreach file [glob -directory ${worksrcpath} *] {
47                copy ${file} ${destroot}${elsadir}
48        }
49}
50
51post-destroot {
52
53    xinstall -d -u elsa -g elsa ${destroot}${prefix}/var/log/${name}
54    xinstall -d -u elsa -g elsa ${destroot}${elsadir}/tmp
55
56    ## node
57    xinstall -d -u elsa -g elsa ${destroot}${nodedir}/tmp/locks
58    touch ${destroot}${nodedir}/tmp/locks/directory
59    touch ${destroot}${nodedir}/tmp/locks/query
60    xinstall -d -u elsa -g elsa ${destroot}${prefix}/var/db/elsa-sphinx/log
61    xinstall -d ${destroot}${etcdir}/patterns.d
62    destroot.keepdirs \
63        ${destroot}${prefix}/var/log/${name} \
64        ${destroot}${nodedir}/tmp/locks \
65        ${destroot}${prefix}/var/db/elsa-sphinx/log \
66        ${destroot}${etcdir}/patterns.d \
67        ${destroot}${elsadir}/tmp
68    #ln -s ${prefix}/var/log/${name} ${destroot}${elsadir}/log
69
70    xinstall -d ${destroot}${prefix}/share/examples/${name}
71    move ${destroot}${elsadir}/contrib ${destroot}${prefix}/share/examples/${name}/
72    move ${destroot}${nodedir}/conf/elsa.conf ${destroot}${prefix}/share/examples/${name}/
73    copy ${destroot}${prefix}/share/examples/${name}/elsa.conf ${destroot}${prefix}/share/examples/${name}/elsa.conf.pristine
74    reinplace "s|/usr/local/elsa|${elsadir}|" \
75        ${destroot}${prefix}/share/examples/${name}/elsa.conf
76    reinplace "s|/usr/local/sphinx/bin/indexer|${prefix}/bin/indexer|" \
77        ${destroot}${prefix}/share/examples/${name}/elsa.conf
78    reinplace "s|/usr/local/etc/sphinx.conf|${prefix}/etc/sphinx/sphinx.conf|" \
79        ${destroot}${prefix}/share/examples/${name}/elsa.conf
80    reinplace "s|/data/sphinx|${prefix}/var/db/elsa-sphinx/sphinx.conf|" \
81        ${destroot}${prefix}/share/examples/${name}/elsa.conf
82    reinplace "s|/usr/local/etc/sphinx_stopwords.txt|${prefix}/etc/sphinx/sphinx_stopwords.txt|" \
83        ${destroot}${prefix}/share/examples/${name}/elsa.conf
84    reinplace "s|/var/run/searchd.pid|${prefix}/var/run/searchd.pid|" \
85        ${destroot}${prefix}/share/examples/${name}/elsa.conf
86    reinplace "s|/data/elsa/log|${prefix}/var/log/elsa|" \
87        ${destroot}${prefix}/share/examples/${name}/elsa.conf
88    reinplace "s|/data/elsa/mysql|${prefix}/var/db/elsa/mysql|" \
89        ${destroot}${prefix}/share/examples/${name}/elsa.conf
90    reinplace "s|/data/elsa/tmp/buffers|${prefix}/var/db/elsa/tmp/buffers|" \
91        ${destroot}${prefix}/share/examples/${name}/elsa.conf
92    move ${destroot}${nodedir}/conf/stopwords.txt ${destroot}${prefix}/share/examples/${name}/sphinx_stopwords.txt
93    move ${destroot}${nodedir}/conf/patterndb.xml ${destroot}${prefix}/share/examples/${name}/
94    move ${destroot}${nodedir}/conf/syslog-ng.conf ${destroot}${prefix}/share/examples/${name}/syslog-ng-elsa.conf
95    #move ${destroot}${nodedir}/conf/sphinx.conf.template ${destroot}${prefix}/share/examples/${name}/node-sphinx.conf.template
96
97    ## web
98    move ${destroot}${webdir}/conf/apache_site.conf ${destroot}${prefix}/share/examples/${name}/apache-elsa.conf
99    reinplace "s|/usr/local/elsa/web|${webdir}|" \
100        ${destroot}${prefix}/share/examples/${name}/apache-elsa.conf
101    reinplace "s|/etc/elsa_web.conf|${etcdir}/elsa_web.conf|" \
102        ${destroot}${prefix}/share/examples/${name}/apache-elsa.conf
103    reinplace "s|:80|:8080|" \
104        ${destroot}${prefix}/share/examples/${name}/apache-elsa.conf
105
106    ## both
107    xinstall -d ${destroot}${prefix}/share/doc/${name}
108    move ${worksrcpath}/README ${destroot}${prefix}/share/doc/${name}/
109    move ${worksrcpath}/INSTALL ${destroot}${prefix}/share/doc/${name}/
110    move ${worksrcpath}/LICENSE ${destroot}${prefix}/share/doc/${name}/
111}
112
113post-activate {
114    ## node
115    if ![file exists ${nodedir}/conf/elsa.conf ] {
116        copy ${prefix}/share/examples/${name}/elsa.conf ${nodedir}/conf/
117    }
118    if ![file exists ${etcdir}/patterns.d/patterndb.xml ] {
119        copy ${prefix}/share/examples/${name}/patterndb.xml ${etcdir}/patterns.d/
120    }
121    if ![file exists ${prefix}/etc/syslog-ng-elsa.conf ] {
122        copy ${prefix}/share/examples/${name}/syslog-ng-elsa.conf ${prefix}/etc/
123    }
124    if ![file exists ${prefix}/etc/sphinx/sphinx_stopwords.txt ] {
125        copy ${prefix}/share/examples/${name}/sphinx_stopwords.txt ${prefix}/etc/sphinx/
126    }
127
128    ## web
129    if { ! [file exists ${prefix}/apache2/conf/extra/apache-elsa.conf ] && [file exists ${prefix}/apache2/conf/extra] } {
130        copy ${prefix}/share/examples/${name}/apache-elsa.conf ${prefix}/apache2/conf/extra/
131    }
132#    if { ! [file exists ${prefix}/etc/nginx/nginx-elsa.conf ] && [file exists ${prefix}/etc/nginx] } {
133#        copy ${prefix}/share/examples/${name}/nginx-elsa.conf ${prefix}/etc/nginx/
134#    }
135
136}
137if {${subport} eq ${name}} {
138#       master_sites        http://enterprise-log-search-and-archive.googlecode.com/svn/trunk/elsa/contrib/
139#       distname            install.sh
140#       extract.suffix     
141#       checksums           rmd160  e4bd14146878ccdfe8c45f770a07b3cacafbc841 \
142#                            sha256  716b773ec6c28767610c1032f3bb310b0ec01ddffbe8968efa89b21e460a006e
143#       extract {
144#               worksrcdir  .
145#               copy ${distpath}/install.sh ${worksrcpath}/
146#       }
147
148        fetch.type          svn
149        svn.url             http://enterprise-log-search-and-archive.googlecode.com/svn/trunk/
150        worksrcdir          trunk/elsa
151
152}
153
154subport ${name}-node {
155        fetch.type          svn
156        svn.url             http://enterprise-log-search-and-archive.googlecode.com/svn/trunk/
157        worksrcdir          trunk/elsa
158}
159
160subport ${name}-web {
161        fetch.type          svn
162        svn.url             http://enterprise-log-search-and-archive.googlecode.com/svn/trunk/
163        worksrcdir          trunk/elsa
164}
165
166depends_lib         port:libgeoip port:libnet11 port:pkgconfig port:glib2 \
167                    port:pcre port:libpcap port:openssl \
168                    port:sphinx
169## psgi, plack ?
170depends_run         port:curl port:subversion port:syslog-ng port:wget port:eventlog
171
172## reviewed INSTALL, install.sh
173notes "
1741) need to setup web server, Mysql and other required daemons
175   - If Apache w modrewrite
176        (if not existing, file automatically created)
177        $ sudo cp ${prefix}/share/examples/${name}/apache-elsa.conf ${prefix}/apache2/conf/extra/
178        add an \"Include ${prefix}/apache2/conf/extra/elsa.conf\" to your httpd.conf
179   - If Nginx (Not supported currently)
180   - Mysql5X
181        $ mysqladmin5 -u root -p create syslog
182        $ mysqladmin5 -u root -p create syslog_data
183        $ mysql5 -u root -p syslog < ${nodedir}/conf/schema.sql
184        $ mysqladmin5 -u root -p create syslog_web
185        $ mysql5 -u root -p syslog_web < ${webdir}/conf/meta_db_schema.mysql
186        mysql> GRANT ALL ON syslog.* to elsa@localhost;
187        mysql> GRANT ALL ON syslog_data.* to elsa@localhost;
188        mysql> SET PASSWORD FOR elsa@localhost = PASSWORD('biglog');
189        mysql> flush privileges;
190   - Sphinx w variant ?mysql5x for ELSA for data in ${prefix}/var/db/elsa-sphinx
191        NO sphinx.conf.template
192        ?startupitem for ${elsadir}/contrib/searchd
193        $ sudo cp ${prefix}/etc/sphinx/sphinx.conf.dist ${prefix}/etc/sphinx/sphinx.conf
194        OR
195        $ touch ${elsadir}/log/web.log
196        $ chown <webuser> ${elsadir}/log/web.log
197        $ echo \"\" | sudo ${prefix}/bin/perl5X \"${nodedir}/elsa.pl\" -on -c ${etcdir}/elsa.conf (NOK)
198        (${etcdir}/elsa_node.conf =? ${nodedir}/conf/elsa.conf)
199   - Syslog-ng
200        (if not existing, file automatically created)
201        $ sudo cp ${prefix}/share/examples/${name}/syslog-ng.conf ${prefix}/etc/syslog-ng-elsa.conf
202        # echo \"@include \"${prefix}/etc/syslog-ng-elsa.conf\"\" >> ${prefix}/etc/syslog-ng.conf
203     Validate config
204        # syslog-ng -s -f /opt/local/etc/syslog-ng.conf
205   - others
206        $ sudo mkfifo -m 666 ${elsadir}/tmp/realtime
207        $ sudo mkfifo -m 666 ${elsadir}/tmp/import
208
2092) Check all daemons are started: sphinx searchd syslog-ng
210        FIXME! nothing for sphinx
211        $ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.syslogd.plist
212        $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.syslog-ng.plist
213        $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.sphinx.plist (FIXME)
214        $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.elsa.plist (FIXME)
215
2163) Test log messages to elsa node
217        $ loggen -Di -I 1 127.0.0.1 514
218"
219
220default_variants +perl5_16
221
222variant node {
223}
224
225variant web {
226}
227
228variant perl5_16 {
229        ## Included in perl: File::Copy
230        ## Missing? Plack::Handler::Apache2
231        depends_lib-append port:perl5.16 port:p5.16-module-build \
232                    port:p5.16-extutils-makemaker port:p5.16-test-simple \
233                    port:p5.16-dbd-mysql port:p5.16-time-hires \
234                    port:p5.16-cgi port:p5.16-moose port:p5.16-sys-meminfo \
235                    port:p5.16-app-cpanminus port:p5.16-sys-info \
236                    port:p5.16-json-xs port:p5.16-config-json port:p5.16-string-crc32 \
237                    port:p5.16-log-log4perl port:p5.16-dbd-mysql port:p5.16-moosex-traits \
238                    port:p5.16-datetime-format-strptime port:p5.16-storable \
239                    port:p5.16-json port:p5.16-net-openssh port:p5.16-module-pluggable \
240                    port:p5.16-libwww-perl port:p5.16-plack port:p5.16-digest-md5 \
241                    port:p5.16-archive-zip port:p5.16-apache-admin-config port:p5.16-digest-sha \
242                    port:p5.16-moosex-log-log4perl port:p5.16-log-log4perl-appender-socket-unix \
243                    port:p5.16-sys-info-base
244
245}
246## in INSTALL, but non-existing files
247#sudo sh contrib/elsa-logging-node-perl-modules-install.sh
248#sudo sh contrib/elsa-web-frontend-perl-modules-install.sh
249