mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-03 22:34:11 +02:00
Update 99-run.sh
This commit is contained in:
@@ -6,27 +6,42 @@ set -e
|
|||||||
# SET /CONFIG #
|
# SET /CONFIG #
|
||||||
###############
|
###############
|
||||||
|
|
||||||
bashio::log.info "Ensuring permissions are good"
|
echo " "
|
||||||
|
bashio::log.info "Ensuring the file structure is correct :"
|
||||||
|
|
||||||
# Define structure
|
# Define structure
|
||||||
echo "... making sure structure is correct"
|
echo "... creating default files"
|
||||||
touch /config/apprise.txt
|
touch /config/apprise.txt
|
||||||
touch /config/include_species_list.txt
|
touch /config/include_species_list.txt
|
||||||
touch /config/exclude_species_list.txt
|
touch /config/exclude_species_list.txt
|
||||||
mkdir -p /config/BirdSongs/Extracted/By_Date
|
|
||||||
mkdir -p /config/BirdSongs/Extracted/Charts
|
# Set BirdSongs folder
|
||||||
mkdir -p /config/BirdSongs/Processed
|
BIRDSONGS_FOLDER="/config/BirdSongs"
|
||||||
mkdir -p /config/BirdSongs/StreamData
|
if bashio::config.has_value "BIRDSONGS_FOLDER"; then
|
||||||
|
BIRDSONGS_FOLDER_OPTION="$(bashio::config "BIRDSONGS_FOLDER")"
|
||||||
|
echo "... BIRDSONGS_FOLDER set to $BIRDSONGS_FOLDER_OPTION"
|
||||||
|
mkdir -p "$BIRDSONGS_FOLDER_OPTION" || bashio::log.fatal "...... folder couldn't be created"
|
||||||
|
chown -R pi:pi "$BIRDSONGS_FOLDER_OPTION" || bashio::log.fatal "...... folder couldn't be given permissions for 1000:1000"
|
||||||
|
if [ -d "$BIRDSONGS_FOLDER_OPTION" ] && [ "$(stat -c '%u:%g' "$BIRDSONGS_FOLDER_OPTION")" == "1000:1000" ]; then
|
||||||
|
BIRDSONGS_FOLDER="$BIRDSONGS_FOLDER_OPTION"
|
||||||
|
else
|
||||||
|
bashio::log.yellow "BIRDSONGS_FOLDER reverted to /config/BirdSongs"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "... creating default folders ; it is highly recommended to store those on a ssd"
|
||||||
|
mkdir -p "$BIRDSONGS_FOLDER"/Extracted/By_Date
|
||||||
|
mkdir -p "$BIRDSONGS_FOLDER"/Extracted/Charts
|
||||||
|
mkdir -p "$BIRDSONGS_FOLDER"/Processed
|
||||||
|
mkdir -p "$BIRDSONGS_FOLDER"/StreamData
|
||||||
|
|
||||||
# Permissions
|
# Permissions
|
||||||
echo "... set permissions to user pi"
|
echo "... set permissions to user pi"
|
||||||
chown -R 1000:1000 /config /etc/birdnet
|
chown -R 1000:1000 /config /etc/birdnet "$BIRDSONGS_FOLDER"
|
||||||
|
|
||||||
# Symlink files
|
# Symlink files
|
||||||
bashio::log.green "Ensuring files are in /config ; please customize as needed"
|
|
||||||
for files in "$HOME/BirdNET-Pi/birdnet.conf" "$HOME/BirdNET-Pi/scripts/birds.db" "$HOME/BirdNET-Pi/apprise.txt" "$HOME/BirdNET-Pi/exclude_species_list.txt" "$HOME/BirdNET-Pi/include_species_list.txt"; do
|
for files in "$HOME/BirdNET-Pi/birdnet.conf" "$HOME/BirdNET-Pi/scripts/birds.db" "$HOME/BirdNET-Pi/apprise.txt" "$HOME/BirdNET-Pi/exclude_species_list.txt" "$HOME/BirdNET-Pi/include_species_list.txt"; do
|
||||||
filename="${files##*/}"
|
filename="${files##*/}"
|
||||||
echo "... setting $filename"
|
echo "... creating symlink for $filename"
|
||||||
if [ ! -f /config/"$filename" ]; then echo "... copying $filename" && sudo -u pi mv "$files" /config/; fi
|
if [ ! -f /config/"$filename" ]; then echo "... copying $filename" && sudo -u pi mv "$files" /config/; fi
|
||||||
if [ -e "$files" ]; then rm "$files"; fi
|
if [ -e "$files" ]; then rm "$files"; fi
|
||||||
chmod 777 /config/*
|
chmod 777 /config/*
|
||||||
@@ -35,44 +50,54 @@ for files in "$HOME/BirdNET-Pi/birdnet.conf" "$HOME/BirdNET-Pi/scripts/birds.db"
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Symlink folders
|
# Symlink folders
|
||||||
for folders in BirdSongs/Extracted/By_Date BirdSongs/Extracted/Charts BirdSongs/Processed BirdSongs/StreamData; do
|
for folders in Extracted/By_Date Extracted/Charts Processed StreamData; do
|
||||||
echo "... setting folder $folders"
|
echo "... creating symlink for $BIRDSONGS_FOLDER/$folders"
|
||||||
rm -r "$HOME/${folders:?}"
|
rm -r "$HOME/BirdSongs/${folders:?}"
|
||||||
sudo -u pi ln -fs /config/"$folders" "$HOME/$folders"
|
sudo -u pi ln -fs "$BIRDSONGS_FOLDER"/"$folders" "$HOME/BirdSongs/$folders"
|
||||||
done
|
done
|
||||||
|
|
||||||
################
|
################
|
||||||
# MODIFY WEBUI #
|
# MODIFY WEBUI #
|
||||||
################
|
################
|
||||||
|
|
||||||
|
echo " "
|
||||||
|
bashio::loginfo "Adapting webui"
|
||||||
|
|
||||||
# Correct the phpsysinfo for the correct gotty service
|
# Correct the phpsysinfo for the correct gotty service
|
||||||
sed -i "s/gotty/$(ps aux | grep -o 'gotty-[a-z0-9]*' | head -n 1)/g" "$HOME"/BirdNET-Pi/templates/phpsysinfo.ini
|
gottyservice="$(ps aux | grep -o 'gotty-[a-z0-9]*' | head -n 1)"
|
||||||
|
echo "... using $gottyservice in phpsysinfo"
|
||||||
|
sed -i "s/,gotty,/,${gottyservice:-gotty},/g" "$HOME"/BirdNET-Pi/templates/phpsysinfo.ini
|
||||||
|
|
||||||
# Remove services tab
|
# Remove services tab
|
||||||
sed -i '/System Controls/d' "$HOME"/BirdNET-Pi/homepage/views.php
|
echo "... removing System Controls from webui as should be used from HA"
|
||||||
|
sed -i '/>System Controls/d' "$HOME"/BirdNET-Pi/homepage/views.php
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# SET SYSTEM #
|
# SET SYSTEM #
|
||||||
##############
|
##############
|
||||||
|
|
||||||
|
echo " "
|
||||||
|
bashio::loginfo "Starting system services"
|
||||||
|
|
||||||
# Set TZ
|
# Set TZ
|
||||||
if bashio::config.has_value 'TZ'; then
|
if bashio::config.has_value 'TZ'; then
|
||||||
TIMEZONE=$(bashio::config 'TZ')
|
TIMEZONE=$(bashio::config 'TZ')
|
||||||
bashio::log.green "Setting timezone to $TIMEZONE"
|
echo "... setting timezone to $TIMEZONE"
|
||||||
ln -snf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime
|
ln -snf /usr/share/zoneinfo/"$TIMEZONE" /etc/localtime
|
||||||
echo "$TIMEZONE" >/etc/timezone
|
echo "$TIMEZONE" >/etc/timezone
|
||||||
fi || (bashio::log.fatal "Error : $TIMEZONE not found. Here is a list of valid timezones : https://manpages.ubuntu.com/manpages/focal/man3/DateTime::TimeZone::Catalog.3pm.html")
|
fi || (bashio::log.fatal "Error : $TIMEZONE not found. Here is a list of valid timezones : https://manpages.ubuntu.com/manpages/focal/man3/DateTime::TimeZone::Catalog.3pm.html")
|
||||||
|
|
||||||
# Correcting systemctl
|
# Correcting systemctl
|
||||||
|
echo "... correcting systemctl"
|
||||||
curl -f -L -s -S https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py -o /bin/systemctl
|
curl -f -L -s -S https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl3.py -o /bin/systemctl
|
||||||
chmod a+x /bin/systemctl
|
chmod a+x /bin/systemctl
|
||||||
|
|
||||||
# Starting dbus
|
# Starting dbus
|
||||||
bashio::log.green "Starting system services..."
|
echo "... starting dbus"
|
||||||
echo "... dbus"
|
|
||||||
service dbus start
|
service dbus start
|
||||||
|
|
||||||
# Starting services
|
# Starting services
|
||||||
|
echo ""
|
||||||
bashio::log.green "Starting BirdNET-Pi services"
|
bashio::log.green "Starting BirdNET-Pi services"
|
||||||
chmod +x "$HOME"/BirdNET-Pi/scripts/restart_services.sh
|
chmod +x "$HOME"/BirdNET-Pi/scripts/restart_services.sh
|
||||||
/."$HOME"/BirdNET-Pi/scripts/restart_services.sh &>/proc/1/fd/1
|
/."$HOME"/BirdNET-Pi/scripts/restart_services.sh &>/proc/1/fd/1
|
||||||
|
|||||||
Reference in New Issue
Block a user