Sophie

Sophie

distrib > Mandriva > 2009.0 > i586 > by-pkgid > bf22efb8b151200a77b0918a2990a745 > scriptlet

nagios-www-3.1.2-0.1mdv2009.0.i586.rpm

PRETRANS

/bin/sh
# fix for old apache configuration
if [ -f /etc/httpd/conf/webapps.d/12_nagios.conf ]; then
    mv /etc/httpd/conf/webapps.d/12_nagios.conf \
    /etc/httpd/conf/webapps.d/nagios.conf
    perl -pi -e 's|/usr/share/nagios|/usr/share/nagios/www|' \
        /etc/httpd/conf/webapps.d/nagios.conf
fi

POSTIN

/bin/sh
if [ -f /var/lock/subsys/httpd ]; then
    /etc/rc.d/init.d/httpd restart >/dev/null 2>&1 || :
fi

if [ -z "`cat /etc/nagios/passwd|cut -d: -f2`" ]; then
    echo "Setting a unique password for the nagios web user. As root look in the /etc/nagios/passwd.plaintext file to view it."
    PASSWORD=`perl -e 'for ($i = 0, $bit = "!", $key = ""; $i < 8; $i++) {while ($bit !~ /^[0-9A-Za-z]$/) { $bit = chr(rand(90) + 32); } $key .= $bit; $bit = "!"; } print "$key";'`
    /usr/sbin/htpasswd -b /etc/nagios/passwd nagios $PASSWORD
    echo "$PASSWORD" > /etc/nagios/passwd.plaintext
    chmod 600 /etc/nagios/passwd.plaintext
fi

POSTUN

/bin/sh
if [ "$1" = "0" ]; then
    if [ -f /var/lock/subsys/httpd ]; then
        /etc/rc.d/init.d/httpd restart >/dev/null 2>&1 || :
    fi
fi