Skip to content

Commit 7fd2f7f

Browse files
authored
better test for package installed or not.
1 parent fd5f621 commit 7fd2f7f

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

root/etc/cont-init.d/50-plex-update

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
# copy config on first run, regardless of update status
44
[[ ! -e /etc/default/plexmediaserver ]] && \
5-
cp /defaults/plexmediaserver /etc/default/plexmediaserver
5+
cp /defaults/plexmediaserver /etc/default/plexmediaserver
66

77
# test if plex is installed and try re-pulling latest if not
8-
if dpkg -s plexmediaserver > /dev/null 2>&1 ; then
8+
if (dpkg --get-selections plexmediaserver | grep -wq "install"); then
99
:
10-
else echo "for some reason plex doesn't appear to be installed, pulling a new copy and exiting out of update script"
10+
else
11+
echo "for some reason plex doesn't appear to be installed, pulling a new copy and exiting out of update script"
1112
curl -o /tmp/plexmediaserver.deb -L \
12-
"${PLEX_INSTALL}" && \
13+
"${PLEX_INSTALL}" && \
1314
dpkg -i --force-confold /tmp/plexmediaserver.deb
1415
rm -f /tmp/plexmediaserver.deb
1516
exit 0
1617
fi
1718

1819
# set no update message
1920
[[ -e /tmp/no-version.nfo ]] && \
20-
rm /tmp/no-version.nfo
21+
rm /tmp/no-version.nfo
2122
NOVERSION_SET='/tmp/no-version.nfo'
2223
cat > "${NOVERSION_SET}" <<-EOFVERSION
2324
#######################################################
@@ -30,7 +31,7 @@ EOFVERSION
3031

3132
# set update failed message
3233
[[ -e /tmp/update_fail.nfo ]] && \
33-
rm /tmp/update_fail.nfo
34+
rm /tmp/update_fail.nfo
3435
UPGRADE_FAIL='/tmp/update_fail.nfo'
3536
cat > "${UPGRADE_FAIL}" <<-EOFFAIL
3637
########################################################
@@ -50,7 +51,7 @@ fi
5051

5152
# set header for no preferences/token message
5253
[[ -e /tmp/no-token.nfo ]] && \
53-
rm /tmp/no-token.nfo
54+
rm /tmp/no-token.nfo
5455
NOTOKEN_SET='/tmp/no-token.nfo'
5556
cat > "${NOTOKEN_SET}" <<-EOFTOKEN
5657
#####################################################
@@ -70,8 +71,8 @@ fi
7071

7172
# attempt to read plex token
7273
PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' \
73-
"/config/Library/Application Support/Plex Media Server/Preferences.xml" \
74-
| sed "s/\".*//")
74+
"/config/Library/Application Support/Plex Media Server/Preferences.xml" \
75+
| sed "s/\".*//")
7576

7677
# if plex token isn't found, exit out
7778
if [ -z "$PLEX_TOKEN" ]; then

0 commit comments

Comments
 (0)