-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·75 lines (64 loc) · 1.89 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
. ~/.profile
. ~/.bashrc
. ~/.nvm/nvm.sh
# node.js version to use
# hardcoded until a better solution is found (scrapping the HTML seems overkill)
NODE_VERSION=16
# making sure that jq is installed
if ! [ -x "$(command -v jq)" ]; then
echo "jq is not installed..."
echo "installing jq"
sudo apt install jq -y
fi
# making sure that node version manager is installed
if ! [ -x "$(command -v nvm)" ]; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
. ~/.nvm/nvm.sh
fi
# downloading and installing plexamp per the original upgrade.sh script
cd
PLEXAMP_URL=$(curl -s "https://plexamp.plex.tv/headless/version$1.json" | jq -r '.updateUrl')
nvm install $NODE_VERSION
nvm use $NODE_VERSION
wget -q "$PLEXAMP_URL" -O plexamp.tar.bz2
if [[ -d ./plexamp.last ]]; then
rm -rf plexamp.last
fi
if [[ -d ./plexamp ]]; then
mv plexamp plexamp.last
fi
tar xfj plexamp.tar.bz2
rm plexamp.tar.bz2
chown -R "${USER}:${USER}" plexamp
# authenticating if first installation
if ! [ -d ~/.local/share/Plexamp ]; then
echo "authentication needed, follow the instructions below"
cd plexamp
node js/index.js;
cd
fi
# installing service
SERVICE_CONFIG="[Unit]\n
Description=Plexamp\n
After=network-online.target\n
Requires=network-online.target\n
\n
[Service]\n
Type=simple\n
User=pi\n
WorkingDirectory=/home/pi/plexamp\n
ExecStart=$(which node) /home/pi/plexamp/js/index.js\n
Restart=on-failure\n
\n
[Install]\n
WantedBy=multi-user.target"
echo -e $SERVICE_CONFIG > plexamp.service
sudo mv plexamp.service /lib/systemd/system/plexamp.service
# enabling service
sudo systemctl daemon-reload
sudo systemctl enable plexamp
sudo systemctl -q restart plexamp