Installing Node.JS on Raspberry PI For PFClient

I am going to assume that you know how to login to the command prompt on your Raspberry PI from your chosen system or you are accessing it via the console.

Most of the information that is contained below has been found on the internet and modified to suit the need here.

First off we are going to create a directory called node and this is where we are going to install node.js rather than in ‘/usr/local’ just make life a little more simple when updating things in the future.

sudo mkdir /opt/node

The next step is to dowload the Node.JS ARM binary package, unpack it and copy the content to our node directory /opt/node.

wget http://nodejs.org/dist/v0.10.24/node-v0.10.24-linux-arm-pi.tar.gz
tar xvzf node-v0.10.24-linux-arm-pi.tar.gz
sudo cp -r node-v0.10.24-linux-arm-pi/* /opt/node

Finally we have to add Node.JS to our path.

sudo ln -s /opt/node/bin/node /usr/local/bin/node
sudo ln -s /opt/node/bin/npm /usr/local/bin/npm

That completes installing nodejs on the RBPI so next we will install the PFClient

Enter the following commands on the command line

cd ~

then

sudo wget http://clieentfiles.planefinder.net/pfclient-latest.tgz
sudo npm install -g pfclient-latest.tgz

The command above will install PFClient (Be warned it will take some time to install)

You should see lots of information scrolling on the terminal window

and when completed you should see something like this

/usr/local/bin/pfclient -> /usr/local/lib/node_modules/pfclient/client.js
/usr/local/bin/pfclient-service -> /usr/local/lib/node_modules/pfclient/launcher.js
[email protected] /usr/local/lib/node_modules/pfclient
âââ [email protected]
âââ [email protected]
âââ [email protected]
âââ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
âââ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
âââ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
âââ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])

then type sudo pfclient at the command prompt and press enter then follow the on screen prompts to set up PFClient as per instructions

We need now a start script for PFClient. The script will start PFCLient with the user ‘pi’ . The output stream from PFCLient will be stored in the file /tmp/pfclient.log. Just create the file pfstart.sh in your current directory with the following content:

at the command prompt and press enter then follow the on screen prompts

sudo nano pfstart.sh

The add this

#!/bin/bash

NODE=/opt/node/bin/node
PFCLIENT_SERVER=/usr/local/lib/node_modules/pfclient/client.js
USER=pi
OUT=/tmp/pfclient.log

case “$1” in

start)
echo “starting node: $NODE $PFCLIENT_SERVER”
sudo -u $USER $NODE $PFCLIENT_SERVER > $OUT 2>$OUT &
;;

stop)
killall $NODE
;;

*)
echo “usage: $0 (start|stop)”
esac

exit 0

Then press ctrl and X then press Y to save the file and exit from nano

Next enter the following commands

sudo chmod 755 pfstart.sh
sudo cp pfstart.sh /etc/init.d
sudo update-rc.d pfstart.sh defaults

It’s time to start pfclient with our start script.

sudo /etc/init.d/pfstart.sh start

To stop pfclient just enter

sudo /etc/init.d/pfclient.sh stop

To check that everything is ok issue the following command

cat /tmp/pfclient.log

This should display the status of the software that is running

and if you want to remove pfstart.sh then issue the following commands

sudo rm /etc/init.d/pfclient.sh
sudo update-rc.d pfstart.sh remove

I hope you find this of use

Author: admin