From 3a40aa892670ce3f6418057c6b909f69845fba37 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Tue, 27 Jul 2021 11:12:05 -0400 Subject: [PATCH] Fixed #25 - bad eventcmd and fifo paths --- install.sh | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index f777025..e91aec5 100755 --- a/install.sh +++ b/install.sh @@ -2,37 +2,40 @@ set -euo pipefail tls_fingerprint=`openssl s_client -connect tuner.pandora.com:443 < /dev/null 2> /dev/null | openssl x509 -noout -fingerprint | tr -d ':' | cut -d'=' -f2` -event_command=${PWD}/eventcmd.sh -fifo=${PWD}/ctl -configdir=~/.config/pianobar repo='https://github.com/kylejohnson/Patiobar.git' +clone_path="$HOME/Patiobar" +event_command=${clone_path}/eventcmd.sh +fifo=${clone_path}/ctl +configdir=~/.config/pianobar if ! which npm &> /dev/null; then echo "npm is not installed!" echo "Installing NPM is beyond the scope of this installer as methods vary by distro, OS and preference." echo "Note that NPM is usually installed with Node.js." echo "https://nodejs.org/en/download/ is a decent place to start." - exit 1; + exit 1 fi # Don't clone if already in the repo -if [ ! -d .git ]; then - if git clone "${repo}"; then - cd Patiobar +if [ ! -d $clone_path ]; then + echo "Cloning $repo in to $clone_path" + if git clone "${repo}" "${clone_path}"; then + cd "${clone_path}" else echo "Could not clone ${repo}" exit 1 fi +else + echo "$repo already exists at $clone_path. Moving on." fi -# Don't run npm install if it has already ran -if [ ! -d node_modules ]; then - echo -n 'Running `npm install`... ' - if npm install > /dev/null 2>&1; then - echo "success" - else - echo "failure" - fi +# Install node packages +echo -n 'Installing node packages... ' +if npm install > /dev/null 2>&1; then + echo "success" +else + echo "failure" + exit 1 fi # Don't create fifo if it already exists @@ -42,13 +45,17 @@ if [ ! -p "${fifo}" ]; then echo "success" else echo "failure" + exit 1 fi +else + echo "Control file already exists. Moving on." fi -echo -n "Creating default ~/.config/pianobar/config file... " + if mkdir -p "${configdir}"; then if ! [ -f "${configdir}/config" ]; then - if cat << EOF >> "${configdir}/config"; then + echo -n "Creating default ~/.config/pianobar/config file... " + if cat << EOF >> "${configdir}/config"; then user = user@example.com password = password #autostart_station = 123456 @@ -58,10 +65,17 @@ fifo = ${fifo} tls_fingerprint = ${tls_fingerprint} EOF echo "success" + echo "You will need to edit ${configdir}/config with your Pandora username and password." else echo "failure" + exit 1 fi else echo "${configdir}/config already exists" + echo "You will need to manually update that file." + exit fi +else + echo "Failed to create $configdir." + exit 1 fi