ChuckPa / PlexDBRepair

Database repair utility for Plex Media Server databases
Other
867 stars 43 forks source link

"Error: Unknown host" while running on Arch Linux #65

Closed Spazholio closed 1 year ago

Spazholio commented 1 year ago

Unsure what you need from me to diagnose/troubleshoot, but I'm running on the latest version of Arch and getting the above error when attempting to run.

ChuckPa commented 1 year ago

Arch is not a supported platform at this point.

Because it's not supported as part of Plex main distribution, I have no knowledge of how it might be installed on a host.

Things I need to know:

  1. How to identify the host as Arch Linux ( a file in /etc usually works for this - /etc/os-release, etc )
  2. Pathname of directory containing the Plex executables (e.g. Plex SQLite)
  3. Pathname for the default PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
  4. Command (as root) to start & stop Plex
  5. Whether or not logger is the system logging tool.

There might be a few other tweaks but these are the known variables to fill in as HostConnfig() runs and configures the script to run on the host.

Spazholio commented 1 year ago

Understood. If you have any interest in adding Arch as a supported platform, here are the answers to at least those 5 questiions:

  1. The output of /etc/os-release is:

    NAME="Arch Linux"
    PRETTY_NAME="Arch Linux"
    ID=arch
    BUILD_ID=rolling
    ANSI_COLOR="38;2;23;147;209"
    HOME_URL="https://archlinux.org/"
    DOCUMENTATION_URL="https://wiki.archlinux.org/"
    SUPPORT_URL="https://bbs.archlinux.org/"
    BUG_REPORT_URL="https://bugs.archlinux.org/"
    PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
    LOGO=archlinux-logo

    Additionally, the output of uname -r is 6.2.12-arch1-1 which feels weaker than using /etc/os-release

  2. /usr/lib/plexmediaserver/Plex\ SQLite

  3. I don't have this set as an environment variable, but /var/lib/plex/Plex Media Server/ contains the following:

    drwxr-xr-x  5 plex plex 4.0K Apr 11 12:43  Codecs
    drwxr-xr-x 37 plex plex 4.0K May  1 17:40 'Crash Reports'
    drwxr-xr-x  2 plex plex 4.0K Apr  8 19:01  Diagnostics
    drwxr-xr-x  3 plex plex 4.0K Apr  8 19:01  Drivers
    drwxr-xr-x  4 plex plex 4.0K May  4 15:12  Logs
    drwxr-xr-x  3 plex plex 4.0K Apr  8 19:05  Media
    drwxr-xr-x  7 plex plex 4.0K Apr  8 19:05  Metadata
    -rw-r--r--  1 plex plex    7 May  1 17:40  plexmediaserver.pid
    drwxr-xr-x  4 plex plex 4.0K Apr 19 14:11  Plug-ins
    drwxr-xr-x  8 plex plex 4.0K Apr  8 19:21 'Plug-in Support'
    -rw-------  1 plex plex 1.8K May  3 17:40  Preferences.xml
    drwxr-xr-x  4 plex plex 4.0K Apr 19 14:12  Scanners
    -rw-------  1 plex plex  13K May  2 22:07 'Setup Plex.html'
    drwxr-xr-x  2 plex plex 4.0K Apr  8 19:21  Update
  4. systemctl [start|stop] plexmediaserver.service

  5. I'm uncertain about this one. I know that Plex logs to standalone log files, but I'm don't know if journalctl is thrown into the mix there.

ChuckPa commented 1 year ago

try man logger and see if you get a man page.

As for the environment variables, they all will be defined in /lib/systemd/system/plexmediaserver.service if the start/stop is systemd compliant.

Spazholio commented 1 year ago

I get a man page, yes.

And the contents of /lib/systemd/system/plexmediaserver.service are:

[Unit]
Description=Plex Media Server
After=network.target network-online.target

[Service]
# In this file, set LANG and LC_ALL to en_US.UTF-8 on non-English systems to avoid mystery crashes.
EnvironmentFile=/etc/conf.d/plexmediaserver
ExecStart=/usr/lib/plexmediaserver/Plex\x20Media\x20Server
SyslogIdentifier=plexmediaserver
Type=simple
User=plex
Group=plex
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3

