Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemd install #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ If you just want to get running, you can use a pre-built chroot with the latest

(~~Btw, the chroot is built nightly from master using Docker on a C1.~~ Manually built for now. See the [Makefile](Makefile.docker) for details.)

## Install as service using a pre-built chroot

Grab the latest release from [Releases](https://github.com/Fornoth/spotify-connect-web/releases)

If you want to install it as a service, install a pre-built chroot with the latest version installed.
### Installation instructions (example):

curl -O curl -OL https://github.com/Fornoth/spotify-connect-web/releases/download/0.0.3-alpha/spotify-connect-web.sh
chmod u+x spotify-connect-web.sh
# Download the current chroot (~ 180 MB)
sudo ./spotify-connect-web.sh install-system
# Copy your `spotify_appkey.key` into the app directory. (See below for information on how to get that file.)
sudo cp spotify_appkey.key /usr/local/lib/spotify-connect-web/usr/src/app/
# Run once using normal cmdline options
sudo /usr/local/bin/spotify-connect-web.sh --username 12345678 --password xyz123 --bitrate 320
# start service
sudo systemctl start spotify-connect


## Quickstart with Docker
(You will have to use `sudo` if not logged in as root.)

Expand Down
43 changes: 43 additions & 0 deletions spotify-connect-web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
set -e

DIR=~/spotify-connect-web-chroot
DIR_SYSTEM=/usr/local/lib/spotify-connect-web
DIR_SYSTEMD=/lib/systemd/system/
NAME=rpi-server3

if [ "$1" == "install-system" ]; then
if [ "$(id -u)" != "0" ]; then
echo "For system wide install this script must be run as root (e.g. use sudo $0)" 1>&2
exit 1
fi
mkdir -p $DIR_SYSTEM
cd $DIR_SYSTEM
curl http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.tar.gz | sudo tar xz
cp $0 $DIR_SYSTEM/../../bin/
cat >/lib/systemd/system/spotify-connect.service <<EOF
[Unit]
Description=Spotify Connect

[Service]
ExecStart=$DIR_SYSTEM/../../bin/$(basename $0) --name $NAME --bitrate 320
StandardOutput=null

[Install]
WantedBy=multi-user.target
Alias=spotify-connect.service

EOF
systemctl enable spotify-connect.service

elif [ "$1" == "install" ]; then
mkdir -p $DIR
cd $DIR
curl -L https://github.com/Fornoth/spotify-connect-web/releases/download/0.0.3-alpha/spotify-connect-web_0.0.3-alpha_chroot.tar.gz | sudo tar xz
else
trap "sudo umount $DIR/dev $DIR/proc" EXIT
sudo mount --bind /dev $DIR/dev
sudo mount -t proc proc $DIR/proc/
sudo cp /etc/resolv.conf $DIR/etc/
sudo chroot $DIR /bin/bash -c "cd /usr/src/app && python main.py $*"
fi