diff --git a/combine.sh b/combine.sh new file mode 100644 index 00000000..8dc527b6 --- /dev/null +++ b/combine.sh @@ -0,0 +1,42 @@ +#!/bin/bash +shopt -s globstar + +path="/home/$(logname)/pikaraoke-songs" +combined="/media/unified" +drive_list="/home/$(logname)/pikaraoke/list" +cache="/home/$(logname)/pikaraoke-songs/song_cache" +#ensure directories and files exist +if [[ -d $path ]]; then + echo "$path exists" +else + sudo mkdir -p $path +fi +if [[ -d $combined ]]; then + echo "$combined exists" +else + sudo mkdir -p $path +fi + +#get a list of external devices +lsblk -o NAME | grep sd[a-z][0-9] > $drive_list +sed -i 's/^..//' $drive_list + + +for drive in $(cat $drive_list); do + echo "combining drives" + sudo mount "/dev/$(basename $drive)" "/media/$(basename $drive)" + sudo mount --bind "/media/(basename $drive)" $combined +done + +#run plocate and get a list of all song paths in the combined folder +bash /home/$(logname)/pikaraoke/create_database.sh + +#add songs to ~/pikaraoke-songs +while IFS= read -r song || [ -n "$song" ]; do + if [[ ! -e "$path/$(basename "$song")" ]]; then + BASE=$(basename "$song") + ln -sf "$song" "/home/pi/pikaraoke-songs/$BASE" + fi +done < <(cat "song_paths") +echo "" > song_paths +#ls $path > $cache diff --git a/create_database.sh b/create_database.sh new file mode 100644 index 00000000..cd0d2e8f --- /dev/null +++ b/create_database.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +#make an updatedb specifically for /media/unified +sudo updatedb -l 0 -U /media/unified -o /home/$(logname)/pikaraoke/plocate.db +plocate media/$(logname) | grep -E "\.(zip|cdg|mp3|mp4)$" > song_paths diff --git a/setup.sh b/setup.sh index ce8fc2b5..63820b35 100755 --- a/setup.sh +++ b/setup.sh @@ -18,6 +18,7 @@ if [[ $(cat /etc/os-release | grep -i debian) != "" ]]; then sudo apt-get install ffmpeg -y sudo apt-get install chromium-browser -y sudo apt-get install chromium-chromedriver -y + sudo apt-get install plocate -y if [ $? -ne 0 ]; then echo "ERROR: Binary dependency installation failed with error code: $?"; exit 1; fi else echo "Client is not Debian-based. Skipping binary installation. Please install ffmpeg and chrome manually.";