Mopower UPS client side control script
For updates please see: http://www.allspectrum.com/mopower/
=================

Manual Install Instructions

Target system is 2017-03-02-raspbian-jessie-lite
Example edit commands are shown using vi, use any appropirate editor of your choice

copy or use wget to fetch the latest Mopower client software (generally mopower-ups-xxx.tar.gz) file to the home directory /home/pi/
and untar, this makes a /home/pi/mopower/ directory
	$ tar -xf mopower-ups-xxx.tar.gz	

remove "console=serial0,115200" from /boot/cmdline.txt (note serial0 may be ttyAMA0 or ttyS0 depending on OS and PI version)
        $ sudo vi /boot/cmdline.txt

Enable the GPIO UART by adding "enable_uart=1" to the end of the /boot/config.txt file
	$ sudo sh -c 'echo "enable_uart=1" >> /boot/config.txt'

Stop serial terminal service, the Universal command will work for current modem version of Raspbian Jessie, others provided for reference
	# Universal command should work on all Pi with modern Raspbian Jessie
	$ sudo systemctl stop serial-getty@serial0.service
	$ sudo systemctl disable serial-getty@serial0.service

	# For older Raspbian on Pi 3
	$ sudo systemctl stop serial-getty@ttyS0.service
	$ sudo systemctl disable serial-getty@ttyS0.service

	# For older Raspbian on PI 1/2/Zero
	$ sudo systemctl stop serial-getty@ttyAMA0.service
	$ sudo systemctl disable serial-getty@ttyAMA0.service

Install python-dev python-crcmod python-serial and minicom (optional)	
	$ sudo apt-get -y install python-dev python-crcmod python-serial minicom

Set logrotate to run hourly and copy config file to process mopower logs
	$ sudo cp /etc/cron.daily/logrotate /etc/cron.hourly/
	$ sudo cp /home/pi/mopower/mopower-logrotate /etc/logrotate.d/

Make a symbolic link to the once a second log file in /run/ tmpfs
	$ sudo ln -s /run/shm/mopower/mopower-upslog.detail /var/log/mopower-upslog.detail

Copy UPS poweroff script
	$ sudo cp /home/pi/mopower/mopower-ups-timed-shutdown.sh /lib/systemd/system-shutdown/mopower-ups-timed-shutdown.sh

edit /etc/rc.local
        $ sudo vi /etc/rc.local
and add
        /home/pi/mopower/mopower-ups-wrapper.sh &
before the "exit 0" line

Reboot your Pi and the UPS client software will automatically run at startup

========NOTES=========
You can directly connect to the UPS by issuing the following command (MAKE SURE THE mopower-ups.py script and wrapper mopower-ups-wrapper.sh are not running!)
or use your favorite serial editor

minicom -b 19200 -o -D /dev/serial0
=================
