2015-02-12 16:58:54 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Set location of the config file
|
|
|
|
conf_path=/etc/forked-daapd.conf
|
|
|
|
|
|
|
|
if [ ! -f $conf_path ]; then
|
|
|
|
echo "Error: Couldn't find $conf_path"
|
|
|
|
echo "Set the correct config file location in the script"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
logfile=`awk '$1=="logfile"{print $3}' $conf_path`
|
|
|
|
logfile="${logfile%\"}"
|
|
|
|
logfile="${logfile#\"}"
|
2015-02-26 14:52:49 -05:00
|
|
|
library_path=`awk '$1=="directories"{print}' $conf_path`
|
|
|
|
library_path="${library_path#*\"}"
|
|
|
|
library_path="${library_path%%\"*}"
|
2015-02-12 16:58:54 -05:00
|
|
|
|
|
|
|
if [ ! -f $logfile ]; then
|
|
|
|
echo "Error: Couldn't find logfile in $logfile"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ ! -d $library_path ]; then
|
|
|
|
echo "Error: Couldn't find library in $library_path"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "This script will help you pair Remote with forked-daapd"
|
|
|
|
echo "Please verify that these paths are correct:"
|
|
|
|
echo " Log file: $logfile"
|
|
|
|
echo " Library: $library_path"
|
|
|
|
read -p "Confirm? [Y/n] " yn
|
|
|
|
if [ "$yn" = "n" ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
echo "Please start the pairing process in Remote by selecting Add library"
|
|
|
|
read -p "Press ENTER when ready..." yn
|
|
|
|
echo -n "Looking in $logfile for Remote announcement..."
|
2015-02-14 17:10:58 -05:00
|
|
|
sleep 5
|
2015-02-12 16:58:54 -05:00
|
|
|
|
|
|
|
remote=`grep "Discovered remote" $logfile | tail -1 | grep -Po "'.*?'"`
|
|
|
|
remote="${remote%\'}"
|
|
|
|
remote="${remote#\'}"
|
|
|
|
|
|
|
|
if [ -z "$remote" ]; then
|
|
|
|
echo "not found"
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo "found"
|
|
|
|
fi
|
|
|
|
|
|
|
|
read -p "Ready to pair Remote '$remote', please enter PIN: " pin
|
|
|
|
if [ -z "$pin" ]; then
|
|
|
|
echo "Error: Invalid PIN"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Writing pair.remote to $library_path..."
|
2015-02-27 17:01:15 -05:00
|
|
|
printf "$remote\n$pin" > "$library_path/pair.remote"
|
2015-02-12 16:58:54 -05:00
|
|
|
sleep 1
|
|
|
|
echo "Removing pair.remote from library again..."
|
|
|
|
rm "$library_path/pair.remote"
|
|
|
|
echo "All done"
|
|
|
|
|