[Install]
WantedBy=multi-user.target

And the contents of /etc/conf.d/plexmediaserver are:

LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib
PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plex
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
PLEX_MEDIA_SERVER_TMPDIR=/tmp
TMPDIR=/tmp
ChuckPa commented 1 year ago

Thanks.

That's what I need to add Arch Linux support.

I'll try to craft up a draft version this weekend.

Spazholio commented 1 year ago

No rush, I appreciate the efforts. Please let me know if you need a guinea pig.

ChuckPa commented 1 year ago

@Spazholio

On branch chuckpa/add-arch-support, you will find:

  1. Updated (v1.0.5) release candidate
  2. Updated ReleaseNotes
  3. Cleaned up README

Please let me know what you find.

Spazholio commented 1 year ago

Color me dumb, but I don't see that branch yet?

ChuckPa commented 1 year ago

You do now. The :monkey: pushed the :eject_button: :rofl:

Spazholio commented 1 year ago

Running as root (tried as regular user and as sudo as well):

Given application support directory override specified does not exist: ''. Ignoring.
ERROR: Cannot write to Databases directory. Insufficient privilege.

Additionally, on line 471, that isn't a directory that exists on my filesystem.

ChuckPa commented 1 year ago

DAMN IT.

How do you have it in /etc/systemd/system/plexmediaserver.service.d/override.conf ?

ChuckPa commented 1 year ago

I thought PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR points to

AppSuppDir="/var/lib/plex/Library/Application Support"

Did I misunderstand you?

Nevermind, I did. :)

Please edit line 471 and remove the Application Support part from the path.

Spazholio commented 1 year ago

Here's what's in that file:

[Unit]
After=mnt-data-media-movies.mount mnt-data-media-tvshows.mount mnt-data-media-videos.mount mnt-data-media-musicvideos.mount mnt-data-media-music.mount
Requires=mnt-data-media-movies.mount mnt-data-media-tvshows.mount mnt-data-media-videos.mount mnt-data-media-musicvideos.mount mnt-data-media-music.mount

But this file doesn't normally exist and was just recently added a couple of days ago to make sure that my network were mounts before Plex starts up. Otherwise it kinda sorta nukes my entire library.

And as per /etc/conf.d/plexmediaserver: PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plex

ChuckPa commented 1 year ago

It's common for networking to be slower than Plex.

On Ubuntu/Debian/Redhat, we have it

[Unit]
Description=Plex Media Server
After=network.target network-online.target

Check that on your system. "network-online.target" is systemd's signal that the network is ready

ChuckPa commented 1 year ago

Found my problem with reading the override.

use this please:

    # Where is the data
    AppSuppDir="/var/lib/plex"

    # Find the metadata dir if customized
    if [ -e /etc/systemd/system/plexmediaserver.service.d ]; then

      # Get custom AppSuppDir if specified
      NewSuppDir="$(GetOverride PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR)"

      if [ "$NewSuppDir" != "" ]; then
        if [ -d "$NewSuppDir" ]; then
          AppSuppDir="$NewSuppDir"
        else
          Output "Given application support directory override specified does not exist: '$NewSuppDir'. Ignoring."
        fi
      fi
    fi
ChuckPa commented 1 year ago

I have an improvement suggestion for your package maintainer.

The service file should be updated to handle the network configuration delay. (SSD systems boot faster than the network hardware can init)

Add the After= clause

[Unit]
Description=Plex Media Server
After=network.target network-online.target

[Service]
ChuckPa commented 1 year ago

@Spazholio

Paul, Have you had an opportunity to try both these changes ?

Spazholio commented 1 year ago

Shoot! Sorry, life gets in the way sometimes. It appears to be working quite well now.

ChuckPa commented 1 year ago

@Spazholio

If you're happy with these changes, I'll commit then to the branch and merge

I have a PR. care to review it ? Thoughts?

Spazholio commented 1 year ago

Sure thing.

ChuckPa commented 1 year ago

Completed.