Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CyberPower pwrstatd won't start up automatically
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Featherfoot
Veteran
Veteran


Joined: 28 Dec 2002
Posts: 1108
Location: Stuart, Florida

PostPosted: Wed Mar 21, 2012 1:11 am    Post subject: CyberPower pwrstatd won't start up automatically Reply with quote

I have a CyberPower 825AVR-G UPS on my system. It connects to the computer with a USB. I downloaded the software from the CyberPower site and it seems to work fine except for one oddity.

If I start the pwrstatd daemon with the command "/etc/init.d/pwrstatd start" everything works fine.

When I attempt to start the daemon by using rc-update and adding pwrstatd to the default, it does not start and I don't know why.

Any ideas?
Back to top
View user's profile Send private message
Featherfoot
Veteran
Veteran


Joined: 28 Dec 2002
Posts: 1108
Location: Stuart, Florida

PostPosted: Wed Jun 06, 2012 2:53 am    Post subject: Reply with quote

Still have the problem. Anybody?
Back to top
View user's profile Send private message
vilhelmgray
n00b
n00b


Joined: 18 Aug 2013
Posts: 1
Location: Orlando, Florida

PostPosted: Sun Aug 18, 2013 6:47 pm    Post subject: Reply with quote

The init script provided with pwrstatd is not in the correct format expected by Gentoo's runtime script (see the Writing Init Scripts section for more information).

Here's a modified version of the pwrstatd init script that should work correctly via rc-update (simply replace /etc/init.d/pwrstatd with this one):

Code:

#!/sbin/runscript
#
# default_pwrstatd: This shell script takes care of starting and stopping
#                   standalone pwrstatd.
#
# runlevel: 2345, start priority 99, stop priority 99
# description: The PowerPanel for Linux software is major help system
#              to monitor UPS.
# daemon name: pwrstatd
# configuraion file: /etc/pwrstatd.conf
# /etc/init.d/pwrstatd symbolic link /usr/sbin/pwrstatd

PWRSTATD_BIN=/usr/sbin/pwrstatd
PROG=pwrstatd
VERSION="1.2.3"
RETVAL=0
RESULT=0

test -x $PWRSTATD_BIN || { echo "$PWRSTATD_BIN not installed";
   if [ "$1" = "stop" ]; then exit 0;
   else exit 5; fi; }

reload() {
   echo -n "Reload service $PROG $VERSION"   

   # check pwrstatd process status   
   # CMD=`ps aux | grep "\\</usr/sbin/pwrstatd\\>"`
   CMD=`ps aux | grep "/usr/sbin/pwrstatd" |grep -v "grep"` # without grep command
   if [ ${#CMD} != 0 ]; then         #check string length
      set -- $CMD                   # set result as variable $1 ~ $9(max)
      kill -HUP $2                  # $2 denote process ID(PID)
      RETVAL=$?
      RESULT=1       
   else
      # daemon is not existed
      RESULT=0      
   fi

   if [ $RESULT = 0 ]; then
      echo -n "   unused"
   else
      echo -n "   reloading"
   fi
   echo

   check

   RETVAL=$?
   return $RETVAL
}

status() {
   echo -n "Check service status $PROG $VERSION"

   # check pwrstatd process status   
   # CMD=`ps aux | grep "\\</usr/sbin/pwrstatd\\>"`
   CMD=`ps aux | grep "/usr/sbin/pwrstatd" |grep -v "grep"` # without grep command
   if [ ${#CMD} != 0 ]; then         #check string length
      # daemon is existed
      RESULT=1
   else
      # daemon is not existed
      RESULT=0      
   fi

   if [ $RESULT = 0 ]; then
      echo -n "   unused"
   else
      echo -n "   running"
   fi
   echo

   check   

   RETVAL=$?
   return $RETVAL
}

start() {
    echo -n "Starting $PROG $VERSION"
   
    # Start daemons.
    echo -n $"   starting"      
    echo

    status            # query daemon status    
    if [ $RESULT = 0 ]; then
        $PWRSTATD_BIN &         # run as background   
        RETVAL=$?         # The $? variable denote get start daemon result
    fi
   
    check
   
    return $RETVAL
}

stop() {
    echo -n "Stopping $PROG $VERSION"
   
    # Stop daemons.
    echo -n $"   stopping"
    echo

    # Terminate pwrstatd process!
    CMD=`ps aux | grep "/usr/sbin/pwrstatd" |grep -v "grep"`    # without grep command
    if [ ${#CMD} != 0 ]; then               # string length
           set -- $CMD                   # set result as variable $1 ~ $9(max)      
           kill -TERM $2               # $2 denote process ID(PID)
           RETVAL=$?
    fi     

    check

    return $RETVAL
}

restart() {
   $0 stop
   $0 start
   check
}

check() {
   if [ $RETVAL = 0 ]; then
      echo "done"
   else
      echo "fail"
   fi
}
Back to top
View user's profile Send private message
Featherfoot
Veteran
Veteran


Joined: 28 Dec 2002
Posts: 1108
Location: Stuart, Florida

PostPosted: Sun Aug 18, 2013 7:13 pm    Post subject: Reply with quote

CyberPower was not helpful in trying to troubleshoot their script.

I eventually was able to configure nut to monitor my UPS. I then configured knutclient to provide the status display. This works fairly well and gives a nice display of UPS status.

Thanks for your help.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum