modern_lisp-machine/misc/scripts/music_server.sh

30 lines
963 B
Bash
Raw Permalink Normal View History

2024-04-02 04:06:40 +00:00
EXEC_SHELL_PATH=$(command -v bash)
# Define the music folder and log file path
MUSIC_FOLDER="/mnt/Data/Audio/"
LOG_FILE="/tmp/navidrome_logfile.log"
2024-06-01 05:00:40 +00:00
#LOG_SERVICE="/tmp/service_music.log"
2024-04-02 04:06:40 +00:00
# Create the log directory if it doesn't exist
mkdir -p "$(dirname "$LOG_FILE")"
2024-06-01 05:00:40 +00:00
#mkdir -p "$(dirname "$LOG_SERVICE")"
2024-04-02 04:06:40 +00:00
# Check if the music folder exists
if [ ! -d "$MUSIC_FOLDER" ]; then
echo -e "\e[91mMount the hard drive first!\e[0m"
exit 1
fi
# Change directory to the music folder
cd "$MUSIC_FOLDER"
# Check if Navidrome is already running
if pgrep -x "navidrome" > /dev/null; then
echo "Navidrome is already running. Exiting."
else
# Run Navidrome command, redirecting output to the log file and detaching it from the terminal
setsid nohup navidrome --musicfolder "$MUSIC_FOLDER" > "$LOG_FILE" 2>&1 &
2024-06-01 05:00:40 +00:00
# setsid nohup loophole http 4533 --hostname ajattix > "$LOG_SERVICE" 2>&1 &
2024-04-02 04:06:40 +00:00
echo "Navidrome started and detached from the terminal."
fi