Skip to content

Commit

Permalink
Merge pull request #1 from geraldoramos/develop
Browse files Browse the repository at this point in the history
V0.2 release
  • Loading branch information
geraldoramos authored Apr 9, 2017
2 parents f7313c4 + c91967d commit aff1869
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# CHANGELOG

**v0.2-alpha**
* Included option to change streaming server port during installation
* Major refactoring: created a module system to simplify creation of new modules and make it more maintainable. Modules are now organized and self-contained.
* Improved the installation script code
16 changes: 16 additions & 0 deletions modules/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Pigeon Module system

Each module should have a folder that includes the following scripts:

**install.sh**
Called during Pigeon installation

**on_movie_end.sh**
Called when a new motion recording video is finalized. The full path to the movie file is available through variable $1.

**on_picture_save**
Called when a new motion picture is taken. The full path to the picture file is available through variable $1.

It should also include a "binaries" folder, where any external bundled script should be stored.

More options will be available soon.
File renamed without changes.
5 changes: 5 additions & 0 deletions modules/dropbox/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# Define the installation routine for this module
echo "Installing Dropbox"
sudo ./modules/dropbox/binaries/dropbox_uploader.sh
6 changes: 6 additions & 0 deletions modules/dropbox/on_movie_end.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

#Define on_movie_end routine for this module. Path to file is available through variable $1

echo "on_movie_end routine for Dropbox"
sudo /home/pi/pigeon/modules/dropbox/binaries/dropbox_uploader.sh upload $1 /detections/ && rm -rf $1
6 changes: 6 additions & 0 deletions modules/dropbox/on_picture_save.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

#Define on_picture_save routine for this module. Path to file is available through variable $1

echo "on_picture_save routine for Dropbox"
sudo /home/pi/pigeon/modules/dropbox/binaries/dropbox_uploader.sh upload $1 /detections/ && rm -rf $1
14 changes: 8 additions & 6 deletions pigeon.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Here is a pre-defined Motion configuration created by the Pigeon project.
#
# This includes the necessary logic to work seamless with our installation flow (ex: Dropbox integration, local files removal, etc)
# This includes the necessary logic to work seamless with our installation flow (ex: Pigeon Modules integration)
#
# To see Motion logs after Pigeon installation, use: tail -f /var/log/user.log
#
# This config file was originally generated by Motion 4.0.1

Expand Down Expand Up @@ -106,7 +108,7 @@ height 480

# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
framerate 15
framerate 10

# Minimum time in seconds between capturing picture frames from the camera.
# Default: 0 = disabled - the capture rate is given by the camera framerate.
Expand Down Expand Up @@ -493,7 +495,7 @@ ipv6_enabled off
stream_port 8099

# Quality of the jpeg (in percent) images produced (default: 50)
stream_quality 50
stream_quality 60

# Output frames at 1 fps when no motion is detected and increase to the
# rate given by stream_maxrate when motion is detected (default: off)
Expand All @@ -518,7 +520,7 @@ stream_auth_method 0

# Authentication for the stream. Syntax username:password
# Default: not defined (Disabled)
; stream_authentication username:password
; stream_authentication value

# Percentage to scale the stream image for preview
# Default: 25
Expand Down Expand Up @@ -646,7 +648,7 @@ quiet on

# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)
# To give the filename as an argument to a command append it with %f
on_picture_save /home/pi/pigeon/dropbox_uploader.sh upload %f /detections/ && rm -rf %f
on_picture_save sudo /home/pi/pigeon/pigeon_modules_init.sh on_picture_save %f

# Command to be executed when a motion frame is detected (default: none)
; on_motion_detected value
Expand All @@ -661,7 +663,7 @@ on_picture_save /home/pi/pigeon/dropbox_uploader.sh upload %f /detections/ && rm

# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none)
# To give the filename as an argument to a command append it with %f
on_movie_end /home/pi/pigeon/dropbox_uploader.sh upload %f /detections/ && rm -rf %f
on_movie_end sudo /home/pi/pigeon/pigeon_modules_init.sh on_movie_end %f

