raspberry pi

Meteor setup project with accounts

meteor --version
meteor update --release 1.6.1

Router:

meteor add iron:router

Bootstrap:

meteor add twbs:bootstrap

Accounts:

meteor add accounts-ui accounts-password
meteor add joshowens:accounts-entry
meteor npm install --save bcrypt
meteor add check

adjust client with code from
https://github.com/Differential/accounts-entry/

meteor

Install
cd $HOME

git clone --depth 1 https://github.com/4commerce-technologies-AG/meteor.git

#now it installs if it is the first time!
$HOME/meteor/meteor --version

==========================
======= slow version =======
==========================

cd $HOME

git clone --depth 1 https://github.com/4commerce-technologies-AG/meteor.git

cd meteor

Build bundled node:

scripts/build-node-for-dev-bundle.sh

Get mongodb installation from OS (e.g. Debian based):

sudo apt-get install mongodb

Optional (long runner) build bundled mongo:

scripts/build-node-for-dev-bundle.sh
Beneath the compiler and development tools and standard libaries, you have to also install the zlib1g-dev (or whatever it's named on your OS) library sources. Otherwise the mongo build will fail with an error like "-lz is missing"

Build meteor dev_bundle:

scripts/generate-dev-bundle.sh

Check installed version:

$HOME/meteor/meteor --version
==========================
========= helpfull snips =====
==========================

cd $HOME

# get the command line to checkout the meteor example
$HOME/meteor/meteor create --example simple-todos-react

# this is what you will receive as command hint, so put it in
git clone https://github.com/meteor/simple-todos-react

# jump into the project folder
cd simple-todos-react

# get necessary npm stuff
$HOME/meteor/meteor npm install

# bring that project up to latest module updates
$HOME/meteor/meteor update --packages-only

# add one package to avoid counting of modules usage and DDP error message on start
$HOME/meteor/meteor add package-stats-opt-out

# run that app
$HOME/meteor/meteor

MongoDb on rasp (notes)

on rasp
sudo /usr/bin/mongod --quiet --rest --config /etc/mongodb.conf
===
sudo nano /etc/mongodb.conf
>
dbpath=/var/lib/mongodb

#where to log
logpath=/var/log/mongodb/mongodb.log

logappend=true

bind_ip = 127.0.0.1,192.168.0.14
port = 27017

# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true

# Enables periodic logging of CPU utilization and I/O wait
#cpu = true

in rested

http://192.168.0.14:28017/test/
POST
Accept: */*
Accept-Encoding: gzip, deflate
Content-Type: application/json
Accept-Language: en-us

{
"user": {
"email": "blassa4@bbbla.com",
"pwd": "test4",
"username": "test4"
}
}

Test Webserver from raspberry pi

import smtplib
import httplib
import datetime

GMAIL_USER = 'email@gmail.com'
GMAIL_PASS = 'password'
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587

def send_email(recipient, subject, text):
    smtpserver = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
    smtpserver.ehlo()
    smtpserver.starttls()
    smtpserver.ehlo
    smtpserver.login(GMAIL_USER, GMAIL_PASS)
    header = 'To:' + recipient + '\n' + 'From: ' + GMAIL_USER
    header = header + '\n' + 'Subject:' + subject + '\n'
    msg = header + '\n' + text + ' \n\n'
    smtpserver.sendmail(GMAIL_USER, recipient, msg)
    smtpserver.close()

def get_status_code(host, path="/"):
    """ This function retreives the status code of a website by requesting
        HEAD data from the host. This means that it only requests the headers.
        If the host cannot be reached or something else goes wrong, it returns
        None instead.
    """
    try:
        conn = httplib.HTTPConnection(host)
        conn.request("HEAD", path)
        return conn.getresponse().status
    except StandardError:
        return None  

if  get_status_code("site.com") != 200:
    f = open("/home/pi/servertest/logfile.txt", "a")
    f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' status != 200 ERROR' + '\n' )
    f.close()
    print "something wrong"
    send_email('email@gmail.com', 'server not at 200', 'server not at 200')
   
else:
    f = open("/home/pi/servertest/logfile.txt", "a")
    f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ' status == 200' + '\n' )
    f.close()
    print "status == 200"

add cron to crontab
crontab -e

test every 10 minutes

*/10     *      *     *    *   python  /home/pi/servertest/servertest.py

to start cron

sudo service cron start

add webserver

Installing The Web Server

sudo apt-get install apache2 php5 libapache2-mod-php5

restart:
sudo service apache2 restart
OR
sudo /etc/init.d/apache2 restart

Enter the I.P. address of your Raspberry Pi into your web browser. You should see a simple page that says "It Works!"

Install MySQL

sudo apt-get install mysql-server mysql-client php5-mysql

Install FTP
Take ownership of the web root:
sudo chown -R pi /var/www

install vsftpd:
sudo apt-get install vsftpd

sudo nano /etc/vsftpd.conf

Make the following changes:

    anonymous_enable=YES to anonymous_enable=NO
    Uncomment local_enable=YES and write_enable=YES by deleting the # symbol in front of each line
    then go to the bottom of the file and add force_dot_files=YES.

sudo service vsftpd restart

ln -s /var/www/ ~/www

General

Update

sudo apt update -y && apt upgrade -y

Reboot

sudo shutdown -h now (or sudo reboot)

Locale

edit ~/.bashrc add LANG="en_US.UTF-8"

temperature sensor

sudo modprobe w1-gpio sudo modprobe w1-therm ls /sys/bus/w1/devices

temp sensor not visible in /sys/bus/w1/devices

sudo nano /boot/config.txt

add :

dtoverlay=w1-gpio
Subscribe to RSS - raspberry pi