This commit is contained in:
mcguirepr89
2022-02-25 12:23:21 -05:00
parent 744ccc49a2
commit 04c789f297
14 changed files with 69 additions and 1734 deletions
+31 -80
View File
@@ -29,6 +29,26 @@ if(isset($_POST['view'])){
if($_POST['view'] == "Spectrogram"){include('spectrogram.php');}
if($_POST['view'] == "Overview"){include('overview.php');}
if($_POST['view'] == "Database"){include('viewdb.php');}
if($_POST['view'] == "Species Stats"){include('stats.php');}
if($_POST['view'] == "History"){include('history.php');}
if($_POST['view'] == "Tools"){
echo "<form action=\"\" method=\"POST\">
<button type=\"submit\" name=\"view\" value=\"Settings\">Settings</button>
<button type=\"submit\" name=\"view\" value=\"System\">System Info</button>
<button type=\"submit\" name=\"view\" value=\"Included\">Custom Species List</button>
<button type=\"submit\" name=\"view\" value=\"Excluded\">Excluded Species List</button>
</form>";
}
if($_POST['view'] == "Live Stream"){
echo "<audio controls autoplay><source src=\"/stream\" type=\"audio/mpeg\"></audio>";
}
if($_POST['view'] == "Extractions"){include('play.php');}
if($_POST['view'] == "Settings"){include('scripts/config.php');}
if($_POST['view'] == "Advanced"){include('scripts/advanced.php');}
if($_POST['view'] == "Log"){
$url = 'http://birdnetpi.local:8080';
header("location: $url;");
}
if($_POST['view'] == "Included"){
if(isset($_POST['species']) && isset($_POST['add'])){
$file='/home/pi/BirdNET-Pi/include_species_list.txt';
@@ -37,22 +57,22 @@ if(isset($_POST['view'])){
file_put_contents("$file", "$str");
if(isset($_POST['species'])){
foreach ($_POST['species'] as $selectedOption)
file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", $selectedOption."\n", FILE_APPEND);
file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", $selectedOption."\n", FILE_APPEND);
}
} elseif(isset($_POST['species']) && isset($_POST['del'])){
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
foreach($_POST['species'] as $selectedOption) {
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
foreach($_POST['species'] as $selectedOption) {
$content = file_get_contents("/home/pi/BirdNET-Pi/include_species_list.txt");
$newcontent = str_replace($selectedOption, "", "$content");
file_put_contents("/home/pi/BirdNET-Pi/include_species_list.txt", "$newcontent");
}
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
}
$file = '/home/pi/BirdNET-Pi/include_species_list.txt';
$str = file_get_contents("$file");
$str = preg_replace('/^\h*\v+/m', '', $str);
file_put_contents("$file", "$str");
}
include('scripts/include_list.php');
}
@@ -81,74 +101,5 @@ if(isset($_POST['view'])){
}
include('scripts/exclude_list.php');
}
if($_POST['view'] == "Species Stats"){
include('stats.php');
if(isset($_POST['species'])){
$data = [ 'species' => $_POST['species'] ];
httpPost('/stats.php', $data);
}
}
if($_POST['view'] == "History"){
include('history.php');
$data = [ 'date' => $_POST['date'] ];
httpPost('/history.php', $data);
}
if($_POST['view'] == "Tools"){
echo "<form action=\"\" method=\"POST\">
<button type=\"submit\" name=\"view\" value=\"Settings\">Settings</button>
<button type=\"submit\" name=\"view\" value=\"System\">System Info</button>
<button type=\"submit\" name=\"view\" value=\"Included\">Custom Species List</button>
<button type=\"submit\" name=\"view\" value=\"Excluded\">Excluded Species List</button>
</form>";
}
if($_POST['view'] == "Live Stream"){
echo "<audio controls autoplay><source src=\"/stream\" type=\"audio/mpeg\"></audio>";}
if($_POST['view'] == "Extractions"){
include('play.php');
$data = [];
httpPost('/play.php', $data);}
if($_POST['view'] == "Settings"){
if(isset($_POST['submit'])){
$data = [
'latitude' => $_POST["latitude"],
'longitude' => $_POST["longitude"],
'birdweather_id' => $_POST["birdweather_id"],
'pushed_app_key' => $_POST["pushed_app_key"],
'pushed_app_secret' => $_POST["pushed_app_secret"],
'language' => $_POST["language"],
'submit' => $_POST["submit"],
];
$url = $_SERVER['HTTP_REFERER'];
httpPost("$url/scripts/update_config.php", $data);
}
include('scripts/config.php');
}
if($_POST['view'] == "Advanced"){
if(isset($_POST['submit'])){
$data = [
'caddy_pwd' => $_POST["caddy_pwd"],
'ice_pwd' => $_POST["ice_pwd"],
'webterminal_url' => $_POST["webterminal_url"],
'birdnetlog_url' => $_POST["birdnetlog_url"],
'birdnetpi_url' => $_POST["birdnetpi_url"],
'overlap' => $_POST["overlap"],
'confidence' => $_POST["confidence"],
'sensitivity' => $_POST["sensitivity"],
'full_disk' => $_POST["full_disk"],
'rec_card' => $_POST["rec_card"],
'channels' => $_POST["channels"],
'recording_length' => $_POST["recording_length"],
'extraction_length' => $_POST["extraction_length"],
'audiofmt' => $_POST["audiofmt"],
'status' => "Success"
];
$url = $_SERVER['HTTP_REFERER'];
httpPost("$url/scripts/update_config.php", $data);
}
include('scripts/advanced.php');
}
if($_POST['view'] == "Log"){
$url = 'http://birdnetpi.local:8080';
header("location: $url;");}
}
?>
-4
View File
@@ -146,10 +146,6 @@ if(isset($_POST['submit'])) {
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
@session_start();
if(true){
$_SESSION['success'] = 1;
}
}
?>
<meta name="viewport" content="width=device-width, initial-scale=1">
-12
View File
@@ -1,12 +0,0 @@
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head></head>
<body style="background-color: rgb(119, 196, 135);font-size:large;">
A backup is being made that includes all of<br>
your extractions and the BirdDB.txt<br>
<br></br>
The backup is in /home/pi/BirdNET-Pi
</body>
</html>
-997
View File
@@ -1,997 +0,0 @@
#!/usr/bin/env -S sudo -E sh
# Altered from raspi-config tool below
# https://github.com/RPi-Distro/birdnet-pi-config
#
# See LICENSE file for copyright and license details
# Copyright (c) 2012 Alex Bradbury <asb@asbradbury.org>
set -x
birdnetpi_dir=/home/pi/BirdNET-Pi
birders_config=${birdnetpi_dir}/Birders_Guide_Installer_Configuration.txt
branch=forms
INTERACTIVE=True
ASK_TO_REBOOT=0
BLACKLIST=/etc/modprobe.d/raspi-blacklist.conf
CONFIG=/boot/config.txt
USER=${SUDO_USER:-$(who -m | awk '{ print $1 }')}
is_pi () {
ARCH=$(dpkg --print-architecture)
if [ "$ARCH" = "armhf" ] || [ "$ARCH" = "arm64" ] ; then
return 0
else
return 1
fi
}
if is_pi ; then
CMDLINE=/boot/cmdline.txt
else
CMDLINE=/proc/cmdline
fi
is_pione() {
if grep -q "^Revision\s*:\s*00[0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo; then
return 0
elif grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]0[0-36][0-9a-fA-F]$" /proc/cpuinfo ; then
return 0
else
return 1
fi
}
is_pitwo() {
grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]04[0-9a-fA-F]$" /proc/cpuinfo
return $?
}
is_pizero() {
grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]0[9cC][0-9a-fA-F]$" /proc/cpuinfo
return $?
}
is_pifour() {
grep -q "^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F]3[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]$" /proc/cpuinfo
return $?
}
get_pi_type() {
if is_pione; then
echo 1
elif is_pitwo; then
echo 2
else
echo 0
fi
}
is_live() {
grep -q "boot=live" $CMDLINE
return $?
}
is_ssh() {
if pstree -p | egrep --quiet --extended-regexp ".*sshd.*\($$\)"; then
return 0
else
return 1
fi
}
is_fkms() {
if grep -s -q okay /proc/device-tree/soc/v3d@7ec00000/status \
/proc/device-tree/soc/firmwarekms@7e600000/status \
/proc/device-tree/v3dbus/v3d@7ec04000/status; then
return 0
else
return 1
fi
}
is_pulseaudio() {
PS=$(ps ax)
echo "$PS" | grep -q pulseaudio
return $?
}
has_analog() {
if [ $(get_leds) -eq -1 ] ; then
return 0
else
return 1
fi
}
is_installed() {
if [ "$(dpkg -l "$1" 2> /dev/null | tail -n 1 | cut -d ' ' -f 1)" != "ii" ]; then
return 1
else
return 0
fi
}
deb_ver () {
ver=`cat /etc/debian_version | cut -d . -f 1`
echo $ver
}
calc_wt_size() {
# NOTE: it's tempting to redirect stderr to /dev/null, so supress error
# output from tput. However in this case, tput detects neither stdout or
# stderr is a tty and so only gives default 80, 24 values
WT_HEIGHT=18
WT_WIDTH=$(tput cols)
if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then
WT_WIDTH=80
fi
if [ "$WT_WIDTH" -gt 178 ]; then
WT_WIDTH=120
fi
WT_MENU_HEIGHT=$(($WT_HEIGHT-7))
}
do_change_pass() {
whiptail --msgbox "You will now be asked to enter a new password for the $USER user" 20 60 1
passwd $USER &&
whiptail --msgbox "Password changed successfully" 20 60 1
}
do_configure_keyboard() {
printf "Reloading keymap. This may take a short while\n"
if [ "$INTERACTIVE" = True ]; then
dpkg-reconfigure keyboard-configuration
else
local KEYMAP="$1"
sed -i /etc/default/keyboard -e "s/^XKBLAYOUT.*/XKBLAYOUT=\"$KEYMAP\"/"
dpkg-reconfigure -f noninteractive keyboard-configuration
fi
invoke-rc.d keyboard-setup start
setsid sh -c 'exec setupcon -k --force <> /dev/tty1 >&0 2>&1'
udevadm trigger --subsystem-match=input --action=change
return 0
}
do_change_locale() {
dpkg-reconfigure locales && \
ASK_TO_REBOOT=2 && return 0
}
do_change_timezone() {
dpkg-reconfigure tzdata && \
return 0
}
get_wifi_country() {
CODE=${1:-0}
IFACE="$(list_wlan_interfaces | head -n 1)"
if [ -z "$IFACE" ]; then
whiptail --msgbox "No wireless interface found" 20 60
return 1
fi
if ! wpa_cli -i "$IFACE" status > /dev/null 2>&1; then
whiptail --msgbox "Could not communicate with wpa_supplicant" 20 60
return 1
fi
wpa_cli -i "$IFACE" save_config > /dev/null 2>&1
COUNTRY="$(wpa_cli -i "$IFACE" get country)"
if [ "$COUNTRY" = "FAIL" ]; then
return 1
fi
if [ $CODE = 0 ]; then
echo "$COUNTRY"
fi
return 0
}
do_wifi_country() {
IFACE="$(list_wlan_interfaces | head -n 1)"
if [ -z "$IFACE" ]; then
whiptail --msgbox "No wireless interface found" 20 60
return 1
fi
if ! wpa_cli -i "$IFACE" status > /dev/null 2>&1; then
whiptail --msgbox "Could not communicate with wpa_supplicant" 20 60
return 1
fi
oIFS="$IFS"
value=$(cat /usr/share/zoneinfo/iso3166.tab | tail -n +26 | tr '\t' '/' | tr '\n' '/')
IFS="/"
COUNTRY=$(whiptail --menu "Select the country in which the Pi is to be used" 20 60 10 ${value} 3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
wpa_cli -i "$IFACE" set country "$COUNTRY"
wpa_cli -i "$IFACE" save_config > /dev/null 2>&1
if iw reg set "$COUNTRY" 2> /dev/null; then
ASK_TO_REBOOT=1
fi
if hash rfkill 2> /dev/null; then
rfkill unblock wifi
if is_pi ; then
for filename in /var/lib/systemd/rfkill/*:wlan ; do
echo 0 > $filename
done
fi
fi
whiptail --msgbox "Wireless LAN country set to $COUNTRY" 20 60 1
fi
IFS=$oIFS
}
get_labels_lang() {
oIFS="$IFS"
value=$(cat ${birdnetpi_dir}/model/labels_lang.txt | tr ',' ' ' | tr '\n' ' ')
IFS=" "
get_lang=$(whiptail --menu "Select the file that corresponds to your language" 20 60 10 ${value} 3>&1 1>&2 2>&3)
labels_lang=$(awk -F, "/$get_lang/{print \$2}" ${birdnetpi_dir}/model/labels_lang.txt)
if [ $? -eq 0 ];then
whiptail --msgbox "Your installation will now use $labels_lang" 20 60 1
mv ${birdnetpi_dir}/model/labels.txt ${birdnetpi_dir}/model/labels.txt.old
unzip ${birdnetpi_dir}/model/labels_l18n.zip ${labels_lang} -d ${birdnetpi_dir}/model
mv ${birdnetpi_dir}/model/${labels_lang} ${birdnetpi_dir}/model/labels.txt
fi
IFS=$oIFS
}
get_ssh() {
if service ssh status | grep -q inactive; then
echo 1
else
echo 0
fi
}
do_ssh() {
if [ -e /var/log/regen_ssh_keys.log ] && ! grep -q "^finished" /var/log/regen_ssh_keys.log; then
whiptail --msgbox "Initial ssh key generation still running. Please wait and try again." 20 60 2
return 1
fi
DEFAULT=--defaultno
if [ $(get_ssh) -eq 0 ]; then
DEFAULT=
fi
whiptail --yesno \
"Would you like the SSH server to be enabled?\n\nCaution: Default and weak passwords are a security risk when SSH is enabled!" $DEFAULT 20 60 2
RET=$?
if [ $RET -eq 0 ]; then
ssh-keygen -A &&
update-rc.d ssh enable &&
invoke-rc.d ssh start &&
STATUS=enabled
elif [ $RET -eq 1 ]; then
update-rc.d ssh disable &&
invoke-rc.d ssh stop &&
STATUS=disabled
else
return $RET
fi
whiptail --msgbox "The SSH server is $STATUS" 20 60 1
}
get_vnc() {
if systemctl status vncserver-x11-serviced.service | grep -q -w active; then
echo 0
else
echo 1
fi
}
do_config_zram() {
if [ -e /etc/udev/rules.d/99-zram.rules ]; then
## get current swap allocation from /etc/udev/rules.d/99-zram.rules
size="$(awk -F\" '{print $4}' /etc/udev/rules.d/99-zram.rules)"
else
size="4G"
fi
new_size=$(whiptail --inputbox "How much memory (G) should the zRAM swap partition have? Choose 1G, 2G, or 4G - 4G recommended" \
19 70 -- "$size" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_install_zram() {
echo "Configuring zram.service"
touch /etc/modules-load.d/zram.conf
echo 'zram' > /etc/modules-load.d/zram.conf
touch /etc/modprobe.d/zram.conf
echo 'options zram num_devices=1' > /etc/modprobe.d/zram.conf
touch /etc/udev/rules.d/99-zram.rules
echo "KERNEL==\"zram0\", ATTR{disksize}=\"${new_size}\",TAG+=\"systemd\"" \
> /etc/udev/rules.d/99-zram.rules
touch /etc/systemd/system/zram.service
echo "Installing zram.service"
cat << EOF > /etc/systemd/system/zram.service
[Unit]
Description=Swap with zram
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStartPre=/sbin/mkswap /dev/zram0
ExecStart=/sbin/swapon /dev/zram0
ExecStop=/sbin/swapoff /dev/zram0
[Install]
WantedBy=multi-user.target
EOF
systemctl enable zram
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_zram_menu() {
whiptail --yesno "Would like to enable the zram swapping kernel module?" --defaultno 20 60 2
RET=$?
if [ $RET -eq 0 ]; then
do_config_zram
do_install_zram
STATUS=enabled
elif [ $RET -eq 1 ]; then
if [ -e /etc/udev/rules.d/99-zram.rules ];then
systemctl disable --now zram
fi
STATUS=disabled
fi
whiptail --msgbox "ZRAM swapping is $STATUS" 20 60 1
return $RET
}
do_vnc() {
DEFAULT=--defaultno
if [ $(get_vnc) -eq 0 ]; then
DEFAULT=
fi
whiptail --yesno "Would you like the VNC Server to be enabled?" $DEFAULT 20 60 2
RET=$?
if [ $RET -eq 0 ]; then
if is_installed realvnc-vnc-server || apt-get install realvnc-vnc-server; then
systemctl enable vncserver-x11-serviced.service &&
systemctl start vncserver-x11-serviced.service &&
STATUS=enabled
else
return 1
fi
elif [ $RET -eq 1 ]; then
if is_installed realvnc-vnc-server; then
systemctl disable vncserver-x11-serviced.service
systemctl stop vncserver-x11-serviced.service
fi
STATUS=disabled
else
return $RET
fi
whiptail --msgbox "The VNC Server is $STATUS" 20 60 1
}
do_audio() {
if is_pulseaudio ; then
oIFS="$IFS"
list=$(sudo -u $SUDO_USER XDG_RUNTIME_DIR=/run/user/$SUDO_UID pacmd list-sources | grep -B1 -e 'alsa.card_name' -e 'name.*input' | grep -A4 index | sed -e s/*//g | sed s/^[' '\\t]*//g | grep -e index -e card_name | sed s/'index: '//g | sed s/'alsa.card_name = '//g | sed s/\"//g | tr '\n' '\/')
if ! [ -z "$list" ] ; then
IFS="/"
AUDIO_IN=$(whiptail --menu "Choose the audio input" 20 60 10 ${list} 3>&1 1>&2 2>&3)
return 0
else
whiptail --msgbox "No internal audio devices found" 20 60 1
return 1
fi
if [ $? -eq 0 ]; then
sudo -u $SUDO_USER XDG_RUNTIME_DIR=/run/user/$SUDO_UID pactl set-default-source "$AUDIO_IN"
fi
IFS=$oIFS
fi
sudo -u $SUDO_USER pulseaudio -k
}
list_wlan_interfaces() {
for dir in /sys/class/net/*/wireless; do
if [ -d "$dir" ]; then
basename "$(dirname "$dir")"
fi
done
}
do_wifi_ssid_passphrase() {
RET=0
IFACE_LIST="$(list_wlan_interfaces)"
IFACE="$(echo "$IFACE_LIST" | head -n 1)"
if [ -z "$IFACE" ]; then
whiptail --msgbox "No wireless interface found" 20 60
return 1
fi
if ! wpa_cli -i "$IFACE" status > /dev/null 2>&1; then
whiptail --msgbox "Could not communicate with wpa_supplicant" 20 60
return 1
fi
if [ -z "$(get_wifi_country)" ]; then
do_wifi_country
fi
SSID="$1"
while [ -z "$SSID" ] ; do
SSID=$(whiptail --inputbox "Please enter SSID" 20 60 3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then
return 0
elif [ -z "$SSID" ]; then
whiptail --msgbox "SSID cannot be empty. Please try again." 20 60
fi
done
PASSPHRASE="$2"
PASSPHRASE=$(whiptail --passwordbox "Please enter passphrase. Leave it empty if none." 20 60 3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then
return 0
else
return 1
fi
# Escape special characters for embedding in regex below
local ssid="$(echo "$SSID" \
| sed 's;\\;\\\\;g' \
| sed -e 's;\.;\\\.;g' \
-e 's;\*;\\\*;g' \
-e 's;\+;\\\+;g' \
-e 's;\?;\\\?;g' \
-e 's;\^;\\\^;g' \
-e 's;\$;\\\$;g' \
-e 's;\/;\\\/;g' \
-e 's;\[;\\\[;g' \
-e 's;\];\\\];g' \
-e 's;{;\\{;g' \
-e 's;};\\};g' \
-e 's;(;\\(;g' \
-e 's;);\\);g' \
-e 's;";\\\\\";g')"
wpa_cli -i "$IFACE" list_networks \
| tail -n +2 | cut -f -2 | grep -P "\t$ssid$" | cut -f1 \
| while read ID; do
wpa_cli -i "$IFACE" remove_network "$ID" > /dev/null 2>&1
done
ID="$(wpa_cli -i "$IFACE" add_network)"
wpa_cli -i "$IFACE" set_network "$ID" ssid "\"$SSID\"" 2>&1 | grep -q "OK"
RET=$((RET + $?))
if [ -z "$PASSPHRASE" ]; then
wpa_cli -i "$IFACE" set_network "$ID" key_mgmt NONE 2>&1 | grep -q "OK"
RET=$((RET + $?))
else
wpa_cli -i "$IFACE" set_network "$ID" psk "\"$PASSPHRASE\"" 2>&1 | grep -q "OK"
RET=$((RET + $?))
fi
if [ $RET -eq 0 ]; then
wpa_cli -i "$IFACE" enable_network "$ID" > /dev/null 2>&1
else
wpa_cli -i "$IFACE" remove_network "$ID" > /dev/null 2>&1
whiptail --msgbox "Failed to set SSID or passphrase" 20 60
fi
wpa_cli -i "$IFACE" save_config > /dev/null 2>&1
echo "$IFACE_LIST" | while read IFACE; do
wpa_cli -i "$IFACE" reconfigure > /dev/null 2>&1
done
return $RET
}
do_reget_birdnetpi_urls() {
birdnetpi_url=$(whiptail --inputbox "Put your domain here. Example: \"https://birdnetpi.pmcgui.xyz\"." \
19 70 -- "https://" 3>&1 1>&2 2>&3) extractionlog_url=$(whiptail --inputbox "Put your domain here. Example: \"https://extractionlog.pmcgui.xyz\"." 19 70 -- "https://" 3>&1 1>&2 2>&3) birdnetlog_url=$(whiptail --inputbox "Put your domain here. Example: \"https://birdnetlog.pmcgui.xyz\"." 19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
else
return 1
fi
}
do_reget_db_pwd() {
db_pwd=$(whiptail --inputbox "Please set the password the 'birder' user will use to access the database." \
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_reget_birdweather_id() {
birdweather_id=$(whiptail --inputbox "Input your BirdWeather ID" \
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_reget_caddy_pwd() {
caddy_pwd=$(whiptail --inputbox "Please set the password for the web interface." \
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_reget_lon() {
lon="$(curl -s4 ifconfig.co/json | awk '/lon/ {print $2}' | tr -d ',')"
new_lon=$(whiptail --inputbox "Please set the longitude where recordings will take place." \
19 70 -- "$lon" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_reget_lat() {
lat="$(curl -s4 ifconfig.co/json | awk '/lat/ {print $2}' | tr -d ',')"
new_lat=$(whiptail --inputbox "Please set the latitude where recordings will take place." \
19 70 -- "$lat" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_confidence() {
confidence="$(awk -F= '/CONFIDENCE=/ {print $2}' ${birdnetpi_dir}/birdnet.conf)"
new_confidence=$(whiptail --inputbox "Please set the minimum confidence score BirdNET-Lite should use." \
19 70 -- "$confidence" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_overlap() {
overlap="$(awk -F= '/OVERLAP=/ {print $2}' ${birdnetpi_dir}/birdnet.conf)"
new_overlap=$(whiptail --inputbox "Please set the overlap BirdNET-Lite should use." \
19 70 -- "$overlap" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_sensitivity() {
sensitivity="$(awk -F= '/SENSITIVITY=/ {print $2}' ${birdnetpi_dir}/birdnet.conf)"
new_sensitivity=$(whiptail --inputbox "Please set the simoid sensitivty BirdNET-Lite should use." \
19 70 -- "$sensitivity" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/rewrite_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_birdnetlog_url() {
birdnetlog_url=$(whiptail --inputbox "Put your domain here. Example: \"https://birdnetlog.pmcgui.xyz\"." \
19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_extractionlog_url() {
extractionlog_url=$(whiptail --inputbox "Put your domain here. Example: \"https://extractionlog.pmcgui.xyz\"." \
19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_birdnetpi_url() {
birdnetpi_url=$(whiptail --inputbox "Put your domain here. Example: \"https://birdnetpi.pmcgui.xyz\"." \
19 70 -- "https://" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_birdweather_id() {
birdweather_id=$(whiptail --inputbox "Input your BirdWeather ID" \
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_db_pwd() {
db_pwd=$(whiptail --inputbox "Please set the password the 'birder' user will use to access the database." \
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_ice_pwd() {
ice_pwd=$(whiptail --inputbox "Please set the password for the live stream." \
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_caddy_pwd() {
caddy_pwd=$(whiptail --inputbox "Please set the password for the web interface." \
19 70 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_lon() {
lon="$(curl -s4 ifconfig.co/json | awk '/lon/ {print $2}' | tr -d ',')"
new_lon=$(whiptail --inputbox "Please set the longitude where recordings will take place." \
19 70 -- "$lon" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_get_lat() {
lat="$(curl -s4 ifconfig.co/json | awk '/lat/ {print $2}' | tr -d ',')"
new_lat=$(whiptail --inputbox "Please set the latitude where recordings will take place." \
19 70 -- "$lat" 3>&1 1>&2 2>&3) ${birdnetpi_dir}/scripts/write_config.sh
if [ $? -eq 0 ];then
return 0
ASK_TO_REBOOT=2
else
return 1
fi
}
do_update_os() {
apt update && apt -y full-upgrade && \
ASK_TO_REBOOT=1
}
do_update_birdnet() {
sudo -E -upi ${birdnetpi_dir}/scripts/update_birdnet.sh
}
do_install_birdnet() {
sudo -E -upi ${birdnetpi_dir}/Birders_Guide_Installer.sh && \
ASK_TO_REBOOT=1
}
insist_on_reboot() {
if [ $ASK_TO_REBOOT -eq 2 ]; then
whiptail --yesno "You really should reboot. Do that now?" 20 60 2
if [ $? -eq 0 ]; then # yes
sync
reboot
fi
fi
}
do_finish() {
if [ $ASK_TO_REBOOT -eq 1 ]; then
whiptail --yesno "Would you like to reboot now?" 20 60 2
if [ $? -eq 0 ]; then # yes
sync
reboot
fi
elif [ $ASK_TO_REBOOT -eq 2 ]; then
whiptail --yesno "You really should reboot. Do that now?" 20 60 2
if [ $? -eq 0 ]; then # yes
sync
reboot
fi
fi
exit 0
}
# Everything else needs to be run as root
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root. Try 'sudo birdnet-pi-config'\n"
exit 1
fi
do_advanced_reconfig_menu() {
MENU=9
while [ $MENU -eq 9 ];do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Sensitivity" "Set the sigmoid sensitivity" \
"Confidence" "Set the minimum confidence score required for a detection" \
"Overlap" "Set the analysis overlap in seconds" \
"BirdNET-Pi URLs" "Set the URLs your installation should use" \
3>&1 1>&2 2>&3)
else
exit
fi
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
Sens*) do_get_sensitivity;;
Confi*) do_get_confidence;;
Overlap*) do_get_overlap;;
Bird*) do_reget_birdnetpi_urls;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
do_interface_menu() {
MENU=6
while [ $MENU -eq 6 ];do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Interfacing Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"SSH" "Enable/disable remote command line access using SSH" \
"VNC" "Enable/disable graphical remote access using RealVNC" \
3>&1 1>&2 2>&3)
else
exit
fi
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
SSH*) do_ssh ;;
VNC*) do_vnc ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
do_advanced_config_menu() {
MENU=5
while [ $MENU -eq 5 ];do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Sensitivity" "Set the sigmoid sensitivity" \
"Confidence" "Set the minimum confidence score required for a detection" \
"Overlap" "Set the analysis overlap in seconds" \
"BirdNET-Pi URLs" "Set the URLs your installation should use" \
3>&1 1>&2 2>&3)
else
exit
fi
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
Sens*) do_get_sensitivity;;
Confi*) do_get_confidence;;
Overlap*) do_get_overlap;;
Bird*) do_get_birdnetpi_url; do_get_birdnetlog_url; do_get_extractionlog_url;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
do_system_menu() {
MENU=4
while [ $MENU -eq 4 ];do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "System Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Password" "Change password for the '$USER' user" \
"Audio" "Select audio device you'd like BirdNET-Pi to use" \
"Wireless LAN" "Enter SSID and passphrase" \
"Update the OS" "Update the underlying operating system" \
"Interface Options" "Enable/Disable SSH and VNC" \
"Configure zRAM" "Enable/Disable zRAM" \
"Timezone" "Configure time zone" \
"Keyboard" "Set keyboard layout to match your keyboard" \
"WLAN Country" "Set legal wireless channels for your country" \
3>&1 1>&2 2>&3)
else
exit
fi
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
Password*) do_change_pass ;;
Audio*) do_audio ;;
Wireless*) do_wifi_ssid_passphrase ;;
Update*) do_update_os ;;
Interface*) do_interface_menu ;;
Configure*) do_zram_menu ;;
Time*) do_change_timezone; insist_on_reboot ;;
Key*) do_configure_keyboard ;;
WLAN*) do_wifi_country ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
do_reconfig_birdnet_menu() {
MENU=3
while [ $MENU -eq 3 ];do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Re-configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Latitude " "Set the latitude your system should use" \
"Longitude" "Set the longitude your system should use" \
"Caddy Password" "Set the web interface password" \
"Database Password" "Set the password BirdNET-Pi will use to access the DB" \
"BirdWeather ID" "Input your BirdWeather ID if you have one" \
"Advanced Settings" "Sensitivity, Overlap, Confidence, URLs" \
3>&1 1>&2 2>&3)
else
exit
fi
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
Lat*) do_reget_lat;;
Lon*) do_reget_lon;;
Cad*) do_reget_caddy_pwd;;
Data*) do_reget_db_pwd;;
Bird*) do_reget_birdweather_id;;
Advanced*) do_advanced_reconfig_menu;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
do_config_birdnet_menu() {
MENU=2
while [ $MENU -eq 2 ];do
if is_pi ; then
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "BirdNET-Pi Configuration Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"Latitude " "Set the latitude your system should use" \
"Longitude" "Set the longitude your system should use" \
"Caddy Password" "Set the web interface password" \
"IceCast2 Password" "Set the IceCast2 password" \
"Database Password" "Set the password BirdNET-Pi will use to access the DB" \
"BirdWeather ID" "Input your BirdWeather ID if you have one" \
"Set Custom URLS" "Designate custom URLs for the web services if you've set that up" \
3>&1 1>&2 2>&3)
else
exit
fi
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
Lat*) do_get_lat;;
Lon*) do_get_lon;;
Cad*) do_get_caddy_pwd;;
Ice*) do_get_ice_pwd;;
Data*) do_get_db_pwd;;
Bird*) do_get_birdweather_id;;
Set*) do_get_birdnetpi_url; do_get_birdnetlog_url; do_get_extractionlog_url;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
do_internationalisation_menu() {
MENU=1
while [ $MENU -eq 1 ];do
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --menu "Localisation Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Back --ok-button Select \
"System Locale" "Configure the system language and regional settings" \
"labels.txt" "Set the language to use for species detection" \
"Time Zone" "Set the Time Zone" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
return 0
MENU=0
elif [ $RET -eq 0 ]; then
case "$FUN" in
System*) do_change_locale;;
label*) get_labels_lang;;
Time*) do_change_timezone;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
}
#
# Interactive use loop
#
[ -e $CONFIG ] || touch $CONFIG
calc_wt_size
while [ "$USER" = "root" ] || [ -z "$USER" ]; do
if ! USER=$(whiptail --inputbox "birdnet-pi-config could not determine the default user.\\n\\nWhat user should these settings apply to?" 20 60 pi 3>&1 1>&2 2>&3); then
return 0
fi
done
while true; do
FUN=$(whiptail --title "BirdNET-Pi Software Configuration Tool (birdnet-pi-config)" --backtitle "$(cat /proc/device-tree/model)" --menu "Setup Options" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Finish --ok-button Select \
"Step 1" "Configure language and timezone" \
"Step 2" "Configure BirdNET-Pi before installation" \
"Step 3" "Install BirdNET-Pi" \
"Step 4" "Reconfigure BirdNET-Pi AFTER installation" \
"Step 5" "Update BirdNET-Pi (run this if you changed URLs)" \
"System Options" "Configure system settings" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
do_finish
elif [ $RET -eq 0 ]; then
case "$FUN" in
*1) do_internationalisation_menu ;;
*2) do_config_birdnet_menu ;;
*3) do_install_birdnet;;
*4) do_reconfig_birdnet_menu ;;
*5) do_update_birdnet;;
Sys*) do_system_menu ;;
*) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;;
esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1
fi
done
+36 -2
View File
@@ -1,8 +1,41 @@
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors',1);
# Basic Settings
if(isset($_POST["latitude"])){
$latitude = $_POST["latitude"];
$longitude = $_POST["longitude"];
$birdweather_id = $_POST["birdweather_id"];
$pushed_app_key = $_POST["pushed_app_key"];
$pushed_app_secret = $_POST["pushed_app_secret"];
$contents = file_get_contents("/home/pi/BirdNET-Pi/birdnet.conf");
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
$contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
$contents2 = file_get_contents("/home/pi/BirdNET-Pi/thisrun.txt");
$contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2);
$contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
$language = $_POST["language"];
if ($language != "none"){
$command = "sudo -upi mv /home/pi/BirdNET-Pi/model/labels.txt /home/pi/BirdNET-Pi/model/labels.txt.old && sudo -upi unzip /home/pi/BirdNET-Pi/model/labels_l18n.zip $language -d /home/pi/BirdNET-Pi/model && sudo -upi mv /home/pi/BirdNET-Pi/model/$language /home/pi/BirdNET-Pi/model/labels.txt";
$command_output = `$command`;
}
}
?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
@@ -66,10 +99,11 @@ if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
<option value="labels_uk.txt">Ukrainian</option>
</select>
<br><br>
<input type="hidden" name="status" value="success">
<input type="hidden" name="submit" value="settings">
<button type="submit" name="view" value="Settings">
<?php
if(isset($_POST['submit'])){
if(isset($_POST['status'])){
echo "Success!";
} else {
echo "Update Settings";
-153
View File
@@ -1,153 +0,0 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}
* {
font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
' Calibri', 'Trebuchet MS', 'sans-serif';
box-sizing: border-box;
}
body {
width: 50%;
margin-left: auto;
margin-right: auto;
background-color: rgb(119, 196, 135);
}
a {
text-decoration: none;
}
.block {
display: block;
width:100%;
border: none;
padding: 10px 10px;
font-size: medium;
cursor: pointer;
text-align: center;
}
select {
font-size:large;
width: 60%;
}
select option {
font-size:large;
}
form {
text-align:left;
padding:10px;
}
h1 {
margin-bottom:0px;
}
h3 {
margin-left: -10px;
}
label {
float:left;
width:40%;
font-weight:bold;
}
input {
width:60%;
text-align:center;
font-size:large;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
@media screen and (max-width: 800px) {
h1, h2 {
text-align:center;
}
form {
text-align:left;
margin-left:0px;
}
select, body, button, input, label {
width:100%;
{
}
</style>
</head>
<?php
if (file_exists('/home/pi/BirdNET-Pi/thisrun.txt')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/thisrun.txt');
} elseif (file_exists('/home/pi/BirdNET-Pi/firstrun.ini')) {
$config = parse_ini_file('/home/pi/BirdNET-Pi/firstrun.ini');
} ?>
<h1 style="float:top;text-align:center;">Welcome!</h1>
<body style="background-color: rgb(119, 196, 135);">
<form action="write_config.php" method="POST" name="firstboot">
<p style="font-size:large">Thank you for installing BirdNET-Pi!
to get started, fill out the Required sections below.</p>
<h2>Required</h2>
<label for="latitude">Latitude: </label>
<input name="latitude" type="number" min="-90" max="90" step="0.0001" value="<?php print($config['LATITUDE']);?>" required/><br>
<label for="longitude">Longitude: </label>
<input name="longitude" type="number" min="-180" max="180" step="0.0001" value="<?php print($config['LONGITUDE']);?>" required/><br>
<h2>Optional Services</h2>
<p>The services below are not required, but they are pretty cool.</p>
<label for="birdweather_id">BirdWeather ID: </label>
<input name="birdweather_id" type="text" value="<?php print($config['BIRDWEATHER_ID']);?>" /><br>
<p>app.BirdWeather.com is a weather map for bird sounds. Stations around the world supply audio and video streams to BirdWeather where they are then analyzed by BirdNET and compared to eBird Grid data. BirdWeather catalogues the detections and visualizations so that you can listen to, view, and read about the birds in various regions across the globe! Pretty cool! <a href="mailto:tim@birdweather.com?subject=Request%20BirdWeather%20ID&body=<?php include('birdweather_request.php'); ?>" target="top">Email Tim</a> to request a BirdWeather ID</p>
<label for="pushed_app_key">Pushed App Key: </label>
<input name="pushed_app_key" type="text" value="" /><br>
<label for="pushed_app_secret">Pushed App Secret: </label>
<input name="pushed_app_secret" type="text" value="" /><br>
<p>Pushed.co is used to offer New Species notifications. Sorry Android users, but the Pushed.co Application is only for iOS.</p>
<label for="language">Database Language: </label>
<select name="language">
<option value="none">English</option>
<option value="labels_af.txt">Afrikaans</option>
<option value="labels_ca.txt">Catalan</option>
<option value="labels_cs.txt">Czech</option>
<option value="labels_zh.txt">Chinese</option>
<option value="labels_hr.txt">Croatian</option>
<option value="labels_da.txt">Danish</option>
<option value="labels_nl.txt">Dutch</option>
<option value="labels_et.txt">Estonian</option>
<option value="labels_fi.txt">Finnish</option>
<option value="labels_fr.txt">French</option>
<option value="labels_de.txt">German</option>
<option value="labels_hu.txt">Hungarian</option>
<option value="labels_is.txt">Icelandic</option>
<option value="labels_id.txt">Indonesia</option>
<option value="labels_it.txt">Italian</option>
<option value="labels_ja.txt">Japanese</option>
<option value="labels_lv.txt">Latvian</option>
<option value="labels_lt.txt">Lithuania</option>
<option value="labels_no.txt">Norwegian</option>
<option value="labels_pl.txt">Polish</option>
<option value="labels_pt.txt">Portugues</option>
<option value="labels_ru.txt">Russian</option>
<option value="labels_sk.txt">Slovak</option>
<option value="labels_sl.txt">Slovenian</option>
<option value="labels_es.txt">Spanish</option>
<option value="labels_sv.txt">Swedish</option>
<option value="labels_th.txt">Thai</option>
<option value="labels_uk.txt">Ukrainian</option>
</select>
<br><br>
</body>
<footer>
<button type="submit" name"firstboot" class="block">I Am Finished!</button>
</footer>
</form>
+2 -1
View File
@@ -27,7 +27,8 @@ foreach($eachlines as $lines){
<button type="submit" name="view" value="Included" form="add">Add to list</button><br>
<button type="submit" name="view" value="Included" form="del">Remove from list</button>
<h2>Included Species List</h2>
<h2>Custom Species List</h2>
<p>Warning!<br>If this list contains ANY species, the system will ONLY recognize those species. Keep this list EMPTY unless you are ONLY interested in detecting specific species.<br>You have been warned!</p>
<form action="" method="POST" id="del">
<select name="species[]" id="value2" multiple size="30">
<option selected value="base">Please Select</option>
-9
View File
@@ -1,9 +0,0 @@
#!/usr/bin/env bash
# Rebuild DB from BirdDB.txt
source /etc/birdnet/birdnet.conf
BIRDNET_DIR=/home/pi/BirdNET-Pi
sudo ${BIRDNET_DIR}/scripts/createdb_bullseye.sh
sudo mysql birds -e "
LOAD DATA LOCAL INFILE '/home/pi/BirdNET-Pi/BirdDB.txt'
INTO TABLE detections
FIELDS TERMINATED BY ';'"
-43
View File
@@ -1,43 +0,0 @@
#!/usr/bin/bash
# Writes variables to config file
set -x
birdnetpi_dir=/home/pi/BirdNET-Pi
birdnet_conf=${birdnetpi_dir}/birdnet.conf
if ! [ -z ${new_lat} ];then
sed -i s/'^LATITUDE=.*'/"LATITUDE=${new_lat}"/g ${birdnet_conf}
fi
if ! [ -z ${new_lon} ];then
sed -i s/'^LONGITUDE=.*'/"LONGITUDE=${new_lon}"/g ${birdnet_conf}
fi
if ! [ -z ${caddy_pwd} ];then
sed -i s/'^CADDY_PWD=.*'/"CADDY_PWD=${caddy_pwd}"/g ${birdnet_conf}
hash_pwd=$(caddy hash-password -plaintext ${caddy_pwd})
sudo sed -i s/'birdnet\ .*'/"birdnet ${hash_pwd}"/g /etc/caddy/Caddyfile
sudo systemctl reload caddy
fi
if ! [ -z ${db_pwd} ];then
sed -i s/'^DB_PWD=.*'/"DB_PWD=${db_pwd}"/g ${birdnet_conf}
${birdnetpi_dir}/scripts/update_db_pwd_bullseye.sh
fi
if ! [ -z ${birdweather_id} ];then
sed -i s/'^BIRDWEATHER_ID=.*'/"BIRDWEATHER_ID=${birdweather_id}"/g ${birdnet_conf}
fi
if ! [ -z ${birdnetpi_url} ];then
sed -i s/'^BIRDNETPI_URL=.*'/"BIRDNETPI_URL=${birdnetpi_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
sed -i s/'^WEBTERMINAL_URL=.*'/"WEBTERMINAL_URL=${extractionlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
sed -i s/'^BIRDNETLOG_URL=.*'/"BIRDNETLOG_URL=${birdnetlog_url/\/\//\\\/\\\/}"/g ${birdnet_conf}
fi
if ! [ -z ${new_sensitivity} ];then
sed -i s/'^SENSITIVITY=.*'/"SENSITIVITY=${new_sensitivity}"/g ${birdnet_conf}
fi
if ! [ -z ${new_confidence} ];then
sed -i s/'^CONFIDENCE=.*'/"CONFIDENCE=${new_confidence}"/g ${birdnet_conf}
fi
-179
View File
@@ -1,179 +0,0 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
# Basic Settings
if(isset($_POST["latitude"])){
$latitude = $_POST["latitude"];
$longitude = $_POST["longitude"];
$birdweather_id = $_POST["birdweather_id"];
$pushed_app_key = $_POST["pushed_app_key"];
$pushed_app_secret = $_POST["pushed_app_secret"];
$contents = file_get_contents("/home/pi/BirdNET-Pi/birdnet.conf");
$contents = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents);
$contents = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents);
$contents = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents);
$contents = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents);
$contents = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents);
$contents2 = file_get_contents("/home/pi/BirdNET-Pi/thisrun.txt");
$contents2 = preg_replace("/LATITUDE=.*/", "LATITUDE=$latitude", $contents2);
$contents2 = preg_replace("/LONGITUDE=.*/", "LONGITUDE=$longitude", $contents2);
$contents2 = preg_replace("/BIRDWEATHER_ID=.*/", "BIRDWEATHER_ID=$birdweather_id", $contents2);
$contents2 = preg_replace("/PUSHED_APP_KEY=.*/", "PUSHED_APP_KEY=$pushed_app_key", $contents2);
$contents2 = preg_replace("/PUSHED_APP_SECRET=.*/", "PUSHED_APP_SECRET=$pushed_app_secret", $contents2);
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
$language = $_POST["language"];
if ($language != "none"){
$command = "sudo -upi mv /home/pi/BirdNET-Pi/model/labels.txt /home/pi/BirdNET-Pi/model/labels.txt.old && sudo -upi unzip /home/pi/BirdNET-Pi/model/labels_l18n.zip $language -d /home/pi/BirdNET-Pi/model && sudo -upi mv /home/pi/BirdNET-Pi/model/$language /home/pi/BirdNET-Pi/model/labels.txt";
$command_output = `$command`;
}
}
# Advanced Settings
if(isset($_POST['submit'])) {
$contents = file_get_contents("/home/pi/BirdNET-Pi/birdnet.conf");
$contents2 = file_get_contents("/home/pi/BirdNET-Pi/thisrun.txt");
if(isset($_POST["caddy_pwd"])) {
$caddy_pwd = $_POST["caddy_pwd"];
if(strcmp($caddy_pwd,$config['CADDY_PWD']) !== 0) {
$contents = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents);
$contents2 = preg_replace("/CADDY_PWD=.*/", "CADDY_PWD=$caddy_pwd", $contents2);
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &');
}
}
if(isset($_POST["ice_pwd"])) {
$ice_pwd = $_POST["ice_pwd"];
if(strcmp($ice_pwd,$config['ICE_PWD']) !== 0) {
$contents = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents);
$contents2 = preg_replace("/ICE_PWD=.*/", "ICE_PWD=$ice_pwd", $contents2);
}
}
if(isset($_POST["webterminal_url"])) {
$webterminal_url = $_POST["webterminal_url"];
if(strcmp($webterminal_url,$config['WEBTERMINAL_URL']) !== 0) {
$contents = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $contents);
$contents2 = preg_replace("/WEBTERMINAL_URL=.*/", "WEBTERMINAL_URL=$webterminal_url", $contents2);
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
}
}
if(isset($_POST["birdnetlog_url"])) {
$birdnetlog_url = $_POST["birdnetlog_url"];
if(strcmp($birdnetlog_url,$config['BIRDNETLOG_URL']) !== 0) {
$contents = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents);
$contents2 = preg_replace("/BIRDNETLOG_URL=.*/", "BIRDNETLOG_URL=$birdnetlog_url", $contents2);
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
}
}
if(isset($_POST["birdnetpi_url"])) {
$birdnetpi_url = $_POST["birdnetpi_url"];
if(strcmp($birdnetpi_url,$config['BIRDNETPI_URL']) !== 0) {
$contents = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents);
$contents2 = preg_replace("/BIRDNETPI_URL=.*/", "BIRDNETPI_URL=$birdnetpi_url", $contents2);
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
exec('sudo /usr/local/bin/update_caddyfile.sh > /dev/null 2>&1 &');
}
}
if(isset($_POST["overlap"])) {
$overlap = $_POST["overlap"];
if(strcmp($overlap,$config['OVERLAP']) !== 0) {
$contents = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents);
$contents2 = preg_replace("/OVERLAP=.*/", "OVERLAP=$overlap", $contents2);
}
}
if(isset($_POST["confidence"])) {
$confidence = $_POST["confidence"];
if(strcmp($confidence,$config['CONFIDENCE']) !== 0) {
$contents = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents);
$contents2 = preg_replace("/CONFIDENCE=.*/", "CONFIDENCE=$confidence", $contents2);
}
}
if(isset($_POST["sensitivity"])) {
$sensitivity = $_POST["sensitivity"];
if(strcmp($sensitivity,$config['SENSITIVITY']) !== 0) {
$contents = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents);
$contents2 = preg_replace("/SENSITIVITY=.*/", "SENSITIVITY=$sensitivity", $contents2);
}
}
if(isset($_POST["full_disk"])) {
$full_disk = $_POST["full_disk"];
if(strcmp($full_disk,$config['FULL_DISK']) !== 0) {
$contents = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents);
$contents2 = preg_replace("/FULL_DISK=.*/", "FULL_DISK=$full_disk", $contents2);
}
}
if(isset($_POST["rec_card"])) {
$rec_card = $_POST["rec_card"];
if(strcmp($rec_card,$config['REC_CARD']) !== 0) {
$contents = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents);
$contents2 = preg_replace("/REC_CARD=.*/", "REC_CARD=$rec_card", $contents2);
}
}
if(isset($_POST["channels"])) {
$channels = $_POST["channels"];
if(strcmp($channels,$config['CHANNELS']) !== 0) {
$contents = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents);
$contents2 = preg_replace("/CHANNELS=.*/", "CHANNELS=$channels", $contents2);
}
}
if(isset($_POST["recording_length"])) {
$recording_length = $_POST["recording_length"];
if(strcmp($recording_length,$config['RECORDING_LENGTH']) !== 0) {
$contents = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents);
$contents2 = preg_replace("/RECORDING_LENGTH=.*/", "RECORDING_LENGTH=$recording_length", $contents2);
}
}
if(isset($_POST["extraction_length"])) {
$extraction_length = $_POST["extraction_length"];
if(strcmp($extraction_length,$config['EXTRACTION_LENGTH']) !== 0) {
$contents = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents);
$contents2 = preg_replace("/EXTRACTION_LENGTH=.*/", "EXTRACTION_LENGTH=$extraction_length", $contents2);
}
}
if(isset($_POST["audiofmt"])) {
$audiofmt = $_POST["audiofmt"];
if(strcmp($audiofmt,$config['AUDIOFMT']) !== 0) {
$contents = preg_replace("/AUDIOFMT=.*/", "AUDIOFMT=$audiofmt", $contents);
$contents2 = preg_replace("/AUDIOFMT=.*/", "AUDIOFMT=$audiofmt", $contents2);
}
}
$fh = fopen("/home/pi/BirdNET-Pi/birdnet.conf", "w");
$fh2 = fopen("/home/pi/BirdNET-Pi/thisrun.txt", "w");
fwrite($fh, $contents);
fwrite($fh2, $contents2);
}
?>
-11
View File
@@ -1,11 +0,0 @@
#!/usr/bin/env bash
# Update database password
source /etc/birdnet/birdnet.conf
mysql -e "
SET PASSWORD FOR 'birder'@'localhost' = PASSWORD('${DB_PWD}');
FLUSH PRIVILEGES";
sed -i "s/mysqli.default_host =.*/mysqli.default_host = localhost/g" /etc/php/7.4/fpm/php.ini
sed -i "s/mysqli.default_user =.*/mysqli.default_user = birder/g" /etc/php/7.4/fpm/php.ini
sed -i "s/mysqli.default_pw =.*/mysqli.default_pw = ${DB_PWD}/g" /etc/php/7.4/fpm/php.ini
systemctl restart php7.4-fpm.service
-38
View File
@@ -1,38 +0,0 @@
<?php
$timer=60;
header( "refresh:$timer;url=/overview.php" );
?>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head></head>
<body style="background-color: rgb(119, 196, 135)">
<script>
function countDown(secs,elem) {
var element = document.getElementById(elem);
element.innerHTML = "Update in progress. Please allow another "+secs+" seconds for it to complete.";
if(secs < 1) {
clearTimeout(timer);
element.innerHTML = '<h4>Let\'s see</h4>';
}
secs--;
var timer = setTimeout('countDown('+secs+',"'+elem+'")',1000);
}
</script>
<div id="status"style="font-size:30px;"></div>
<script>countDown(<?php echo $timer;?>,"status");</script>
</body>
</html>
-38
View File
@@ -1,38 +0,0 @@
<?php
$timer=30;
header( "refresh:$timer;url=/advanced.php" );
?>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head></head>
<body style="background-color: rgb(119, 196, 135)">
<script>
function countDown(secs,elem) {
var element = document.getElementById(elem);
element.innerHTML = "Updating settings... Please allow another "+secs+" seconds for it to complete.";
if(secs < 1) {
clearTimeout(timer);
element.innerHTML = '<h4>Let\'s see</h4>';
}
secs--;
var timer = setTimeout('countDown('+secs+',"'+elem+'")',1000);
}
</script>
<div id="status"style="font-size:30px;"></div>
<script>countDown(<?php echo $timer;?>,"status");</script>
</body>
</html>
-167
View File
@@ -1,167 +0,0 @@
#!/usr/bin/env bash
# BirdNET-Pi Welcome Wiz!
#trap 'systemctl --user disable birdnet-pi-config-gui.service' EXIT 0
set -x
birdnet_config=/home/pi/BirdNET-Pi/birdnet.conf
zenity --title="Welcome!" --ok-label="Next" --window-icon=/usr/share/pixmaps/red-cardinal32.png \
--info --text="
Thank for you installing BirdNET-Pi\!" --no-wrap --icon-name=red-cardinal
[ $? -eq 1 ] && exit 1
overview() {
zenity --title="Configuration Wizard" --window-icon=/usr/share/pixmaps/red-cardinal32.png --width=300 --ok-label="Exit" \
--extra-button="Next" --info --text="This will walk you through the following steps:
1) Change the 'pi' user password
2) Setting your Language, Country, Timezone, Keyboard, and WiFi Country (if applicable)
3) Connect to WiFi (if applicable) / Set Date and Time (if applicable)
4) Set BirdNET-Pi's latitude and longitude
5) Set the web interface and database passwords
6) Updating the system to use your new birdnet.conf file" --no-wrap --icon-name=red-cardinal
if [ $? -eq 0 ];then
exit 0
elif [ $? -eq 1 ];then
open_rpi_configuration && change_password
fi
}
change_password() {
zenity --title="Change the 'pi' user password" \
--window-icon=/usr/share/pixmaps/red-cardinal32.png --ok-label="Back" \
--extra-button="Continue" --info --text="Click the button labeled \"Change Password...\"
and enter your new password in each box." --no-wrap --icon-name=red-cardinal
if [ $? -eq 1 ];then
change_locale
else
overview
fi
}
change_locale() {
zenity --title="Setting Language, Country, Timezone, Keyboard, and WiFI Country" \
--window-icon=/usr/share/pixmaps/red-cardinal32.png --ok-label="Back" \
--extra-button="Continue" --info --text="Use the right-most tab labeled \"Localisation\"
1) Locale: Set your Language and Country -- leave Character Set as \"UTF-8\"
2) Timezone: Set your Area and Location
3) Keyboard: Set your keyboard
4) WiFi Country: Choose your country from the list" --no-wrap --icon-name=red-cardinal
if [ $? -eq 1 ];then
sync_clock
else
change_password
fi
}
sync_clock() {
zenity --title="Connecting to WiFi/Setting the Date and Time" --window-icon=/usr/share/pixmaps/red-cardinal32.png \
--question --ok-label="Automatically" --cancel-label="Manually" --icon-name=red-cardinal --text="Should the installation update the date and time Automatically (using the internet),
or will you do this Manually?" --no-wrap
if [ $? -eq 1 ];then
get_date_and_time
else
setup_wifi
fi
}
get_date_and_time() {
full_date="$(zenity --forms --title="Set the current time" --window-icon=/usr/share/pixmaps/red-cardinal32.png --add-calendar=Calendar --add-combo="Current Hour (24h)" --combo-values="01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23" --add-combo="Current Minute" --combo-values="00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59" --add-combo="Current Second" --combo-values="00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59")"
current_date="$(echo ${full_date} | awk -F\| '{print $1}')"
if ! [ -z $current_date ];then
current_time="$(echo ${full_date} | awk -F\| '{print $1" "$2":"$3":"$4}')"
sudo date -s "${current_time}"
get_latitude
else
sync_clock
fi
}
setup_wifi() {
sudo systemctl start dhcpcd
wifi_list=""
until [[ "${wifi_list}" == "Continue" ]];do
wifi_list="$(zenity --title="Connect to WiFi" --extra-button="Refresh WiFi List" --window-icon=/usr/share/pixmaps/red-cardinal32.png --info --text="Use the Networking Icon in the bottom right corner of
the screen to select your WiFi network. Enter the credentials to connect when prompted.
If you are currently connected to BirdNET-Pi via its Access Point and VNC/NoMachine,
this connection will be severed as soon as the new connection is made.
Simply connect your VNC/NoMachine client to the network which you are
currently configuring BirdNET-Pi to use, and you will be able to resume the setup.
Press \"Continue\" AFTER you have connected." --ok-label="Continue" --no-wrap)"
[ -z ${wifi_list} ] && break
if [[ "${wifi_list}" == "Refresh WiFi List" ]];then
sudo systemctl restart dhcpcd
fi
done
get_latitude
}
open_rpi_configuration() {
if ! pgrep rc_gui;then
env SUDO_ASKPASS=/usr/lib/rc-gui/pwdrcg.sh sudo -AE rc_gui &
sleep 1.5
fi
}
get_latitude() {
new_lat="$(zenity --cancel-label="Back" --ok-label="Set" --title="Enter Your Latitude" --window-icon=/usr/share/pixmaps/red-cardinal32.png --width=300 --entry --text="Enter your Latitude.
A network guess: $(curl -s4 ifconfig.co/json | awk '/lat/ {print $2}' | tr -d ',')")"
if [ -n "$new_lat" ];then
get_longitude
else
change_locale
fi
}
get_longitude() {
new_lon="$(zenity --cancel-label="Back" --ok-label="Set" --title="Enter Your Longitude" --window-icon=/usr/share/pixmaps/red-cardinal32.png --width=300 --entry --text="Enter your Longitude.
A network guess: $(curl -s4 ifconfig.co/json | awk '/lon/ {print $2}' | tr -d ',')")"
if [ -n "$new_lon" ];then
set_caddy_pwd
else
get_latitude
fi
}
set_caddy_pwd() {
caddy_pwd="$(zenity --cancel-label="Back" --ok-label="Set" --title="Set Web Password" --window-icon=/usr/share/pixmaps/red-cardinal32.png --width=300 --entry --text="Set a new password for the web interface")"
if [ -n "${caddy_pwd}" ];then
set_db_pwd
else
get_longitude
fi
}
set_db_pwd() {
db_pwd="$(zenity --cancel-label="Back" --ok-label="Set" --title="Set The Database Password" --window-icon=/usr/share/pixmaps/red-cardinal32.png --width=300 --entry --text="Set a new password for the databse.")"
if [ -n "${db_pwd}" ];then
rearview
else
set_caddy_pwd
fi
}
overview