forked from ohhdemgirls/PlexInTheCloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02a-plexpy.sh
executable file
·66 lines (57 loc) · 1.72 KB
/
02a-plexpy.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
#!/bin/bash
source vars
## INFO
# This script installs plexpy
##
#######################
# Pre-Install
#######################
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Execute 'sudo su' to swap to the root user."
exit 1
fi
#######################
# Install
#######################
git clone https://github.com/JonnyWong16/plexpy.git /opt/plexpy/
#######################
# Systemd Service File
#######################
tee "/etc/systemd/system/plexpy.service" > /dev/null <<EOF
[Unit]
Description=PlexPy - Stats for Plex Media Server usage
After=plexmediaserver.service
[Service]
ExecStart=/opt/plexpy/PlexPy.py --quiet --daemon --nolaunch --config /opt/plexpy/config.ini --datadir /opt/plexpy
GuessMainPID=no
Type=forking
User=$username
Group=$username
[Install]
WantedBy=multi-user.target
EOF
#######################
# Permissions
#######################
chown -R $username:$username /opt/plexpy
#######################
# Autostart
#######################
systemctl daemon-reload
systemctl start plexpy
systemctl enable plexpy
#######################
# Remote Access
#######################
echo ''
echo "Do you want to allow remote access to PlexPy?"
echo "If so, you need to tell UFW to open the port."
echo "Otherwise, you can use SSH port forwarding."
echo ''
echo "Would you like us to open the port in UFW?"
select yn in "Yes" "No"; do
case $yn in
Yes ) ufw allow 8181; echo ''; echo "Port 8181 open, PlexPy is now available over the internet."; echo ''; break;;
No ) echo "Port 8181 left closed. You can still access it on your local machine by issuing the following command: ssh $username@$ipaddr -L 8181:localhost:8181"; echo "and then open localhost:8181 on your browser."; exit;;
esac
done