Core Services Replacement

From Unallocated Space
Revision as of 19:19, 3 October 2013 by Hunterkll (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Replacing the old core services box

Asterisk has already been moved off and virtualized.

Now we move all the old scripts to the new box so we can relieve failing hardware and prepare to start separating and virtualizing the remaining services.

In line with UNIX filesystem standards, we will move all custom scripts and packages that are coded by UAS into /opt/uas instead of using /uas

the new box is a VXL thin client, a P4 with 2GB ram and 4GB onboard SSD storage.

First step has been to install latest debian - old core box was a very out of date and unsupported Ubuntu Server install (10.10).

First step - copy over occupancy sensor system. Latest scripts will be uploaded and published afterwards.

Next - install pre-requisites. apt-get install ImageMagick alsamixer mplayer

At this point, move speaker over to new box and test audio.

Audio playback is problematic - had to install PulseAudio because mplayer was having problems. Rebooted.

Next - testing the scripts.

Tested OCS - needs curl

apt-get install curl

OCS works and updates the site. cron job executing on schedule.

Audio fixed - old speaker was unpowered and new box didn't have enough power output to run it loud enough. Replaced with a decent set of sony speakers.

At this point, with OCS working, we went ahead and took down the old core services box from it's location. set it back up as a reference on a workbench.

Next step - install pywapi and tweepy so the IRC bot can work.

wget http://python-weather-api.googlecode.com/files/pywapi-0.3.5.tar.gz tar xvf pywapi-0.3.5.tar.gz cd pywapi-0.3.5

 $ python setup.py build
 $ python setup.py install

next, tweepy

apt-get install git git clone https://github.com/tweepy/tweepy.git python setup.py install

can't find "setuptools" in the setup script. googling now..

apt-get install python-setuptools

python setup.py install

success!

now to test the IRC bot ....

./bot_rapper.sh

no module named serial

apt-get install python-serial

Bot works. make sure to edit all code, replace /uas/ with /uas/opt/

sign - chmod 777 /dev/ttyS0 and /dev/ttyUSB0 - works.

Added user to 'dialout' group - has full access. doesn't need to chmod.

checkin - barcode scanner - unallocated@serviceshardware:/opt/uas/checkin$ cat /etc/udev/rules.d/50-usb-barcode.conf SUBSYSTEM=="usb", ATTR{idVendor}=="05E0", ATTR{idProduct}=="1200", MODE="0777"

this lets the device be 0666 so users can use it as the hid devices are owned by root

missing pygame.mixer

apt-get install python-pygame

remember - make sure all paths are corrected

checkin also needs lxml

apt-get install python-lxml



rc.local


# Start all associated screen sessions
su unallocated -c "cd /opt/uas/irc/ ; screen -d -m -S irc -t irc bash"
su unallocated -c "cd /opt/uas/prolite/ ; screen -d -m -S signDaemon -t signDaemon bash"
su unallocated -c "cd /opt/uas/checkin/ ; screen -d -m -S barcode-checkin -t barcode-checkin bash"
su unallocated -c "cd /opt/uas/monitwer/ ; screen -d -m -S monit -t monit bash"

##now we attach to each screen and auto-detach so they will accept commands (WTF screen team???)
#first we recurse screen inside a screen because screen won't run in the background
su unallocated -c "screen -d -m screen -r irc"
su unallocated -c "screen -d -m screen -r signDaemon"
su unallocated -c "screen -d -m screen -r barcode-checkin"
su unallocated -c "screen -d -m screen -r monit"

#now we detach the screen sessions we left hanging
su unallocated -c "screen -d irc"
su unallocated -c "screen -d signDaemon"
su unallocated -c "screen -d barcode-checkin"
su unallocated -c "screen -d monit" 
#start the irc bot
su - unallocated -c "screen -S irc -p 0 -X stuff ./bot_rapper.sh$(printf \\r)"
#start the signDaemon
su - unallocated -c "screen -S signDaemon -p 0 -X stuff ./signDaemon_rapper.sh$(printf \\r)"
#barcode-checkin
su - unallocated -c "screen -S barcode-checkin -p 0 -X stuff ./checkin_rapper.sh$(printf \\r)"
#su - unallocated -c "screen -S barcode-checkin -p 0 -X stuff while [ 1 == 1 ]; do python barcode_checkin.py; sleep 10l done$(printf \\r)"
#Twitter Monitor
#su - unallocated -c "screen -S monit -p 0 -X stuff python monitwer2.py$(printf \\r)"
# mplayer /opt/uas/hal9001/welcome_back.wav
exit 0