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

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

Update to 1.3.

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