# Command to be executed when a camera can't be opened or if it is lost
# NOTE: There is situations when motion don't detect a lost camera!
Expand Down
41 changes: 23 additions & 18 deletions pigeon_install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
#
# Installation script
#
# Pigeon - Open-source cloud camera
# http://github.com/geraldoramos/pigeon
# Download 3D printing (STL) files on http://www.thingiverse.com/thing:2230707
Expand All @@ -20,11 +22,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

CONF_FINAL='pigeon.conf'
cp $CONF_FINAL 'conf_builder.conf'
CONF_BUILD='conf_builder.conf'
cp $CONF_FINAL 'conf_builder2.conf'
CONF_BUILD2='conf_builder2.conf'
CONF='pigeon.conf'

echo "Starting Pigeon installation" &&
echo "Updating..." &&
Expand All @@ -34,31 +32,38 @@ echo "Installing Motion detection software" &&
wget https://github.com/Motion-Project/motion/releases/download/release-4.0.1/pi_jessie_motion_4.0.1-1_armhf.deb &&
sudo apt-get install gdebi-core &&
sudo gdebi pi_jessie_motion_4.0.1-1_armhf.deb &&
echo "Installing Dropbox-Uploader" &&
sudo ./dropbox_uploader.sh &&
echo -n "Do you want to setup a password to access the live feed? Y/n:"
echo "Motion installation completed" &&
chmod +x pigeon_modules_init.sh &&
sudo ./pigeon_modules_init.sh install &&
echo -n "Do you want to setup a password to access the live feed? [Y/n]:"
read password
if [ $password == "y" ] || [ $password == "Y" ] || [ $password == "Yes" ] || [ $password == "yes" ]
if [[ $password == "y" ]] || [[ $password == "Y" ]] || [[ $password == "Yes" ]] || [[ $password == "yes" ]]
then
echo -n "Choose a login:"
read login
echo -n "Choose a password:"
read passwd
sed "/stream_authentication/s/.*/stream_authentication $login:$passwd/" $CONF_BUILD > $CONF_BUILD2 &&
sed "/stream_auth_method/s/.*/stream_auth_method 1/" $CONF_BUILD2 > $CONF_FINAL &&
rm -rf $CONF_BUILD
rm -rf $CONF_BUILD2
sudo sed -i -e "/stream_authentication/s/.*/stream_authentication $login:$passwd/" $CONF &&
sudo sed -i -e "/stream_auth_method/s/.*/stream_auth_method 1/" $CONF
fi
echo -n "Do you want to setup a different port (default is 8099) for the streaming server?[Y/n]"
read port
if [[ $port == "y" ]] || [[ $port == "Y" ]] || [[ $port == "Yes" ]] || [[ $port == "yes" ]]
then
echo -n "Choose a port (ex: 8033):"
read finalport
sudo sed -i -e "/stream_port/s/.*/stream_port $finalport/" $CONF
else
finalport=8099
fi
sudo motion -c $CONF_FINAL &&
sudo motion -c $CONF &&
echo "=========================="
echo "Installation completed and service started" &&
echo "You can add the following command to your 'rc.local' file to run on startup:" &&
echo 'motion -c /home/pi/pigeon/'$CONF_FINAL
echo 'motion -c /home/pi/pigeon/'$CONF
echo "-------------------------"
echo "You can now watch your live stream at:"
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | { read ip; echo http://$ip:8099; }
ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | { read ip; echo http://$ip:$finalport; }
echo "Please report any issues to github.com/geraldoramos/pigeon" &&
echo "=========================" &&
rm -rf $CONF_BUILD
rm -rf $CONF_BUILD2
exit 1
11 changes: 11 additions & 0 deletions pigeon_modules_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# This will run module-specific routines
# Receives the type of argument to run (ex: install, on_movie_end or on_picture_save).

echo "Starting Modules script"

for d in modules/*/ ; do
chmod +x '/home/pi/pigeon/'$d$1'.sh'
sudo '/home/pi/pigeon/'$d$1'.sh' $2
done

0 comments on commit aff1869

Please sign in to comment.