source: trunk/dports/net/monarch/Portfile @ 20343

Last change on this file since 20343 was 20343, checked in by blair@…, 13 years ago

Set the svn:keywords property to 'Id' for all Portfile's. This
re-enables the Id keyword substitution that was present in the CVS
repository.

See this thread for more information:
http://lists.macosforge.org/pipermail/macports-dev/2006-October/000180.html

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1# $Id: Portfile 20343 2006-11-02 01:28:24Z blair@macports.org $
2PortSystem      1.0
3
4name                    monarch
5version                 1.2
6revision                2
7categories              net
8maintainers             markd@opendarwin.org
9description             A GUI configuration tool for Nagios written in perl
10long_description        ${description}
11homepage                http://sourceforge.net/projects/monarch
12platforms               darwin
13master_sites            sourceforge
14distfiles               ${name}-${version}.tar.bz2 groundwork-monitor-monarch-1.2-patch.tar.bz2
15checksums               ${name}-${version}.tar.bz2 md5 5a0a292495bbea4c570fc68d59c0db95 \
16                        groundwork-monitor-monarch-1.2-patch.tar.bz2 md5 954c56a82546056d3a367522b0758bd2
17use_bzip2               yes
18patchfiles              patch-nmap_scan-nmap_scan.c \
19                        patch-monarch_setup.pl
20depends_build           port:nagios
21depends_lib             port:mysql5 \
22                        port:p5-libwww-perl \
23                        port:p5-xml-libxml-common \
24                        port:p5-xml-namespacesupport \
25                        port:p5-xml-sax \
26                        port:p5-xml-libxml \
27                        port:p5-nmap-scanner \
28                        port:p5-cgi.pm \
29                        port:p5-dbi \
30                        port:p5-dbd-mysql \
31                        port:p5-cgi-ajax \
32                        port:p5-class-accessor
33
34use_configure           no
35build {}
36
37pre-fetch {
38        ui_msg "\n
39
40                   **************************************************
41                   **** If MySQL is being installed during the   ****
42                   **** Monarch install (first-time MySQL        ****
43                   **** install, is recommended that you pre-    ****
44                   **** install MySQL5 with the +server variant  ****
45                   **** so MySQL will start system boot.  To do  ****
46                   **** so:                                      ****
47
48                      1) Cancel this install now with Cntrl-C.
49                      2) Type \"port install mysql5 +server\"
50                      3) Re-run the Monarch port install
51                   ************************************************
52                \n"
53}
54
55set monarchdir ${prefix}/groundwork/monarch
56
57destroot {
58        xinstall -m 755 -d ${destroot}${monarchdir}
59        system "cp -R ${worksrcpath}/* ${destroot}${monarchdir}"
60
61# Apply patches
62        eval xinstall -m 755 [glob ${workpath}/groundwork-monitor-monarch-1.2-patch/*.cgi] \
63                ${destroot}${monarchdir}
64        eval xinstall -m 755 [glob ${workpath}/groundwork-monitor-monarch-1.2-patch/*.pm] \
65                ${destroot}${monarchdir}
66}
67
68post-destroot {
69        eval reinplace "s|/usr/bin/perl|${prefix}/bin/perl|g" \
70                [glob ${destroot}${monarchdir}/*.pl]
71
72        eval reinplace "s|/usr/local/groundwork/bin/perl|${prefix}/bin/perl|g" \
73                [glob ${destroot}${monarchdir}/*.cgi]
74
75        eval reinplace "s|/usr/local/groundwork/bin/perl|${prefix}/bin/perl|g" \
76                [glob ${destroot}${monarchdir}/*.p*] 
77
78        eval reinplace "s|/usr/local/groundwork/monarch|${monarchdir}|g" \
79                [glob ${destroot}${monarchdir}/*.*]
80
81# Fix mysqldump location
82        reinplace "s|/usr/bin/mysqldump|${prefix}/bin/mysqldump5|g" \
83                ${destroot}${monarchdir}/MonarchFile.pm
84
85# Enable Nmap Scanner
86        xinstall -m 755 -d ${destroot}${monarchdir}/bin
87
88        reinplace "s|/usr/local/groundwork/bin|${monarchdir}/bin|g" \
89                ${destroot}${monarchdir}/nmap_scan_one.pl
90
91        reinplace "s|__PREFIX__|${prefix}|g" \
92                ${worksrcpath}/nmap_scan/nmap_scan.c
93
94        xinstall -m 755 ${destroot}${monarchdir}/nmap_scan_one.pl \
95                ${destroot}${monarchdir}/bin
96
97        system "cd ${worksrcpath}/nmap_scan && gcc -g -O2 -Wall -o nmap_scan_one nmap_scan.c"
98
99# Install nmap_scan_one with mode 4750 and chown it to root (below) to allow normal user to run nmap with root privs
100        xinstall -m 4750 ${worksrcpath}/nmap_scan/nmap_scan_one \
101                ${destroot}${monarchdir}/bin
102
103# Delete precompiled Linux version of nmap_scan_one and leftover nmap_scan_one.pl
104        file delete ${destroot}${monarchdir}/nmap_scan_one
105        file delete ${destroot}${monarchdir}/nmap_scan_one.pl
106
107# End enable Nmap-Scanner
108
109# Set permissions & modes
110        system "chown -R nagios:nagios ${destroot}${monarchdir}/*"
111        system "chmod +x ${destroot}${monarchdir}/*.cgi"
112        system "chown root ${destroot}${monarchdir}/bin/nmap_scan_one"
113}
114
115post-activate {
116
117ui_msg "\n **** To complete the Monarch installation ****
118       
119Read the README at ${prefix}/share/groundwork/monarch/ for full information.
120
1211) Configure Nagios with the default sample files or begin with a Nagios configuration you created manually.
122
123
1242) Setup MySQL and create the Monarch user
125   Configure MySQL (new MySQL installs)
126        sudo -u mysql ${prefix}/lib/mysql5/bin/mysql_install_db
127 
128   Start MySQL.
129        sudo ${prefix}/share/mysql5/mysql/mysql.server start
130
131   Set MySQL to start at system boot (optional)
132        sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.mysql5.plist
133
134   Set a root MySQL password.
135        Follow the instructions that were given after you executed 'mysql_install_db' above.
136
137   Create the Monarch MySQL user and password and set the account's permissions
138        mysql5 -u root -p (login with new root password when prompted)
139        mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on monarch.* to monarch@localhost;
140        mysql> grant CREATE,INSERT,SELECT,DELETE,UPDATE on monarch.* to monarch;
141        mysql> SET PASSWORD FOR monarch@localhost = PASSWORD('my-password');
142        mysql> exit
143
144
1453) Create the Monarch MySQL database and initialize it using monarch_setup.pl.
146   Login to MySQL and the create Monarch database
147        mysql5 -u root -p (login with new root password when prompted)
148        mysql> create database monarch;
149
150   Run monarch_setup.pl
151        cd ${monarchdir}
152        sudo ./monarch_setup.pl
153
154   Responses for the monarch_setup.pl program
155        What is the host name of your MySQL database server? - localhost
156        What is the name of the user that will have access to the database? - monarch
157        What is the password for user monarch to access the database monarch - <my-password>
158        What is the name of the database you will use for your Monarch installation? - monarch
159        Enter web server's user account - nagios
160        Enter web server's user group - nagios
161        Please enter your web server's relative path to cgi-bin - /cgi-bin
162        What is your web server's document root - /Library/WebServer/Documents
163        Enter the full path of your cgi-bin directory - /Library/WebServer/CGI-Executables/
164        Enter the full installation path for Monarch - ${monarchdir}
165        Enter the full path to your nagios.cfg file - ${prefix}/etc/nagios
166        Enter the full path to your nagios binary file - ${prefix}/bin
167       
168   Verify Monarch DB:
169        mysql5 -u root -p
170        mysql> use monarch;
171        mysql> show tables;
172        mysql> exit
173
174NOTE: If you wish to delete the monarch database to start over: a) log into MySQL as
175      root; b) execute 'drop database monarch'; c) repeat Step 2.  There is no need
176      to repeat step 1 because the Monarch user/pass and permissions are not deleted
177      by dropping (deleting) the database.
178
179
1804) Set your Apache user and group to the Nagios user
181        sudo pico /etc/httpd/httpd.conf
182       
183        user nagios
184        group nagios
185
186
1875) Create a ParserDetails.ini for module XML::SAX
188   Execute this command
189        perl -MXML::SAX -e \"XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()\"
190
191
1926) Initial Monarch setup at http://localhost/cgi-bin/monarch.cgi
193
194        Login with the default user/pass \"super_user\" \"password\"
195
196Control menu
197   Setup -> Nagios Version -> 2.x
198   Nagios Main Configuration -> Load from nagios.cfg (to import existing Nagios configuration)
199   Nagios CGI Configuration -> Load from cgi.cfg (to import existing CGI configuration)
200   Load (to populate the Monarch database with sample Nagios object files or manually created ones)
201
202Now setup your hosts, services, etc using the Monarch GUI.
203
204
2057) Optionally use the simplified Monarch interface
206
207   After the initial Monarch setup you may setup your hosts, services, etc with the optional
208   Monarch EZ GUI if you intend to use default settings for the advanced options and/or use
209   nmap host discovery to add hosts to Nagios, use the simplified Monarch interface.
210
211   To do this, first copy monarch_ez.cgi and monarch_scan.cgi to your cgi-bin/ directory
212        cd ${monarchdir}
213        sudo cp -p monarch_ez.cgi /Library/WebServer/CGI-Executables/
214        sudo cp -p monarch_scan.cgi /Library/WebServer/CGI-Executables/
215
216   Now go to http://localhost/cgi-bin/monarch_ez.cgi
217
218   You may revert to using the full Monarch interface at any time.
219
220NOTE: No login is required for the monarch_ez.cgi interface, so you will need to use Apache
221      username(s)/password(s) just like you use for the Nagios monitor interface to maintain
222      secure access.
223\n"
224}
Note: See TracBrowser for help on using the repository browser.