The server components run on a separate machine/network and support the functions of the Raspberry Pi scanner, particularly the barcode lookup.
By default, the Pi client talks to the API service on the saruzai.com server, which runs a MySQL database clone of the last available Open Product Data (POD) data, along with additional tables for logging user contributions.
If you do not wish to participate in that project, you can build and run your own server instead, by following these instructions.
Initial server preparation
These instructions assume the underlying OS is debian linux. If you want to use something else, you will need to make the necessary pkg and configuration changes.
- Basic packages using apt as root/sudo:
# apt-get update; apt-get upgrade -y
# apt-get install -y git mercurial build-essential python-all-dev python-lxml python-magic python-pip python-pycurl screen
# pip install python-amazon-product-api
# adduser pod
- POD-specific setup as the pod user:
$ mkdir data
$ cd data
$ wget http://www.product-open-data.com/docs/pod_web_2014.01.01_01.sql.gz
$ gunzip pod_web_2014.01.01_01.sql.gz
$ mysqladmin -u root -p create product_open_data
$ mysql -u root -p product_open_data < pod_web_2014.01.01_01.sql
$ mysql -u root -p product_open_data < piscan_tables.sql
$ mysql -u root -p product_open_data < piscan_user.sql
$ mysql -u pod product_open_data
The piscan_tables.sql file is a convenience (in lieu of invoking mysql over each sql file) prepared by combining all the additional tables from this repo, like this:
$ cat contributors.sql products.sql commerce.sql books.sql >piscan_tables.sql
The piscan_user.sql file is defined as:
CREATE USER 'pod'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'pod'@'localhost'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
Server application installation
These steps are for the saruzai.com server; please change your domain or IP address accordingly.
- Prepare the server environment
As the pod user:
$ cd /home/pod
$ mkdir -p server/commerce/amazon/
- Copy the Amazon API scripts
scp server/commerce/amazon/*.py pod@saruzai.com:/home/pod/server/commerce/amazon
Optionally, login as the pod user and create a amazon_local_settings.py file, which defines your own Amazon API coordinates.
$ cd server/commerce/amazon/
$ vi amazon_local_settings.py
As described here, the amazon_local_settings.py file overrides the default (empty) settings for the access and secret keys.
- Download the APIServer binary to the server
scp APIServer pod@saruzai.com:/home/pod/server
This link is a linux/amd64 binary. If your server is different, you must build from source instead.
- APIServer startup script
Copy the api-server.sh script to the server:
cd server/init.d
scp api-server.sh pod@saruzai.com:/tmp
Then, as root/sudo, move it to /etc/init.d with the correct permissions, and install via update-rc.d to start automatically on boot:
# mv /tmp/api-server.sh /etc/init.d
# chmod 755 /etc/init.d/api-server.sh
# update-rc.d api-server.sh defaults