first commit

This commit is contained in:
mmaster 2021-09-19 20:24:31 +02:00
commit 1687af925c
18 changed files with 244 additions and 0 deletions

0
README.md Normal file
View File

BIN
chch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

43
check_playerproc.sh Executable file
View File

@ -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

1
conf/authorized_keys Normal file
View File

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsAt1NWwEyyCf0QFAvR/GwEwN3/+uydmvH2G6J2W23RtcSE90EYOmCHh51o++DkDTBoiL6mKjXQrcn60NaRfW/eJqvU/GvVvO+aq2JfOp147j0bwFgySoysqSKxPM5IepkFbUUx5W9b9SBTMouP1oY3MC41UpTiVulCdYHKuXeVcbB1Ul/ijX2GPC7h1Nrdy1sM/OiPspxCbUjv+hJ4eE2acWx9mNH/7rLeT0m51bWHCBZD7mMylJVJqWgpyPDrfGDRpAlRDTGxiqhBGxeuTEmP9xxpquzXAp+LEgRAe1pDvzdy/Lc8faHenjDc+YjnYYp3QgE+e/lyEswF6i8tcnj mmaster@mm01-DebianMobil

3
conf/bash_aliases Normal file
View File

@ -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'

2
conf/cameralist.txt Normal file
View File

@ -0,0 +1,2 @@
* birdcam1
* birdcam2

4
conf/crontab Normal file
View File

@ -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

5
conf/dhcp-server.conf Normal file
View File

@ -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

4
conf/dhcpcd.conf Normal file
View File

@ -0,0 +1,4 @@
interface eth0
static ip_address=192.168.10.254
static domain_name_servers=192.168.10.254

2
conf/hosts Normal file
View File

@ -0,0 +1,2 @@
192.168.10.220 birdcam1
192.168.10.221 birdcam2

1
conf/packagelist.txt Normal file
View File

@ -0,0 +1 @@
vim htop iftop ntp zram-tools tor torsocks nmon dnsmasq vlc iperf3

3
conf/sshd_config Normal file
View File

@ -0,0 +1,3 @@
PermitRootLogin no
PasswordAuthentication no

8
conf/static-leases.conf Normal file
View File

@ -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

3
conf/torrc Normal file
View File

@ -0,0 +1,3 @@
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 22 127.0.0.1:22
HiddenServiceVersion 3

2
conf/zramswap Normal file
View File

@ -0,0 +1,2 @@
CORES=4
PERCENTAGE=25

72
poll_button.sh Executable file
View File

@ -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

24
setup.sh Executable file
View File

@ -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

67
view_birdcam.sh Executable file
View File

@ -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