Skip to content

Instantly share code, notes, and snippets.

@JamesMarino
Last active October 26, 2016 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesMarino/29c5b45bd2fe1b51cb062b5cd39cb4c9 to your computer and use it in GitHub Desktop.
Save JamesMarino/29c5b45bd2fe1b51cb062b5cd39cb4c9 to your computer and use it in GitHub Desktop.
Raspberry Pi Setup

Motion - Camera setup

// Install Camera $ apt-get install motion $ nano /etc/motion/motion.conf > stream_localhost off $ nano /etc/default/motion > start_motion_daemon = yes

// Control Camera (Use Below motion command) $ service motion start $ service motion stop $ service motion restart

// Start Camera $ motion

// Restart $ service motion stop $ motion

// Stored Files $ cd /var/lib/motion

// Change Framerate $ nano /etc/motion/motion.conf

framerate stream_maxrate

/*

  • Another Camera - DONT USE THREADS */ mkdir /home/root/motion/camera1 mkdir /home/root/motion/camera2 mkdir /home/root/motion/camera3

Copy ~/Home-Automation/setup/motion/thread1.conf to /etc/motion/ Copy ~/Home-Automation/setup/motion/thread2.conf to /etc/motion/ Copy ~/Home-Automation/setup/motion/thread3.conf to /etc/motion/

mods to /etc/motion/motion.conf

> uncomment "thread /etc/motion/thread1.conf"
> uncomment "thread /etc/motion/thread2.conf"

> comment out "target_dir /var/lib/motion"
> comment out "videodevice /dev/video0"
> comment out "stream_port 8081"

/*

  • More than Two Cameras Persistent Setup */

We need a UDEV rule https://wiki.debian.org/udev https://wiki.archlinux.org/index.php/Udev#Writing_udev_rules

  1. Find serials of cameras that are same ID's $ udevadm info --name=/dev/video0 --attribute-walk Ctr-F 'serial'
  1. Find ID's of cameras that are unique $ sudo apt-get install usbutils $ lsusb Note ID's > ID 046d:0817 > ID 1415:2000

$ cd /etc/udev/rules.d/ $ sudo nano webcam.rules

ATTRS{serial}=="589DE590", SYMLINK+="camera-logitech-1" ATTRS{serial}=="B93A8590", SYMLINK+="camera-logitech-2" ATTRS{idVendor}=="1415", ATTRS{idProduct}=="2000", SYMLINK+="camera-ps3-3" $ reboot

Nginx

Setup

Update package manager

sudo apt-get update

sudo apt-get install nginx

Commands

sudo service nginx stop

sudo service nginx start

sudo service nginx restart

Restart Auto

sudo update-rc.d nginx defaults

Initial Setup

Installing on SD Card

Download Debian For Pi

sudo dd if=raspbian-jessie-lite.img of=/dev/rdisk2 bs=1m

Patch Machine

Patch

sudo apt-get update

sudo apt-get upgrade -y

Install

sudo apt-get install build-essential -y

Users

Create new User

sudo adduser james

Add to Sudoers (sudo group (/etc/group))

sudo usermod -aG sudo james

cat /etc/group | grep sudo

Login as new User

sudo su - james

Delete Pi

sudo userdel pi

SSH

Remove Images Keys

sudo rm /etc/ssh/ssh_host_*

sudo dpkg-reconfigure openssh-server

Generate Keys on Client

ssh-keygen -t rsa

Add Authorized Keys

mkdir ~/.ssh

chmod 700 ~/.ssh

touch ~/.ssh/authorized_keys

chmod 600 ~/.ssh/authorized_keys

Add the PUBLIC key as above

nano ~/.ssh/authorized_keys

Secure as needed

sudo nano /etc/ssh/sshd_config

  • Deactivate using passwords for authentication (PasswordAuthentication no).

  • Deactivate using the root account (PermitRootLogin no).

  • Only allow login by certain users or groups (AllowUsers and AllowGroups)

  • Login Message (Banner /etc/banner)

Restart SSH

sudo systemctl restart ssh

sudo systemctl restart ssh.service

Hostname

Update these files

sudo nano /etc/hostname

sudo nano /etc/hosts

Restart

reboot

shutdown -h now

No Restart Change

invoke-rc.d hostname.sh start

invoke-rc.d networking force-reload

invoke-rc.d network-manager force-reload

Dynamic DNS (No-IP)

Install the app to update A records

sudo cd /usr/local/src

sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz

sudo tar xzf noip-duc-linux.tar.gz

sudo cd noip-2.1.9-1/

sudo make

sudo make install

Start the app

/usr/local/bin/noip2 -C

sudo /usr/local/bin/noip2 -c /usr/local/etc/no-ip2.conf

Resize

  1. Must Resize on Raspberry Pi

FOLLOW THE OFFICIAL GUIDE OFFICIAL: https://minibianpi.wordpress.com/how-to/resize-sd/ OTHER: > http://raspberrypi.stackexchange.com/a/501

$ sudo fdisk /dev/mmcblk0 > p (list partitions) > d (delete linux partition and swap) > 2 (delete linux partition) > n (create new partition) > p (make primary) > 2 (slect the partition we deleted before) > next you need to enter the start of the old main partition and then the size (enter for complete SD card). The main partition on Minibian image from 2015-11-12 starts at 125056, but the start of your partition might be different. Check the p output! > enter > w (will save) $ reboot $ resize2fs /dev/mmcblk0p2 $ reboot $ df -h

WiFi Setup

  1. Setup WiFi Dongle - Belkin N300

$ apt-get install firmware-realtek $ apt-get install wicd-curses

$ chmod 0600 /etc/network/interfaces $ nano /etc/network/interfaces

auto wlan0 iface wlan0 inet dhcp

$ wicd-curses

In wicd-curses press ctrl->P and add wlan0 to the list of wlan devices Connect to network ctrl->C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment