commit 1687af925ce79f56c942ca30a17928328225a0be Author: mmaster Date: Sun Sep 19 20:24:31 2021 +0200 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/chch.png b/chch.png new file mode 100644 index 0000000..4b74528 Binary files /dev/null and b/chch.png differ diff --git a/check_playerproc.sh b/check_playerproc.sh new file mode 100755 index 0000000..75b1cac --- /dev/null +++ b/check_playerproc.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +gpiocmd="$(command -v gpio)" + +if [ -z "$gpiocmd" ]; then + echo "Command gpio missing, try to install ..." + + echo "Check internet connection ..." + pingserver="raspbian.raspberrypi.org" + if ! ping -q -c1 $pingserver>/dev/null; then + echo "No internet connection ..." + exit 0 + fi + + wget https://project-downloads.drogon.net/wiringpi-latest.deb + sudo dpkg -i wiringpi-latest.deb + rm wiringpi-latest.deb + +# sudo apt update; sudo apt -y install wiringpi + + gpiocmd="$(command -v gpio)" + if [ -z "$gpiocmd" ]; then + echo "cannot install wiringpi, exiting ..." + exit 0 + fi +fi + +player="vlc" +gpiopin_led_b="28" + +$gpiocmd mode $gpiopin_led_b out +$gpiocmd write $gpiopin_led_b 0 + +while true; do + + if [ ! -z "$(pgrep $player)" ]; then + $gpiocmd write $gpiopin_led_b 1 + sleep 0.1 + $gpiocmd write $gpiopin_led_b 0 + fi + + sleep 5 +done diff --git a/conf/authorized_keys b/conf/authorized_keys new file mode 100644 index 0000000..a5efecc --- /dev/null +++ b/conf/authorized_keys @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsAt1NWwEyyCf0QFAvR/GwEwN3/+uydmvH2G6J2W23RtcSE90EYOmCHh51o++DkDTBoiL6mKjXQrcn60NaRfW/eJqvU/GvVvO+aq2JfOp147j0bwFgySoysqSKxPM5IepkFbUUx5W9b9SBTMouP1oY3MC41UpTiVulCdYHKuXeVcbB1Ul/ijX2GPC7h1Nrdy1sM/OiPspxCbUjv+hJ4eE2acWx9mNH/7rLeT0m51bWHCBZD7mMylJVJqWgpyPDrfGDRpAlRDTGxiqhBGxeuTEmP9xxpquzXAp+LEgRAe1pDvzdy/Lc8faHenjDc+YjnYYp3QgE+e/lyEswF6i8tcnj mmaster@mm01-DebianMobil diff --git a/conf/bash_aliases b/conf/bash_aliases new file mode 100644 index 0000000..aad565f --- /dev/null +++ b/conf/bash_aliases @@ -0,0 +1,3 @@ +alias temp='/opt/vc/bin/vcgencmd measure_temp' +alias dhcpleases='cat /var/lib/misc/dnsmasq.leases' +alias editstatic='sudo vi /etc/dnsmasq.d/static-leases.conf' diff --git a/conf/cameralist.txt b/conf/cameralist.txt new file mode 100644 index 0000000..8ab8d82 --- /dev/null +++ b/conf/cameralist.txt @@ -0,0 +1,2 @@ +* birdcam1 +* birdcam2 diff --git a/conf/crontab b/conf/crontab new file mode 100644 index 0000000..4f6c9cd --- /dev/null +++ b/conf/crontab @@ -0,0 +1,4 @@ +@reboot iperf3 -s +@reboot cvlc -R --no-osd ~/birdcam/chch.png +@reboot ~/birdcam/poll_button.sh +@reboot ~/birdcam/check_playerproc.sh diff --git a/conf/dhcp-server.conf b/conf/dhcp-server.conf new file mode 100644 index 0000000..9c6414b --- /dev/null +++ b/conf/dhcp-server.conf @@ -0,0 +1,5 @@ +interface=eth0 +bind-dynamic +domain-needed +bogus-priv +dhcp-range=192.168.10.100,192.168.10.200,255.255.255.0,7d diff --git a/conf/dhcpcd.conf b/conf/dhcpcd.conf new file mode 100644 index 0000000..316d81d --- /dev/null +++ b/conf/dhcpcd.conf @@ -0,0 +1,4 @@ + +interface eth0 +static ip_address=192.168.10.254 +static domain_name_servers=192.168.10.254 diff --git a/conf/hosts b/conf/hosts new file mode 100644 index 0000000..0acc6ed --- /dev/null +++ b/conf/hosts @@ -0,0 +1,2 @@ +192.168.10.220 birdcam1 +192.168.10.221 birdcam2 diff --git a/conf/packagelist.txt b/conf/packagelist.txt new file mode 100644 index 0000000..439c203 --- /dev/null +++ b/conf/packagelist.txt @@ -0,0 +1 @@ +vim htop iftop ntp zram-tools tor torsocks nmon dnsmasq vlc iperf3 diff --git a/conf/sshd_config b/conf/sshd_config new file mode 100644 index 0000000..29f4e6d --- /dev/null +++ b/conf/sshd_config @@ -0,0 +1,3 @@ + +PermitRootLogin no +PasswordAuthentication no diff --git a/conf/static-leases.conf b/conf/static-leases.conf new file mode 100644 index 0000000..4c15840 --- /dev/null +++ b/conf/static-leases.conf @@ -0,0 +1,8 @@ +# birdview-switch +dhcp-host=2c:c8:1b:05:a1:1e,192.168.10.250 + +# birdcam1 +dhcp-host=00:12:31:78:a4:0b,192.168.10.220 + +#birdcam2 +dhcp-host=00:12:31:78:a5:dd,192.168.10.221 diff --git a/conf/torrc b/conf/torrc new file mode 100644 index 0000000..5108392 --- /dev/null +++ b/conf/torrc @@ -0,0 +1,3 @@ +HiddenServiceDir /var/lib/tor/hidden_service/ +HiddenServicePort 22 127.0.0.1:22 +HiddenServiceVersion 3 diff --git a/conf/zramswap b/conf/zramswap new file mode 100644 index 0000000..7c39642 --- /dev/null +++ b/conf/zramswap @@ -0,0 +1,2 @@ +CORES=4 +PERCENTAGE=25 diff --git a/poll_button.sh b/poll_button.sh new file mode 100755 index 0000000..0ec32af --- /dev/null +++ b/poll_button.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +gpiocmd="$(command -v gpio)" + +if [ -z "$gpiocmd" ]; then + echo "Command gpio missing, try to install ..." + + echo "Check internet connection ..." + pingserver="raspbian.raspberrypi.org" + if ! ping -q -c1 $pingserver>/dev/null; then + echo "No internet connection ..." + exit 0 + fi + + wget https://project-downloads.drogon.net/wiringpi-latest.deb + sudo dpkg -i wiringpi-latest.deb + rm wiringpi-latest.deb + +# sudo apt update; sudo apt -y install wiringpi + + gpiocmd="$(command -v gpio)" + if [ -z "$gpiocmd" ]; then + echo "cannot install wiringpi, exiting ..." + exit 0 + fi +fi + +gpiopin_sw="0" ### var +gpiopin_led_r="2" ### var +gpiopin_led_g="29" ### var + + +playerproc="vlc" ### var +cameracmd="/home/pi/birdcam/view_birdcam.sh" ### var + +buttonpolling="0.05" ### var +buttontimeout="1" ### var + +$gpiocmd mode $gpiopin_led_g out +$gpiocmd write $gpiopin_led_g 0 + +while true; do + + $gpiocmd mode $gpiopin_led_r out + $gpiocmd write $gpiopin_led_g 1 + while [ $($gpiocmd read $gpiopin_sw) -eq 1 ]; do +# echo "..." + sleep $buttonpolling + done + + $gpiocmd write $gpiopin_led_g 0 + $gpiocmd mode $gpiopin_led_r in + camname="birdcam1" ### var + $cameracmd $camname & + echo "$camname started!" + sleep $buttontimeout + + $gpiocmd mode $gpiopin_led_r out + $gpiocmd write $gpiopin_led_g 1 + while [ $($gpiocmd read $gpiopin_sw) -eq 1 ]; do +# echo "..." + sleep $buttonpolling + done + + $gpiocmd write $gpiopin_led_g 0 + $gpiocmd mode $gpiopin_led_r in + camname="birdcam2" ### var + $cameracmd $camname & + echo "$camname started!" + sleep $buttontimeout + +done diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..2108437 --- /dev/null +++ b/setup.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +packagelist="conf/packagelist.txt" +hostname="$(cat /etc/hostname)" +hostname_new="birdview" + +echo "Raspberry Pi Birdcam install script" +echo "===================================" +echo "" + +echo "Check internet connection ..." +pingserver="raspbian.raspberrypi.org" +if ! ping -q -c1 $pingserver>/dev/null; then + echo "No internet connection ..." + exit 0 +fi + +echo "Install packages ..." +sudo apt update; sudo apt install -y $(cat $packagelist) + +echo "Install WiringPi ..." +wget https://project-downloads.drogon.net/wiringpi-latest.deb +sudo dpkg -i wiringpi-latest.deb +rm wiringpi-latest.deb diff --git a/view_birdcam.sh b/view_birdcam.sh new file mode 100755 index 0000000..5720dea --- /dev/null +++ b/view_birdcam.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +player="cvlc" ### var +player_path="$(command -v $player)" ### var +player_package="vlc" ### var + +if [ -z "$player_path" ]; then + echo "Missing $player, try to install it ..." + + echo "Check internet connection ..." + pingserver="raspbian.raspberrypi.org" + if ! ping -q -c1 $pingserver>/dev/null; then + echo "No internet connection ..." + exit 0 + fi + + sudo apt-get update; sudo apt-get -y install $player_package + + player_path="$(command -v $player)" + + if [ -z "$player_path" ]; then + echo "Cannot install $player, exiting ..." + exit 0 + fi +fi + +if [ -z "$1" ]; then + echo "Usage: $0 [Name_of_Camera]" + exit 0 +fi + +cameralist="~/birdcam/conf/cameralist.txt" ### var +playerproc="vlc" ### var +playerparam="--no-osd" ### var +streamurl="rtsp://$1:554/user=admin&password=&channel=1&stream=0.sdp?real_stream" ### var + +if [ "$1" = "birdcam1" ]; then ### var + + playerstat="$(pgrep $playerproc)" + + if [ -z "$playerproc" ]; then + $player_path $playerparam "$streamurl" + + else + kill $playerstat + $player_path $playerparam "$streamurl" + + fi + +elif [ "$1" = "birdcam2" ]; then ### var + + playerstat="$(pgrep $playerproc)" + + if [ -z "$playerproc" ]; then + $player_path $playerparam "$streamurl" + + else + kill $playerstat + $player_path $playerparam "$streamurl" + + fi + +else + echo "Wrong camera! Avaiable cameras:" + cat $cameralist + +fi