rearranging the tools page to add system_controls and service_controls

This commit is contained in:
mcguirepr89
2022-01-31 12:34:57 -05:00
parent eb218030e5
commit 1cd1dbeecf
4 changed files with 192 additions and 50 deletions
+26 -22
View File
@@ -8,12 +8,12 @@ HOME=/home/pi
USER=pi
my_dir=${HOME}/BirdNET-Pi/scripts
echo "Stopping services"
sudo systemctl stop birdnet_recording.service
/usr/local/bin/stop_core_services.sh
echo "Removing all data . . . "
sudo rm -drf "${RECS_DIR}"
sudo rm -f "${IDFILE}"
sudo rm -f $(dirname ${my_dir})/BirdDB.txt
echo "Recreating necessary directories"
echo "Creating necessary directories"
[ -d ${EXTRACTED} ] || sudo -u ${USER} mkdir -p ${EXTRACTED}
[ -d ${EXTRACTED}/By_Date ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Date
[ -d ${EXTRACTED}/By_Common_Name ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Common_Name
@@ -24,50 +24,54 @@ echo "Recreating necessary directories"
sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/* ${EXTRACTED}
if [ ! -z ${BIRDNETLOG_URL} ];then
BIRDNETLOG_URL="$(echo ${BIRDNETLOG_URL} | sed 's/\/\//\\\/\\\//g')"
sudo -u ${USER} sed -i "s/http:\/\/birdnetpi.local:8080/"${BIRDNETLOG_URL}"/g" $(dirname ${my_dir})/homepage/*.html
phpfiles="$(grep -l "birdnetpi.local:8080" ${my_dir}/*.php)"
sudo -u${USER} sed -i "s/http:\/\/$(hostname).local:8080/"${BIRDNETLOG_URL}"/g" $(dirname ${my_dir})/homepage/*.html
phpfiles="$(grep -l "$(hostname).local:8080" ${my_dir}/*.php)"
for i in "${phpfiles[@]}";do
sudo -u ${USER} sed -i "s/http:\/\/birdnetpi.local:8080/"${BIRDNETLOG_URL}"/g" ${i}
sudo -u${USER} sed -i "s/http:\/\/$(hostname).local:8080/"${BIRDNETLOG_URL}"/g" ${i}
done
fi
if [ ! -z ${EXTRACTIONLOG_URL} ];then
EXTRACTIONLOG_URL="$(echo ${EXTRACTIONLOG_URL} | sed 's/\/\//\\\/\\\//g')"
sudo -u ${USER} sed -i "s/http:\/\/birdnetpi.local:8888/"${EXTRACTIONLOG_URL}"/g" $(dirname ${my_dir})/homepage/*.html
phpfiles="$(grep -l "birdnetpi.local:8888" ${my_dir}/*.php)"
sudo -u${USER} sed -i "s/http:\/\/$(hostname).local:8888/"${EXTRACTIONLOG_URL}"/g" $(dirname ${my_dir})/homepage/*.html
phpfiles="$(grep -l "$(hostname).local:8888" ${my_dir}/*.php)"
for i in "${phpfiles[@]}";do
sudo -u ${USER} sed -i "s/http:\/\/birdnetpi.local:8888/"${EXTRACTIONLOG_URL}"/g" ${i}
sudo -u${USER} sed -i "s/http:\/\/$(hostname).local:8888/"${EXTRACTIONLOG_URL}"/g" ${i}
done
fi
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts ${EXTRACTED}
if [ ! -z ${BIRDNETPI_URL} ];then
if [ -z ${BIRDNETPI_URL} ];then
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/homepage/*.html
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.html
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.html
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.php
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*/*.php
else
BIRDNETPI_URL="$(echo ${BIRDNETPI_URL} | sed 's/\/\//\\\/\\\//g')"
sudo -u ${USER} sed -i "s/http:\/\/birdnetpi.local/"${BIRDNETPI_URL}"/g" $(dirname ${my_dir})/homepage/*.html
phpfiles="$(grep -l birdnetpi.local ${my_dir}/*.php)"
for i in "${phpfiles[@]}";do
sudo -u ${USER} sed -i "s/http:\/\/birdnetpi.local/"${BIRDNETPI_URL}"/g" ${i}
done
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/homepage/*.html
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.html
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.html
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.php
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*/*.php
fi
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/spectrogram.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewday.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/overview.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/scripts/viewdb.php ${EXTRACTED}
sudo -u ${USER} ln -fs $(dirname ${my_dir})/homepage/images/favicon.ico ${EXTRACTED}
sudo -u ${USER} ln -fs ${HOME}/phpsysinfo ${EXTRACTED}
sudo -u ${USER} cp -f $(dirname ${my_dir})/templates/phpsysinfo.ini ${HOME}/phpsysinfo/
sudo -u ${USER} cp -f $(dirname ${my_dir})/templates/green_bootstrap.css ${HOME}/phpsysinfo/templates/
sudo -u ${USER} cp -f $(dirname ${my_dir})/templates/index_bootstrap.html ${HOME}/phpsysinfo/templates/html
echo "Setting Wttr.in URL to "${LATITUDE}", "${LONGITUDE}""
sudo -u ${USER} git -C $(dirname ${my_dir}) checkout -f homepage/menu.html
sudo -u ${USER} sed -i "s/https:\/\/v2.wttr.in\//https:\/\/v2.wttr.in\/"${LATITUDE},${LONGITUDE}"/g" $(dirname ${my_dir})/homepage/menu.html
sudo -u${USER} sed -i "s/https:\/\/v2.wttr.in\//https:\/\/v2.wttr.in\/"${LATITUDE},${LONGITUDE}"/g" $(dirname ${my_dir})/homepage/menu.html
chmod -R g+rw $(dirname ${my_dir})
chmod -R g+rw ${RECS_DIR}
echo "Generating BirdDB.txt"
[ -f $(dirname ${my_dir})/BirdDB.txt ] || sudo -u ${USER} touch $(dirname ${my_dir})/BirdDB.txt
echo "Date;Time;Sci_Name;Com_Name;Confidence;Lat;Lon;Cutoff;Week;Sens;Overlap" | sudo -u ${BIRDNET_USER} tee -a $(dirname ${my_dir})/BirdDB.txt
sudo -u ${BIRDNET_USER} cp -f ${HOME}/BirdNET-Pi/homepage/index.html ${EXTRACTED}/
echo "Dropping and re-creating database"
sudo /home/pi/BirdNET-Pi/scripts/createdb_bullseye.sh
echo "Restarting services"
sudo systemctl restart birdnet_recording.service
/usr/local/bin/restart_services.sh
+9 -28
View File
@@ -68,41 +68,22 @@ a {
<form action="/scripts/config.php">
<button type="submit" class="block">Settings</button>
</form>
<form action="/scripts/system_controls.php">
<button type="submit" class="block">System Controls</button>
</form>
<form action="/scripts/reboot_system.php" onclick="return confirm('Are you sure you want to reboot?')">
<button type="submit" class="block">Reboot</button>
</form>
<form action="/scripts/update_birdnet.php" onclick="return confirm('BE SURE TO STASH ANY LOCAL CHANGES YOU HAVE MADE TO THE SYSTEM BEFORE UPDATING!!!')">
<button style="color:blue;" type="submit" class="block">Update</button>
</form>
<form action="/scripts/shutdown_system.php" onclick="return confirm('Are you sure you want to shutdown?')">
<button style="color: red;" type="submit" class="block">Shutdown</button>
</form>
<form action="/scripts/clear_all_data.php" onclick="return confirm('Clear ALL Data? This cannot be undone.')">
<button style="color: red;" type="submit" class="block">Clear ALL data</button>
</form>
</div>
<div class="column second">
<form action="http://birdnetpi.local:8888" target="top">
<form action="http://birdnetpi-4.local:8888" target="top">
<button type="submit" class="block">Web Terminal</button>
</form>
<form action="/scripts/stop_core_services.php" onclick="return confirm('Stop core services?')">
<button type="submit" class="block">Stop Core Services</button>
<form action="/scripts/service_controls.php">
<button type="submit" class="block">Manage Services</button>
</form>
<form action="/scripts/restart_services.php" onclick="return confirm('Restart ALL services?')">
<button type="submit" class="block">Restart ALL Services</button>
<form action="/scripts/include_list.php">
<button type="submit" class="block">Included Species List</button>
</form>
<form action="/scripts/restart_birdnet_analysis.php">
<button type="submit" class="block">Restart BirdNET Analysis</button>
</form>
<form action="/scripts/restart_birdnet_recording.php">
<button type="submit" class="block">Restart Recording</button>
</form>
<form action="/scripts/restart_extraction.php">
<button type="submit" class="block">Restart Extraction</button>
</form>
<form action="/scripts/restart_caddy.php" onclick="return confirm('Restart Caddy? You will be disconnected for about 20 seconds.')">
<button type="submit" class="block">Restart Caddy</button>
<form action="/scripts/exclude_list.php">
<button type="submit" class="block">Excluded Species List</button>
</form>
</div>
</div>
+82
View File
@@ -0,0 +1,82 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
' Calibri', 'Trebuchet MS', 'sans-serif';
box-sizing: border-box;
box-sizing: border-box;
}
/* Create two unequal columns that floats next to each other */
.column {
float: left;
padding: 10px;
}
.first {
width: calc(50% - 70px);
}
.second {
width: calc(50% - 30px);
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
body {
background-color: rgb(119, 196, 135);
}
a {
text-decoration: none;
color: white;
}
.block {
display: block;
font-weight: bold;
width:100%;
border: none;
background-color: #04AA6D;
padding: 20px 20px;
color: white;
font-size: medium;
cursor: pointer;
text-align: center;
}
@media screen and (max-width: 800px) {
.column {
float: none;
width: 100%;
}
}
</style>
<body style="background-color: rgb(119, 196, 135);">
<div class="row">
<div class="column first">
<form action="/scripts/stop_core_services.php" onclick="return confirm('Stop core services?')">
<button type="submit" class="block">Stop Core Services</button>
</form>
<form action="/scripts/restart_services.php" onclick="return confirm('Restart ALL services?')">
<button type="submit" class="block">Restart ALL Services</button>
</form>
<form action="/scripts/restart_birdnet_analysis.php">
<button type="submit" class="block">Restart BirdNET Analysis</button>
</form>
<form action="/scripts/restart_birdnet_recording.php">
<button type="submit" class="block">Restart Recording</button>
</form>
<form action="/scripts/restart_extraction.php">
<button type="submit" class="block">Restart Extraction</button>
</form>
<form action="/scripts/restart_caddy.php" onclick="return confirm('Restart Caddy? You will be disconnected for about 20 seconds.')">
<button type="submit" class="block">Restart Caddy</button>
</form>
</div>
</div>
</body>
+75
View File
@@ -0,0 +1,75 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
font-family: 'Arial', 'Gill Sans', 'Gill Sans MT',
' Calibri', 'Trebuchet MS', 'sans-serif';
box-sizing: border-box;
box-sizing: border-box;
}
/* Create two unequal columns that floats next to each other */
.column {
float: left;
padding: 10px;
}
.first {
width: calc(50% - 70px);
}
.second {
width: calc(50% - 30px);
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
body {
background-color: rgb(119, 196, 135);
}
a {
text-decoration: none;
color: white;
}
.block {
display: block;
font-weight: bold;
width:100%;
border: none;
background-color: #04AA6D;
padding: 20px 20px;
color: white;
font-size: medium;
cursor: pointer;
text-align: center;
}
@media screen and (max-width: 800px) {
.column {
float: none;
width: 100%;
}
}
</style>
<body style="background-color: rgb(119, 196, 135);">
<div class="row">
<div class="column first">
<form action="/scripts/reboot_system.php" onclick="return confirm('Are you sure you want to reboot?')">
<button type="submit" class="block">Reboot</button>
</form>
<form action="/scripts/update_birdnet.php" onclick="return confirm('BE SURE TO STASH ANY LOCAL CHANGES YOU HAVE MADE TO THE SYSTEM BEFORE UPDATING!!!')">
<button style="color:blue;" type="submit" class="block">Update</button>
</form>
<form action="/scripts/shutdown_system.php" onclick="return confirm('Are you sure you want to shutdown?')">
<button style="color: red;" type="submit" class="block">Shutdown</button>
</form>
<form action="/scripts/clear_all_data.php" onclick="return confirm('Clear ALL Data? This cannot be undone.')">
<button style="color: red;" type="submit" class="block">Clear ALL data</button>
</form>
</div>
</body>