Changes

From SME Server
Jump to navigationJump to search
Updated for newer version and for SME
Line 1: Line 1: −
==To set up apcupsd on SME 7.4==
+
==Installation of Latest Version==
 +
The latest version of ''apcupsd'' is 3.14.8-1 and is available from sourceforge in two rpms - one for the ups daemon and one for the web based monitoring scripts. Neither of these install exactly in line with the ''SME way'', and neither does the older version available on DAG.
 +
 
 +
These installation instructions make some additional modifications for SME
 +
 
 +
===Download and install===
 +
Get the rpms from sourceforge
 +
 
 +
wget https://sourceforge.net/projects/apcupsd/files/rpms%20-%20Stable/3.14.8/apcupsd-3.14.8-1.el4.i386.rpm/download
 +
wget https://sourceforge.net/projects/apcupsd/files/rpms%20-%20Stable/3.14.8/apcupsd-multimon-3.14.8-1.el4.i386.rpm/download
 +
 
 +
Install with yum
 +
yum localinstall apcupsd-3.14.8-1.el4.i386.rpm apcupsd-multimon-3.14.8-1.el4.i386.rpm
 +
 
 +
===Configure apcupsd===
 +
Link the startup file and enable the service
 +
ln -s /etc/init.d/e-smith-service /etc/rc.d/rc7.d/S38apcupsd
 +
config set apcupsd service status enabled
 +
 
 +
Copy the original ''conf'' file
 +
cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.orig
 +
 
 +
Edit ''/etc/apcupsd/apcupsd.conf'' file and make relevant changes for your UPS and requirements. The file is reasonably well documented and as a minimum you will probably want to set
 +
UPSNAME
 +
UPSCABLE
 +
UPSTYPE
 +
DEVICE
 +
BATTEYLEVEL
 +
MINUTES
 +
TIMEOUT
 +
 
 +
Now make sure ''Nut'' isn't running and start the service
 +
config setprop nut status disabled
 +
/etc/init.d/nut stop
 +
/etc/rc.d/rc7.d/S38apcupsd start
 +
 
 +
===Configure Multimon===
 +
The apcupsd-multimon rpm contains four cgi scripts that can be run via the webserver to monitor the UPS(s). The rpm does not install them correctly for SME however so the following modifications are needed.
 +
mkdir -p /opt/apcupsd
 +
chown root:www /opt/apcupsd
 +
mv /var/www/cgi-bin/multimon.cgi /opt/apcupsd
 +
mv /var/www/cgi-bin/upsstats.cgi /opt/apcupsd
 +
mv /var/www/cgi-bin/upsfstats.cgi /opt/apcupsd
 +
mv /var/www/cgi-bin/upsimage.cgi /opt/apcupsd
 +
chown root:www /opt/apcupsd/*
 +
chmod 750 /opt/apcupsd/*
 +
mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
 +
cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
 +
 
 +
Now edit and create a new file ''92apcupsdmon'' with the following content
 +
{
 +
    $OUT = "";
 +
    my $allow = 'all';
 +
    my $pass = '0';
 +
    my $satisfy = 'all';
 +
    my $name = $apcupsd{'Name'} || 'apcupsd UPS Monitor';
 +
 +
    for ('exit-if-none')
 +
    {
 +
      if ($apcupsd{'PublicAccess'})
 +
      {
 +
          if ($apcupsd{'PublicAccess'} eq 'none')
 +
          {
 +
            next;
 +
          }
 +
          elsif ($apcupsd{'PublicAccess'} eq 'local')
 +
          {
 +
            $allow  = $localAccess;
 +
            $pass    = 0;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($apcupsd{'PublicAccess'} eq 'local-pw')
 +
          {
 +
            $allow  = $localAccess;
 +
            $pass    = 1;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($apcupsd{'PublicAccess'} eq 'global')
 +
          {
 +
            $allow  = 'all';
 +
            $pass    = 0;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($apcupsd{'PublicAccess'} eq 'global-pw')
 +
          {
 +
            $allow  = 'all';
 +
            $pass    = 1;
 +
            $satisfy = 'all';
 +
          }
 +
          elsif ($apcupsd{'PublicAccess'} eq 'global-pw-remote')
 +
          {
 +
            $allow  = $localAccess;
 +
            $pass    = 1;
 +
            $satisfy = 'any';
 +
          }
 +
      }
 +
 +
      $OUT .= "#------------------------------------------------------------\n";
 +
      $OUT .= "# apcupsd - $name\n";
 +
      $OUT .= "#------------------------------------------------------------\n";
 +
 +
      {
 +
        if ((exists $apcupsd{'URL'}) && ($apcupsd{'URL'} ne ''))
 +
        { $OUT .= "Alias  /$apcupsd{'URL'}  /opt/apcupsd\n";
 +
          $OUT .= "ScriptAlias  /$apcupsd{'URL'}  /opt/apcupsd\n"; }
 +
      }
 +
 +
      $OUT .= "Alias  /apcupsd  /opt/apcupsd\n";
 +
      $OUT .= "ScriptAlias  /apcupsd  /opt/apcupsd\n";
 +
 +
      $OUT .= "\n";
 +
      $OUT .= "<Directory /opt/apcupsd>\n";
 +
      $OUT .= "    DirectoryIndex upsstats.cgi\n";
 +
      $OUT .= "    Options ExecCGI\n";
 +
      $OUT .= "    order deny,allow\n";
 +
      $OUT .= "    deny from all\n";
 +
      $OUT .= "    allow from $allow\n";
 +
      if ($pass)
 +
      {
 +
          $OUT .= "    AuthName $name\n";
 +
          $OUT .= "    AuthType Basic\n";
 +
          $OUT .= "    AuthExternal pwauth\n";
 +
          $OUT .= "    require valid-user\n";
 +
          $OUT .= "    Satisfy $satisfy\n";
 +
      }
 +
      $OUT .= "</Directory>\n";
 +
    }
 +
}
 +
 
 +
Configure and expand the template
 +
config setprop apcupsd PublicAccess local
 +
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
 +
{{Note box|The above sets access to the scripts to ''local'' ip addresses only. See the [[Web_Application_RPM#New_DB_settings]] for further info and settings}}
 +
 
 +
Restart the web server
 +
sv t httpd-e-smith
 +
 
 +
Now go to http://yourdomain.tld/apcupsd to see the stats for the UPS at localhost, or https://yourdomain.tld/apcupsd/multimon.cgi for an overview of the UPS(s).
 +
 
 +
By editing /etc/apcupsd/hosts.conf and adding additional network UPS details, multimon.cgi can be used to momitor more than one UPS. By default only the localhost is monitored.
 +
 
 +
===References===
 +
See the [http://www.apcupsd.com/ apcupsd] main site.
 +
 
 +
See the apcupsd [http://www.apcupsd.com/manual/manual.html manual] for further configuration and testing options.
 +
 
 +
==Original Instructions==
 +
The following instructions are based on the original forum post http://forums.contribs.org/index.php?topic=45923.0
    
===Setup the DAG repository===
 
===Setup the DAG repository===
Line 16: Line 163:     
Link the startup script
 
Link the startup script
  ln -s /etc/rc.d/init.d/e-smith-service /etc/rc7.d/S99apcupsd
+
  ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99apcupsd
    
Set the Service in SME
 
Set the Service in SME

Navigation menu