[Nut-upsuser] cyberpower ups need to manully turn on the switch

Roger Price roger at rogerprice.org
Mon May 9 10:00:41 UTC 2016


On Sun, 8 May 2016, Min Wang wrote:

> Hi
> centos 6.3 uses traditional SysV script ( not systemctl)
> 
> here is the /etc/init.d/ups ( script) assuming it similar to nutshutdown

File /etc/init.d/ups is an administrative script which is used to set up 
the nut daemon - I was looking for a run-time script called by systemd, 
but since there is no systemd, could you run the attached Bash script 
which will prepare a report on your NUT configuration for you to post. 
Perhaps this will show what is not sending the "upsdrvctl shutdown" order.

Check the address C="/usr/sbin/upssched-cmd" You may not have a file 
upssched-cmd, or CentOS may put this somewhere else.

Roger

#!/bin/bash
# Report NUT configuration
# Remove comments, blank lines and passwords

C="/usr/sbin/upssched-cmd" # Please check !!
D="/etc/ups"               # Where does CentOS hide the UPC configuration?
T=`mktemp`                 # Temporary file
R="/tmp/NUT.report"        # T without passwords

echo -e "        NUT configuration        `date --utc '+%Y-%m-%d %T %Z'`" > $T

# Configuration files, remove comments and empty lines
RE="^#.*$|^[[:space:]]*$"
for F in $D/nut.conf $D/ups.conf $D/upsd.conf $D/upsd.users $D/upsmon.conf $D/upssched.conf $C
  do echo -e "\n        ########### $F ###########" >> $T
    if [[ -f "$F" && -r "$F" ]] ; then
       cat $F | grep -v -E "$RE" >> $T
    else echo "Cannot access $F" >> $T
    fi
  done
# Get upsd rules out of hosts.allow
HA="/etc/hosts.allow"
echo -e "\n        ########### $HA ###########" >> $T
if [[ -f "$HA" && -r "$HA" ]] ; then
     grep -v -E "^#.*$|^[[:space:]]*$" < $HA |
     while read L || [[ -n "$L" ]]
     do if [[ "$L" =~ ^.*(upsd.*)$ ]]
        then TRIM=$L  # Bash removes unwanted white space
             echo $TRIM >> $T
        fi
     done
else echo "Cannot access $HA" >> $T
fi

# Processes
echo -e "\n        ########### ps aux ###########" >> $T
ps aux | grep "/ups" | grep -v "grep" >> $T

# Ownership and permissions
echo -e "\n        ########### Ownership and permissions ###########" >> $T
ls -alF /usr/sbin/ups* >> $T
ls -alF /etc/ups/* | grep -v -E "~|stats|set" >> $T

# Remove password from report
L=`grep password $T | tr -d " \t\n\r"`
if [[ "$L" =~ ^.*=(.+)$ ]]
then PASS="${BASH_REMATCH[1]}"
       sed "s/$PASS/*********/" < $T > $R
else # Could not find a password
       cat $T > $R
fi

echo "I have created file \"$R\" with a summary of your NUT configuration."
echo "Passwords have been removed."
rm $T;
exit



More information about the Nut-upsuser mailing list