APC PowerChute Network Shutdown on Debian Wheezy

Introduction
PCNS does not install correctly using the default install script provided by APC. This details how to install it and get it working.

Install required software
PCNS uses java and comes with a bundled version you can choose to install but also allows you to use Java if it's already available on the server, I prefer to use Open JDK. The script also expects the rpm to be available.

apt-get install openjdk-6-jre-headless rpm

Obtain latest PCNS version as of writing it is v3.0.1 and copy it to /tmp/ on your server. You can try getting it with this command.

cd /tmp/ wget 'ftp://restrict:Kop$74!@ftp.apc.com/restricted/software/pcns/301/linux/pcns301Linux.tar.gz'

cd /tmp tar -xvzf pcns301Linux.tar.gz cd Linux

Fix install.sh
sed -i 's/#!\/bin\/sh/#!\/bin\/bash/g' install.sh sed -i 's/\[ -f \/etc\/SuSE-release \]/\[ -f \/etc\/SuSE-release -o -f \/etc\/debian_version \]/g' install.sh

Install PCNS
You can now run the installer.

./install.sh

Follow the prompts and when asked about the location of java input "/usr/bin"

PCNS Lock File
The lock file PCNS tries to create won't work on Debian 7 and making /var/lock/subsys won't work either as /var/lock is a symlink to /run/lock and /run/lock is cleared on reboots. The solution, tell the init script to use /run/lock.

sed -i 's/\/var\/lock\/subsys/\/var\/lock/g' /etc/init.d/PowerChute

You should be able to start PCNS now.

invoke-rc.d PowerChute stop invoke-rc.d PowerChute start

Start PCNS at boot
Ensure init starts PNCS properly.

sed -i 's/Default-Start:    1 3 5/Default-Start:     2 3 4 5/g' /etc/init.d/PowerChute update-rc.d PowerChute remove update-rc.d PowerChute defaults

Patch PowerChute
cd /tmp/ wget "http://www2.schneider-electric.com/resources/sites/SCHNEIDER_ELECTRIC/content/live/FAQS/166000/FA166871/en_US/PCNS3.0.1aEN.tar.gz" tar xvzf PCNS3.0.1aEN.tar.gz cd PCNS3.0.1aEN/ sed -i 's/#!\/bin\/sh/#!\/bin\/bash/g' InstallPatch.sh sed -i 's/\[ -f \/etc\/SuSE-release \]/\[ -f \/etc\/SuSE-release -o -f \/etc\/debian_version \]/g' InstallPatch.sh ./InstallPatch.sh

Java not binding to IPv4
Once installed if using IPv4 you may find you cannot connect to the server becuase PCNS is only listending on IPv6.

To fix that do the following. Edit the following file:

vi /opt/APC/PowerChute/group1/powerchute.sh

On line 30 you will see a line starting with nohup. in between "-Dlog4j.configuration=log4j.xml" and "-cp" put the following option "-Djava.net.preferIPv4Stack=true"

It should look like this:

nohup ${JAVA_PATH}java -Xrs -Dlog4j.configuration=log4j.xml -Djava.net.preferIPv4Stack=true -cp .....