From 9c58e58d90b81471b0ea296cde67dfb41d43861c Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Mon, 27 Jun 2022 14:28:31 -0400 Subject: [PATCH 01/17] Weekly Report start --- homepage/views.php | 4 ++ scripts/update_birdnet_snippets.sh | 1 + scripts/weekly_report.php | 67 ++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 scripts/weekly_report.php diff --git a/homepage/views.php b/homepage/views.php index dd75f00..5618dad 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -46,6 +46,9 @@ body::-webkit-scrollbar {
+
+ +
@@ -90,6 +93,7 @@ if(isset($_GET['view'])){ if($_GET['view'] == "Overview"){include('overview.php');} if($_GET['view'] == "Today's Detections"){include('todays_detections.php');} if($_GET['view'] == "Species Stats"){include('stats.php');} + if($_GET['view'] == "Weekly Report"){include('weekly_report.php');} if($_GET['view'] == "Streamlit"){echo "";} if($_GET['view'] == "Daily Charts"){include('history.php');} if($_GET['view'] == "Tools"){ diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index c22d0bf..b03a0d7 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -94,6 +94,7 @@ if [[ "$pytest_installation_status" = "not installed" ]];then $HOME/BirdNET-Pi/birdnet/bin/pip3 install pytest==7.1.2 pytest-mock==3.7.0 fi +[ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted sudo systemctl daemon-reload restart_services.sh diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php new file mode 100644 index 0000000..0d8b262 --- /dev/null +++ b/scripts/weekly_report.php @@ -0,0 +1,67 @@ + +
Week ".date('W', $enddate)." Report".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate)."
"; +?>
prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) DESC LIMIT 10'); +if($statement1 == False){ + echo "Database is busy"; + header("refresh: 0;"); +} +$result1 = $statement1->execute(); + +?> +
+ + + + + + + +fetchArray(SQLITE3_ASSOC)) +{ + +$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); +if($statement2 == False){ + echo "Database is busy"; + header("refresh: 0;"); +} +$result2 = $statement2->execute(); +$totalcount = $result2->fetchArray(SQLITE3_ASSOC); +$priorweekcount = $totalcount['COUNT(*)']; + +$percentagediff = round((1 - $priorweekcount / $detection["COUNT(*)"]) * 100); + +if($percentagediff > 0) { + $percentagediff = "+".$percentagediff."%"; +} else { + $percentagediff = "-".abs($percentagediff)."%"; +} + +echo ""; +} +?> + +
"; ?>
".$detection["Com_Name"]."
".$detection["COUNT(*)"]." (".$percentagediff.")
+ +
+
+ * percentages are calculated relative to week +
\ No newline at end of file From 4e3d880b1d942675a246bcbd787713ab85da738d Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Mon, 27 Jun 2022 19:01:32 -0400 Subject: [PATCH 02/17] Species Seen for the First Time --- scripts/weekly_report.php | 134 ++++++++++++++++++++++++++++---------- 1 file changed, 100 insertions(+), 34 deletions(-) diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php index 0d8b262..59a7c61 100644 --- a/scripts/weekly_report.php +++ b/scripts/weekly_report.php @@ -5,6 +5,8 @@ error_reporting(E_ALL); $startdate = strtotime('last sunday') - (7*86400); $enddate = strtotime('last sunday') - (1*86400); + +$debug = false; ?>
Week ".date('W', $enddate)." Report".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate)."
"; @@ -16,50 +18,114 @@ if($db == False){ header("refresh: 0;"); } - -$statement1 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) DESC LIMIT 10'); +if($debug == false){ +$statement1 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) DESC'); +} else { + $statement1 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) ASC'); +} if($statement1 == False){ echo "Database is busy"; header("refresh: 0;"); } $result1 = $statement1->execute(); -?> -
- - - - - - - -fetchArray(SQLITE3_ASSOC)) { - -$statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); -if($statement2 == False){ - echo "Database is busy"; - header("refresh: 0;"); -} -$result2 = $statement2->execute(); -$totalcount = $result2->fetchArray(SQLITE3_ASSOC); -$priorweekcount = $totalcount['COUNT(*)']; - -$percentagediff = round((1 - $priorweekcount / $detection["COUNT(*)"]) * 100); - -if($percentagediff > 0) { - $percentagediff = "+".$percentagediff."%"; -} else { - $percentagediff = "-".abs($percentagediff)."%"; -} - -echo ""; + if($debug == true){ + if($i > 10) { + break; + } + } + $i++; + array_push($detections, $detection); + } ?> - -
"; ?>
".$detection["Com_Name"]."
".$detection["COUNT(*)"]." (".$percentagediff.")
+
+ +
+ + + + + + + + prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); + if($statement2 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result2 = $statement2->execute(); + $totalcount = $result2->fetchArray(SQLITE3_ASSOC); + $priorweekcount = $totalcount['COUNT(*)']; + + $percentagediff = round((1 - $priorweekcount / $detection["COUNT(*)"]) * 100); + + if($percentagediff > 0) { + $percentagediff = "+".$percentagediff."%"; + } else { + $percentagediff = "-".abs($percentagediff)."%"; + } + + echo ""; + } + } + ?> + +
"; ?>
".$detection["Com_Name"]."
".$detection["COUNT(*)"]." (".$percentagediff.")
+
+ + + + + + + + + $val) { + if ($val['Com_Name'] === $id) { + return $key; + } + } + return null; + } + + foreach($detections as $detection) + { + $statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date NOT BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'"'); + if($statement3 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result3 = $statement3->execute(); + $totalcount = $result3->fetchArray(SQLITE3_ASSOC); + $nonthisweekcount = $totalcount['COUNT(*)']; + + // TODO: add a "no species were seen for the first time this week", if applicable + + if($nonthisweekcount == 0) { + $key = array_search($detection["Com_Name"], array_column($detections, 'Com_Name')); + echo ""; + } + } + ?> + +
"; ?>
".$detection["Com_Name"]."
".$detections[$key]["COUNT(*)"]."
+
+
From 828d9d8757a1f48849d9308f708ebc0dd8ee0431 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 11:11:11 -0400 Subject: [PATCH 03/17] Initial notification support --- scripts/weekly_report.php | 57 +++++++++++++++++++++++++++ scripts/weekly_report_notification.sh | 6 +++ 2 files changed, 63 insertions(+) create mode 100644 scripts/weekly_report_notification.sh diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php index 59a7c61..9231ed3 100644 --- a/scripts/weekly_report.php +++ b/scripts/weekly_report.php @@ -7,6 +7,63 @@ $startdate = strtotime('last sunday') - (7*86400); $enddate = strtotime('last sunday') - (1*86400); $debug = false; + +if(isset($_GET['ascii'])) { + + $db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE); + if($db == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + + $statement1 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'" GROUP By Com_Name ORDER BY COUNT(*) DESC'); + if($statement1 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result1 = $statement1->execute(); + + $detections = []; + $i = 0; + while($detection=$result1->fetchArray(SQLITE3_ASSOC)) + { + array_push($detections, $detection); + } + + echo "# Week ".date('W', $enddate)." Report (".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate).")\n"; + + echo "= Top 10 Species =\n"; + + $i = 0; + foreach($detections as $detection) + { + $i++; + + if($i <= 10) { + $statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); + if($statement2 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result2 = $statement2->execute(); + $totalcount = $result2->fetchArray(SQLITE3_ASSOC); + $priorweekcount = $totalcount['COUNT(*)']; + + $percentagediff = round((1 - $priorweekcount / $detection["COUNT(*)"]) * 100); + + if($percentagediff > 0) { + $percentagediff = "+".$percentagediff."%"; + } else { + $percentagediff = "-".abs($percentagediff)."%"; + } + + echo $detection["Com_Name"]." - ".$detection["COUNT(*)"]." (".$percentagediff.")\n"; + } + } + + die(); +} + ?>
Week ".date('W', $enddate)." Report".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate)."
"; diff --git a/scripts/weekly_report_notification.sh b/scripts/weekly_report_notification.sh new file mode 100644 index 0000000..b78983b --- /dev/null +++ b/scripts/weekly_report_notification.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +NOTIFICATION=$(curl 'localhost/views.php?view=Weekly%20Report&ascii=true') +NOTIFICATION=${NOTIFICATION#*#} +firstLine=`echo "${NOTIFICATION}" | head -1` +NOTIFICATION=`echo "${NOTIFICATION}" | tail -n +2` +$HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t "${firstLine}" -b "${NOTIFICATION}" --config=$HOME/BirdNET-Pi/apprise.txt \ No newline at end of file From 5896f00a559eb0a83ffb85b2a65b096e89381928 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:04:59 -0400 Subject: [PATCH 04/17] Notification conf and cron setups --- birdnet.conf-defaults | 1 + scripts/install_config.sh | 1 + scripts/install_services.sh | 6 ++++++ scripts/update_birdnet_snippets.sh | 5 +++++ scripts/{weekly_report_notification.sh => weekly_report.sh} | 3 +++ templates/weekly_report.cron | 2 ++ 6 files changed, 18 insertions(+) rename scripts/{weekly_report_notification.sh => weekly_report.sh} (71%) create mode 100644 templates/weekly_report.cron diff --git a/birdnet.conf-defaults b/birdnet.conf-defaults index 88732b9..9baad16 100644 --- a/birdnet.conf-defaults +++ b/birdnet.conf-defaults @@ -62,6 +62,7 @@ APPRISE_NOTIFICATION_TITLE="New BirdNET-Pi Detection" APPRISE_NOTIFICATION_BODY="A \$sciname \$comname was just detected with a confidence of \$confidence" APPRISE_NOTIFY_EACH_DETECTION=0 APPRISE_NOTIFY_NEW_SPECIES=0 +APPRISE_WEEKLY_REPORT=0 #---------------------- Flickr Images API Configuration -----------------------# ## If FLICKR_API_KEY is set, the web interface will try and display bird images diff --git a/scripts/install_config.sh b/scripts/install_config.sh index dcb78c1..432146f 100755 --- a/scripts/install_config.sh +++ b/scripts/install_config.sh @@ -75,6 +75,7 @@ APPRISE_NOTIFICATION_TITLE="New BirdNET-Pi Detection" APPRISE_NOTIFICATION_BODY="A \$sciname \$comname was just detected with a confidence of \$confidence" APPRISE_NOTIFY_EACH_DETECTION=0 APPRISE_NOTIFY_NEW_SPECIES=0 +APPRISE_WEEKLY_REPORT=0 #---------------------- Flickr Images API Configuration -----------------------# ## If FLICKR_API_KEY is set, the web interface will try and display bird images diff --git a/scripts/install_services.sh b/scripts/install_services.sh index 17c4397..9df1fd2 100755 --- a/scripts/install_services.sh +++ b/scripts/install_services.sh @@ -111,6 +111,7 @@ create_necessary_dirs() { sudo -u ${USER} ln -fs $my_dir/scripts/stats.php ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/scripts/todays_detections.php ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/scripts/history.php ${EXTRACTED} + sudo -u ${USER} ln -fs $my_dir/scripts/weekly_report.php ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/homepage/images/favicon.ico ${EXTRACTED} sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/templates/phpsysinfo.ini ${HOME}/phpsysinfo/ @@ -406,6 +407,10 @@ install_cleanup_cron() { sed "s/\$USER/$USER/g" $my_dir/templates/cleanup.cron >> /etc/crontab } +install_weekly_cron() { + sed "s/\$USER/$USER/g" $my_dir/templates/weekly_report.cron >> /etc/crontab +} + chown_things() { chown -R $USER:$USER $HOME/Bird* } @@ -431,6 +436,7 @@ install_services() { install_phpsysinfo install_livestream_service install_cleanup_cron + install_weekly_cron create_necessary_dirs generate_BirdDB diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index b03a0d7..3bcb774 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -95,6 +95,11 @@ if [[ "$pytest_installation_status" = "not installed" ]];then fi [ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted +[ -L /usr/local/bin/weekly_report.sh ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh +sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron >> /etc/crontab +if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then + sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf +fi sudo systemctl daemon-reload restart_services.sh diff --git a/scripts/weekly_report_notification.sh b/scripts/weekly_report.sh similarity index 71% rename from scripts/weekly_report_notification.sh rename to scripts/weekly_report.sh index b78983b..f52f4d2 100644 --- a/scripts/weekly_report_notification.sh +++ b/scripts/weekly_report.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +source /etc/birdnet/birdnet.conf +echo ${APPRISE_WEEKLY_REPORT} + NOTIFICATION=$(curl 'localhost/views.php?view=Weekly%20Report&ascii=true') NOTIFICATION=${NOTIFICATION#*#} firstLine=`echo "${NOTIFICATION}" | head -1` diff --git a/templates/weekly_report.cron b/templates/weekly_report.cron new file mode 100644 index 0000000..466c749 --- /dev/null +++ b/templates/weekly_report.cron @@ -0,0 +1,2 @@ +#birdnet +0 7 * * 1 $USER /usr/local/bin/weekly_report.sh >/dev/null 2>&1 \ No newline at end of file From 49e67d2247402a92dc50146c59b7c515a8f48c34 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:09:23 -0400 Subject: [PATCH 05/17] Update update_birdnet_snippets.sh --- scripts/update_birdnet_snippets.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index 3bcb774..a65ec40 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -95,7 +95,7 @@ if [[ "$pytest_installation_status" = "not installed" ]];then fi [ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted -[ -L /usr/local/bin/weekly_report.sh ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh +[ -L /usr/local/bin/weekly_report.sh ] || chmod +x $HOME/BirdNET-Pi/scripts/weekly_report.sh; ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron >> /etc/crontab if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf From 655b1eaf09c1fee8eaa3fd90f52fdc38791eebe4 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:10:44 -0400 Subject: [PATCH 06/17] Update update_birdnet_snippets.sh --- scripts/update_birdnet_snippets.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index a65ec40..08dc6b2 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -95,7 +95,7 @@ if [[ "$pytest_installation_status" = "not installed" ]];then fi [ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted -[ -L /usr/local/bin/weekly_report.sh ] || chmod +x $HOME/BirdNET-Pi/scripts/weekly_report.sh; ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh +[ -L /usr/local/bin/weekly_report.sh ] || sudo chmod +x $HOME/BirdNET-Pi/scripts/weekly_report.sh; ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron >> /etc/crontab if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf From ab07e8c0f5e16a41a6c9391f18833b54f6ce567e Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:13:52 -0400 Subject: [PATCH 07/17] Update update_birdnet_snippets.sh --- scripts/update_birdnet_snippets.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index 08dc6b2..f1768fb 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -95,7 +95,7 @@ if [[ "$pytest_installation_status" = "not installed" ]];then fi [ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted -[ -L /usr/local/bin/weekly_report.sh ] || sudo chmod +x $HOME/BirdNET-Pi/scripts/weekly_report.sh; ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh +[ -L /usr/local/bin/weekly_report.sh ] || sudo chmod +x $HOME/BirdNET-Pi/scripts/weekly_report.sh && ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron >> /etc/crontab if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf From 7cc4506524ecc6218f174091f62e17ea0e9fd2c9 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:09:03 -0400 Subject: [PATCH 08/17] fixes --- scripts/clear_all_data.sh | 1 + scripts/update_birdnet_snippets.sh | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/clear_all_data.sh b/scripts/clear_all_data.sh index d574f5e..7108534 100755 --- a/scripts/clear_all_data.sh +++ b/scripts/clear_all_data.sh @@ -34,6 +34,7 @@ sudo -u ${USER} ln -fs $my_dir/overview.php ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/stats.php ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/todays_detections.php ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/history.php ${EXTRACTED} +sudo -u ${USER} ln -fs $my_dir/weekly_report.php ${EXTRACTED} sudo -u ${USER} ln -fs $my_dir/homepage/images/favicon.ico ${EXTRACTED} sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED} sudo -u ${USER} ln -fs $(dirname $my_dir)/templates/phpsysinfo.ini ${HOME}/phpsysinfo/ diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index f1768fb..baee18f 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -95,8 +95,7 @@ if [[ "$pytest_installation_status" = "not installed" ]];then fi [ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted -[ -L /usr/local/bin/weekly_report.sh ] || sudo chmod +x $HOME/BirdNET-Pi/scripts/weekly_report.sh && ln -sf ~/BirdNET-Pi/scripts/weekly_report.php /usr/local/bin/weekly_report.sh -sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron >> /etc/crontab +sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron | sudo tee -a /etc/crontab if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf fi From 512f05b9f326506d6cdffd46dcacccb4755f9cd4 Mon Sep 17 00:00:00 2001 From: ehpersonal38 Date: Tue, 28 Jun 2022 14:11:12 -0400 Subject: [PATCH 09/17] perms --- scripts/weekly_report.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/weekly_report.sh diff --git a/scripts/weekly_report.sh b/scripts/weekly_report.sh old mode 100644 new mode 100755 From 0540e18967846f511f934ff0f87ed30afb22e7e3 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:14:28 -0400 Subject: [PATCH 10/17] Update update_birdnet_snippets.sh --- scripts/update_birdnet_snippets.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index baee18f..7357167 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -95,7 +95,10 @@ if [[ "$pytest_installation_status" = "not installed" ]];then fi [ -L ~/BirdSongs/Extracted/weekly_report.php ] || ln -sf ~/BirdNET-Pi/scripts/weekly_report.php ~/BirdSongs/Extracted -sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron | sudo tee -a /etc/crontab + +if ! grep weekly_report /etc/crontab &>/dev/null;then + sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron | sudo tee -a /etc/crontab +fi if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf fi From ca09725e81b096fe6f6f9d60ef09f0c02eca19ba Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Tue, 28 Jun 2022 14:18:05 -0400 Subject: [PATCH 11/17] Update weekly_report.sh --- scripts/weekly_report.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/weekly_report.sh b/scripts/weekly_report.sh index f52f4d2..db605d2 100755 --- a/scripts/weekly_report.sh +++ b/scripts/weekly_report.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash source /etc/birdnet/birdnet.conf -echo ${APPRISE_WEEKLY_REPORT} - -NOTIFICATION=$(curl 'localhost/views.php?view=Weekly%20Report&ascii=true') -NOTIFICATION=${NOTIFICATION#*#} -firstLine=`echo "${NOTIFICATION}" | head -1` -NOTIFICATION=`echo "${NOTIFICATION}" | tail -n +2` -$HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t "${firstLine}" -b "${NOTIFICATION}" --config=$HOME/BirdNET-Pi/apprise.txt \ No newline at end of file +if [ ${APPRISE_WEEKLY_REPORT} == 1 ];then + NOTIFICATION=$(curl 'localhost/views.php?view=Weekly%20Report&ascii=true') + NOTIFICATION=${NOTIFICATION#*#} + firstLine=`echo "${NOTIFICATION}" | head -1` + NOTIFICATION=`echo "${NOTIFICATION}" | tail -n +2` + $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t "${firstLine}" -b "${NOTIFICATION}" --config=$HOME/BirdNET-Pi/apprise.txt +fi \ No newline at end of file From 23c35e4fe0c83a47182ff73ee7b9b17b4af72ff4 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 29 Jun 2022 09:01:51 -0400 Subject: [PATCH 12/17] fixing formatting on email --- scripts/weekly_report.php | 77 +++++++++++++++++++++--------------- scripts/weekly_report.sh | 2 +- templates/weekly_report.cron | 2 +- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php index 9231ed3..c0966e6 100644 --- a/scripts/weekly_report.php +++ b/scripts/weekly_report.php @@ -1,7 +1,4 @@ fetchArray(SQLITE3_ASSOC)) { - array_push($detections, $detection); + $detections[$detection["Com_Name"]] = $detection["COUNT(*)"]; } echo "# Week ".date('W', $enddate)." Report (".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate).")\n"; - echo "= Top 10 Species =\n"; + echo "= Top 10 Species =
"; $i = 0; - foreach($detections as $detection) + foreach($detections as $com_name=>$scount) { $i++; if($i <= 10) { - $statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); + $statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$com_name.'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); if($statement2 == False){ echo "Database is busy"; header("refresh: 0;"); @@ -49,18 +46,41 @@ if(isset($_GET['ascii'])) { $totalcount = $result2->fetchArray(SQLITE3_ASSOC); $priorweekcount = $totalcount['COUNT(*)']; - $percentagediff = round((1 - $priorweekcount / $detection["COUNT(*)"]) * 100); + $percentagediff = round((1 - $priorweekcount / $scount) * 100); if($percentagediff > 0) { - $percentagediff = "+".$percentagediff."%"; + $percentagediff = "+".$percentagediff."%"; } else { - $percentagediff = "-".abs($percentagediff)."%"; + $percentagediff = "-".abs($percentagediff)."%"; } - echo $detection["Com_Name"]." - ".$detection["COUNT(*)"]." (".$percentagediff.")\n"; + echo $com_name." - ".$scount." (".$percentagediff.")
"; } } + echo "
= Species Detected for the First Time: =
"; + + $newspeciescount=0; + foreach($detections as $com_name=>$scount) + { + $statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$com_name.'" AND Date NOT BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'"'); + if($statement3 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result3 = $statement3->execute(); + $totalcount = $result3->fetchArray(SQLITE3_ASSOC); + $nonthisweekcount = $totalcount['COUNT(*)']; + + if($nonthisweekcount == 0) { + $newspeciescount++; + echo $com_name." - ".$scount."
"; + } + } + if($newspeciescount == 0) { + echo "No new species were seen this week."; + } + die(); } @@ -96,7 +116,7 @@ while($detection=$result1->fetchArray(SQLITE3_ASSOC)) } } $i++; - array_push($detections, $detection); + $detections[$detection["Com_Name"]] = $detection["COUNT(*)"]; } ?> @@ -113,12 +133,11 @@ while($detection=$result1->fetchArray(SQLITE3_ASSOC)) $scount) { $i++; - if($i <= 10) { - $statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); + $statement2 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$com_name.'" AND Date BETWEEN "'.date("Y-m-d",$startdate - (7*86400)).'" AND "'.date("Y-m-d",$enddate - (7*86400)).'"'); if($statement2 == False){ echo "Database is busy"; header("refresh: 0;"); @@ -127,7 +146,7 @@ while($detection=$result1->fetchArray(SQLITE3_ASSOC)) $totalcount = $result2->fetchArray(SQLITE3_ASSOC); $priorweekcount = $totalcount['COUNT(*)']; - $percentagediff = round((1 - $priorweekcount / $detection["COUNT(*)"]) * 100); + $percentagediff = round((1 - $priorweekcount / $scount) * 100); if($percentagediff > 0) { $percentagediff = "+".$percentagediff."%"; @@ -135,7 +154,7 @@ while($detection=$result1->fetchArray(SQLITE3_ASSOC)) $percentagediff = "-".abs($percentagediff)."%"; } - echo "".$detection["Com_Name"]."
".$detection["COUNT(*)"]." (".$percentagediff.")
"; + echo "".$com_name."
".$scount." (".$percentagediff.")
"; } } ?> @@ -146,23 +165,16 @@ while($detection=$result1->fetchArray(SQLITE3_ASSOC)) - + $val) { - if ($val['Com_Name'] === $id) { - return $key; - } - } - return null; - } - foreach($detections as $detection) + $newspeciescount=0; + foreach($detections as $com_name=>$scount) { - $statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$detection["Com_Name"].'" AND Date NOT BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'"'); + $statement3 = $db->prepare('SELECT COUNT(*) FROM detections WHERE Com_Name == "'.$com_name.'" AND Date NOT BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'"'); if($statement3 == False){ echo "Database is busy"; header("refresh: 0;"); @@ -171,13 +183,14 @@ while($detection=$result1->fetchArray(SQLITE3_ASSOC)) $totalcount = $result3->fetchArray(SQLITE3_ASSOC); $nonthisweekcount = $totalcount['COUNT(*)']; - // TODO: add a "no species were seen for the first time this week", if applicable - if($nonthisweekcount == 0) { - $key = array_search($detection["Com_Name"], array_column($detections, 'Com_Name')); - echo ""; + $newspeciescount++; + echo ""; } } + if($newspeciescount == 0) { + echo ""; + } ?>
"; ?>"; ?>
".$detection["Com_Name"]."
".$detections[$key]["COUNT(*)"]."
".$com_name."
".$scount."
No new species were seen this week.
diff --git a/scripts/weekly_report.sh b/scripts/weekly_report.sh index db605d2..8bfaee7 100755 --- a/scripts/weekly_report.sh +++ b/scripts/weekly_report.sh @@ -5,5 +5,5 @@ if [ ${APPRISE_WEEKLY_REPORT} == 1 ];then NOTIFICATION=${NOTIFICATION#*#} firstLine=`echo "${NOTIFICATION}" | head -1` NOTIFICATION=`echo "${NOTIFICATION}" | tail -n +2` - $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t "${firstLine}" -b "${NOTIFICATION}" --config=$HOME/BirdNET-Pi/apprise.txt + $HOME/BirdNET-Pi/birdnet/bin/apprise -vv -t "${firstLine}" -b "${NOTIFICATION}" --input-format=html --config=$HOME/BirdNET-Pi/apprise.txt fi \ No newline at end of file diff --git a/templates/weekly_report.cron b/templates/weekly_report.cron index 466c749..1475f25 100644 --- a/templates/weekly_report.cron +++ b/templates/weekly_report.cron @@ -1,2 +1,2 @@ #birdnet -0 7 * * 1 $USER /usr/local/bin/weekly_report.sh >/dev/null 2>&1 \ No newline at end of file +0 1 * * 1 $USER /usr/local/bin/weekly_report.sh >/dev/null 2>&1 \ No newline at end of file From 5b147caa8936fb38f20e9b6d2c136a5e0a805058 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 29 Jun 2022 09:02:53 -0400 Subject: [PATCH 13/17] Update weekly_report.php --- scripts/weekly_report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php index c0966e6..0fbf2e1 100644 --- a/scripts/weekly_report.php +++ b/scripts/weekly_report.php @@ -58,7 +58,7 @@ if(isset($_GET['ascii'])) { } } - echo "
= Species Detected for the First Time: =
"; + echo "
= Species Detected for the First Time =
"; $newspeciescount=0; foreach($detections as $com_name=>$scount) From 1c28e6d0cfef82e7c92fa02572e0a28ddf226db0 Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 29 Jun 2022 10:25:40 -0400 Subject: [PATCH 14/17] config checkbox --- scripts/config.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/config.php b/scripts/config.php index 023499e..2aafa7f 100644 --- a/scripts/config.php +++ b/scripts/config.php @@ -46,6 +46,11 @@ if(isset($_GET["latitude"])){ } else { $apprise_notify_new_species_each_day = 0; } + if(isset($_GET['apprise_weekly_report'])) { + $apprise_weekly_report = 1; + } else { + $apprise_weekly_report = 0; + } if(isset($timezone)) { shell_exec("sudo timedatectl set-timezone ".$timezone); @@ -101,6 +106,7 @@ if(isset($_GET["latitude"])){ $contents = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents); $contents = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents); $contents = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=.*/", "APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=$apprise_notify_new_species_each_day", $contents); + $contents = preg_replace("/APPRISE_WEEKLY_REPORT=.*/", "APPRISE_WEEKLY_REPORT=$apprise_weekly_report", $contents); $contents = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents); $contents = preg_replace("/DATABASE_LANG=.*/", "DATABASE_LANG=$language", $contents); $contents = preg_replace("/FLICKR_FILTER_EMAIL=.*/", "FLICKR_FILTER_EMAIL=$flickr_filter_email", $contents); @@ -114,6 +120,7 @@ if(isset($_GET["latitude"])){ $contents2 = preg_replace("/APPRISE_NOTIFY_EACH_DETECTION=.*/", "APPRISE_NOTIFY_EACH_DETECTION=$apprise_notify_each_detection", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES=.*/", "APPRISE_NOTIFY_NEW_SPECIES=$apprise_notify_new_species", $contents2); $contents2 = preg_replace("/APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=.*/", "APPRISE_NOTIFY_NEW_SPECIES_EACH_DAY=$apprise_notify_new_species_each_day", $contents2); + $contents2 = preg_replace("/APPRISE_WEEKLY_REPORT=.*/", "APPRISE_WEEKLY_REPORT=$apprise_weekly_report", $contents2); $contents2 = preg_replace("/FLICKR_API_KEY=.*/", "FLICKR_API_KEY=$flickr_api_key", $contents2); $contents2 = preg_replace("/DATABASE_LANG=.*/", "DATABASE_LANG=$language", $contents2); $contents2 = preg_replace("/FLICKR_FILTER_EMAIL=.*/", "FLICKR_FILTER_EMAIL=$flickr_filter_email", $contents2); @@ -329,9 +336,11 @@ https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken} >
> -
+
> -

+
+ > +


From b6bf1bedcaeb06c0e50a0cbe4de01c3e8972b36e Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 29 Jun 2022 17:09:38 -0400 Subject: [PATCH 15/17] More stats, formatting --- homepage/views.php | 3 -- scripts/weekly_report.php | 60 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/homepage/views.php b/homepage/views.php index 5618dad..56ae606 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -46,9 +46,6 @@ body::-webkit-scrollbar {
-
- -
diff --git a/scripts/weekly_report.php b/scripts/weekly_report.php index 0fbf2e1..4968c3f 100644 --- a/scripts/weekly_report.php +++ b/scripts/weekly_report.php @@ -1,4 +1,7 @@ execute(); + $statement4 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'"'); + if($statement4 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result4 = $statement4->execute(); + $totalcount = $result4->fetchArray(SQLITE3_ASSOC)['COUNT(*)']; + + $statement5 = $db->prepare('SELECT DISTINCT(Com_Name), COUNT(*) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate- (7*86400)).'" AND "'.date("Y-m-d",$enddate- (7*86400)).'"'); + if($statement5 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result5 = $statement5->execute(); + $priortotalcount = $result5->fetchArray(SQLITE3_ASSOC)['COUNT(*)']; + + $statement6 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate).'" AND "'.date("Y-m-d",$enddate).'"'); + if($statement6 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result6 = $statement6->execute(); + $totalspeciestally = $result6->fetchArray(SQLITE3_ASSOC)['COUNT(DISTINCT(Com_Name))']; + + $statement7 = $db->prepare('SELECT COUNT(DISTINCT(Com_Name)) FROM detections WHERE Date BETWEEN "'.date("Y-m-d",$startdate- (7*86400)).'" AND "'.date("Y-m-d",$enddate- (7*86400)).'"'); + if($statement7 == False){ + echo "Database is busy"; + header("refresh: 0;"); + } + $result7= $statement7->execute(); + $priortotalspeciestally = $result7->fetchArray(SQLITE3_ASSOC)['COUNT(DISTINCT(Com_Name))']; + + $percentagedifftotal = round((1 - $priortotalcount / $totalcount) * 100); + + if($percentagedifftotal > 0) { + $percentagedifftotal = "+".$percentagedifftotal."%"; + } else { + $percentagedifftotal = "-".abs($percentagedifftotal)."%"; + } + + $percentagedifftotaldistinctspecies = round((1 - $priortotalspeciestally / $totalspeciestally) * 100); + if($percentagedifftotaldistinctspecies > 0) { + $percentagedifftotaldistinctspecies = "+".$percentagedifftotaldistinctspecies."%"; + } else { + $percentagedifftotaldistinctspecies = "-".abs($percentagedifftotaldistinctspecies)."%"; + } + $detections = []; $i = 0; while($detection=$result1->fetchArray(SQLITE3_ASSOC)) @@ -27,7 +77,10 @@ if(isset($_GET['ascii'])) { $detections[$detection["Com_Name"]] = $detection["COUNT(*)"]; } - echo "# Week ".date('W', $enddate)." Report (".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate).")\n"; + echo "# BirdNET-Pi: Week ".date('W', $enddate)." Report\n"; + + echo "Total Detections: ".$totalcount." (".$percentagedifftotal.")
"; + echo "Unique Species Detected: ".$totalspeciestally." (".$percentagedifftotaldistinctspecies.")

"; echo "= Top 10 Species =
"; @@ -81,6 +134,9 @@ if(isset($_GET['ascii'])) { echo "No new species were seen this week."; } + echo "
* data from ".date('F jS, Y',$startdate)." — ".date('F jS, Y',$enddate).".
"; + echo '* percentages are calculated relative to week '.(date('W', $enddate) - 1).'.'; + die(); } @@ -199,5 +255,5 @@ while($detection=$result1->fetchArray(SQLITE3_ASSOC))
- * percentages are calculated relative to week +
* percentages are calculated relative to week
\ No newline at end of file From 4601dd2f09f20a681b1fc3891fc25ef1eaff7b6e Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 29 Jun 2022 17:40:53 -0400 Subject: [PATCH 16/17] better for testing --- scripts/update_birdnet_snippets.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/update_birdnet_snippets.sh b/scripts/update_birdnet_snippets.sh index 7357167..fe90caf 100755 --- a/scripts/update_birdnet_snippets.sh +++ b/scripts/update_birdnet_snippets.sh @@ -100,7 +100,7 @@ if ! grep weekly_report /etc/crontab &>/dev/null;then sed "s/\$USER/$USER/g" $HOME/BirdNET-Pi/templates/weekly_report.cron | sudo tee -a /etc/crontab fi if ! grep APPRISE_WEEKLY_REPORT /etc/birdnet/birdnet.conf &>/dev/null;then - sudo -u$USER echo "APPRISE_WEEKLY_REPORT=0" >> /etc/birdnet/birdnet.conf + sudo -u$USER echo "APPRISE_WEEKLY_REPORT=1" >> /etc/birdnet/birdnet.conf fi sudo systemctl daemon-reload From b3650365506ebaab3eb0cb36bf4be1a24194ad4c Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Fri, 1 Jul 2022 13:20:04 -0400 Subject: [PATCH 17/17] =?UTF-8?q?(=E2=95=AF=C2=B0=E2=96=A1=C2=B0)=E2=95=AF?= =?UTF-8?q?=EF=B8=B5=20=E2=94=BB=E2=94=81=E2=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I feel like I'm walking through a minefield with this linux stuff - a lack of a linebreak on a .cron file can break so many things?? --- templates/weekly_report.cron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/weekly_report.cron b/templates/weekly_report.cron index 1475f25..7c4f50d 100644 --- a/templates/weekly_report.cron +++ b/templates/weekly_report.cron @@ -1,2 +1,2 @@ #birdnet -0 1 * * 1 $USER /usr/local/bin/weekly_report.sh >/dev/null 2>&1 \ No newline at end of file +0 1 * * 1 $USER /usr/local/bin/weekly_report.sh >/dev/null 2>&1